How to migrate your WordPress site to a new host

The most reliable way to migrate your site is using the manual method in this article. However, the manual method can be tricky for less-technical users.

The Duplicator plugin promises to make this easy, but I’ve found it to be incredibly buggy and has failed me on numerous ocassions. Because of this, I use UpdraftPlus for easy migrations. You can make this simpler by buying the UpdraftPlus Migration extension, but it’s also possible to do it for free fairly easily using the guide below along with a search/replace script which covers the functionality provided by the Migration extension.

Migrating your site using UpdraftPlus

Create a backup of your live site

  1. Log into your live site
  2. Install UpdraftPlus
  3. Create a backup
  4. Download the backup files (there will be 4 or more files)

Restore to your dev/new site

Note: Restoring to your dev site from your live site will copy across all user accounts from your live site, replacing any existing user accounts you have on your dev/new site. If you have just set up your new/dev site, you will probably have just an admin account for WordPress. You need to use this for this steps below, but after ther restoration is complete that admin account will be replaced by the credentials from your live site.

  1. Log into your new dev site
  2. Install Updraft plus
  3. On the Existing Backups tab for Updraft Plus, click the link to Upload backup files and choose your backup files
  4. Refresh the page once it’s completed uploading
  5. Click to restore and tick everything to restore
  6. Because you have a different domain in use, it will warn you it’s a migration, not a restoration – just skip that – we will search/replace manually below to complete the migration

Migrating your site manually

This is a technical checklist – if you are unfamiliar with SSH/Putty, you should use the UpdraftPlus approach to migration above.

  1. SSH to your old site, navigate to the webroot folder
  2. Run: zip -r backup.zip wp-content
  3. Run: mysqldump -u username -p dbname > backup.sql (then hit enter and then enter password)
  4. SSH to your new site
  5. SFTP oldipaddress
  6. Navigate to webroot
  7. Run: get backup*
  8. Extract these zip files to somewhere then copy the wp-content/* to your new wp-content folder
  9. Then replace the DB using: mysql -u username -p dbname < backup.sql

Note: The above approach presumes everything custom in your site is in wp-content. If it’s in /assets/ or somewhere instead, you’ll also need to copy those files over.

Search/Replace in your database to change all www.yourdomain.com references to dev.yourdomain.com

If you visit your copied-website now, you will see everything from your live site, but if you click any links you will end up back on your live site. This is because the backup you copied across has references to your live domain name. The tool and steps below allow you to search/replace all the correct places to change these hyperlinks to point to your new dev hyperlinks.

This is the only tricky part about using Updraft Plus and in fact if this is too tricky for you, you can go UpdraftPlus premium and it includes this functionality in the plugin.

  1. Download the Interconnectit search/replace script from here: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
  2. Extract the files, upload the folder to your /var/www/yourdomain/ folder using Filezilla or Cyberduck or similar
  3. Visit your sitedomain.com/searchfolder in your browser – e.g. https://www.superspeedyplugins.com/searchreplace
  4. It will automatically pick up database credentials
  5. Enter www.yourdomain.com in the search box and dev.yourdomain.com in the replace box
  6. Hit Live run and wait

How to make your dev site live

Once you are happy that the performance of your new hosts outperforms your old hosts, you can flip the switch. Here’s how to do it with zero downtime:

  1. Run the search replace script again by opening http://dev.yourdomain.com/searchreplace
  2. Enter dev.yourdomain.com in the search box, www.yourdomain.com in the replace box
  3. Hit live run and wait
  4. Visit your DNS and edit the A records for www.yourdomain.com and yourdomain.com to point to your new IP address
  5. Once you have completed this final search replace and confirmed you are live, you should delete the searchreplace folder using Filezilla as it’s a major security hole leaving it there.

That’s it – you’re live!

Tags:

5 Comments
Show all Most Helpful Highest Rating Lowest Rating Add your review
  1. I absolutely agree that it is really wonderful. This is a very important issue and we should pay attention to it. Thank you for very good guide:)

  2. Hi Dave,
    Thanks so much for this article – I found it really helpful.
    My original site is https – I’m having issues with the dev site as I have no ssl on it – any ideas?
    (Having trouble logging in, it keeps saying not secure etc)

    Cheers,
    Lars

    • The easiest way to fix this is to add SSL to your dev site. You can use Letsencrypt to get yourself a FREE legitimate SSL. I have a guide coming soon but there are guides out there on the internet.

  3. Not so detailed instructions but I’ll try them.

    I understand the basic concept of a WordPress site migration and with the help of your tips i’ll try and migrate one of my WP sites now.

    Even though I can always ask the Rosehosting guys to do the migration, i want to learn to do this manually. I might even consider using a plugin. But first things first, I’m off to my first manual migration attempt.

    Thanks for the article.

    • Hi Larry,

      A purchase of our Fast Stack would allow the WPI team to handle the migration for you. Glad you liked our article. If we can be of any assistance, ping us and we will be happy to help.

      Regards

      John

Leave a reply

Super Speedy Plugins
Logo