Migrating a WordPress Site Without Downtime

At the time of writing this, I’m currently in the process of migrating WordPress sites from one host to another. In particular, I’m moving from WebFaction to DreamHost. However, in this tutorial, I’ll try to be as generic as possible.

Right. Assuming that you have the same set up as I do:

  • You still have access to the old hosting provider.
  • You’ve already signed up to a new hosting provider.
  • Both hosting providers support MySQL databases.
  • You have your domain name registered with anyone but any of the providers. If you ask why I do that, I have learnt to not put things in the same basket. This also makes it easier to move things around as you will see here. If you have it with the old hosting provider, you will most likely lose access to it. Many hosting providers give it for free just because you pay them for hosting. As at now, I register my domain names with VentraIP (in the past, Hover, whom I still recommend).
  • You have your DNS, but not with any of the hosting providers. If you ask why I do that, see above. The easiest thing would probably be having it with the domain name registrar. As at now, I use the CDN provider CloudFlare for this.
  • You have your emails hosted elsewhere. If you ask me why I do that, see above. As at now, I use FastMail.

Let’s get on to it.

Prepping

First, take note of your current DNS settings, particularly the A and AAAA records. In case there’s a failure, rolling back would be your friend.

This is how the records look like on CloudFlare.cloudflare-dns-pre

If possible, lower the TTL for those records to the lowest possible.

Now, we’ll prepare things at the new hosting provider. Setup a hosting home directory (the htdocs folder or whatever it’s called by your hosting provider) for your domain name. Suffice to say, that means it will be fully hosted there.

Still at your new hosting provider, create a subdomain that mirrors the domain you’re hosting, say mirrormirroronthewall.name.tld.mirrored-domain.png

You need to find out the IP address of the server at your new hosting provider that will host your site. (On DreamHost, choose ‘DNS’ for your domain name and scroll down to ‘Non-editable DreamHost DNS records …’.) Get the value of the A record.ip-address.png

On your DNS server, add a new A record pointing to this server.add-mirror-a-record.png

Create a new empty database at your new hosting provider. Take note of the database host, database name, database username, and the password. If your new provider doesn’t use a standard database port, take note of that as well. Optional: I suggest using a randomly generated password with the maximum possible length, like this secure password generator. Unless you understand PHP and how to escape special characters (or simply can’t be bothered), just use numbers and letters.

Great, things are ready at the new place.

Now, move back to the old hosting provider. Go to your WordPress admin area. If you haven’t, install the Duplicator plugin.

From the admin area, select Duplicator / Packages. Select ‘Create New’. Give it a name or just use the suggested one. Just use all the defaults, except the ‘Installer’ area. Now, just to be extract cautious, tick ‘Enable Password Protection’, and supply a password. Under the ‘Prefills’ section, supply the MySQL server settings you took note of a couple of steps ago. Hit ‘Next’.

Duplicator will do a scan. If all’s good, hit ‘Build’ and Duplicator will build a package.duplicator-building-package.png

Once completed, download both Installer (installer.php) and Archive (whatever name chosen) to your computer. We’re now close to abandoning the old hosting provider, but don’t do that yet.

Let’s go back to the new hosting provider. Upload both Installer and Archive to the root web hosting directory, and point your web browser to installer.php on the mirror site, e.g. http://mirrormirroronthewall.name.tld/installer.php.

You will get the Duplicator deployment page.duplicator-mirror-site.png

Tick ‘I have read …’ and hit ‘Next’. It will extract the files from the Archive and take you to Step 2.

Make sure that the database settings are correct including the password and hit ‘Test Database’. Make sure the test passes and hit ‘Next’ and confirm.

Now we’re on Step 3. Under ‘New Settings’, change the URL from the mirror address to the actual address, e.g. https://name.tld. Under ‘Options’, do the same thing for Site URL.

Assuming everything goes well, we’re now on Step 4. Don’t do anything yet.

Go back to the DNS records. Now, set the A records (alsoAAAA if your new provider supports it) to point to the new server IP address (you did take note of it, right?).

I know it is 2019, but I’m old enough to experience the Internet in the 1990s. Take a deep breath, exercise, you know, anything while DNS propagation takes place.

(C’mon, I’ll wait.)

OK, you’re back. Now, back to the Step 4 page, hit ‘Admin Login’.

You should be done now. But, just for extra caution, SFTP to your new host provider, and make sure that the Installer and Archive are gone already.

Congratulations. The migration is done!