Skip to content

Moving a website to a new host

A step-by-step plan for moving files, databases, email and DNS with no lost data and minimal downtime.

6
Sections
2 min
Read time

A migration goes wrong in predictable ways: a forgotten database, email that stops arriving, or a DNS change made before the new server was ready. Following a fixed order avoids all three.

1. Take stock

  • List every domain and subdomain on the old account.
  • List databases, cron jobs, email accounts and forwarders.
  • Note the software versions in use (PHP, MySQL or MariaDB, Node.js).
  • Export the current DNS zone, including MX and TXT records.

2. Prepare DNS

A day before the move, lower the TTL of the A, AAAA and CNAME records you will change to 300 seconds. This makes the final switch take minutes instead of hours.

3. Copy the site

  1. Take a full backup on the old host and keep a copy off both servers.
  2. Copy the files to the new server.
  3. Export the databases and import them on the new server.
  4. Update configuration files with the new database name, user and password.
  5. Recreate cron jobs and any environment variables.

4. Test before switching

Test the site on the new server before changing DNS by pointing your own computer at it through the hosts file:

# /etc/hosts (macOS, Linux) or C:\Windows\System32\drivers\etc\hosts
203.0.113.10  example.com www.example.com

Check the home page, logins, forms, checkout and file uploads. Remove the line when you are done.

5. Switch

  1. Put the old site in maintenance mode, or stop changes, so no new orders or posts are lost.
  2. Re-sync the database if anything changed since the copy.
  3. Update the DNS records (or nameservers).
  4. Issue the SSL certificate on the new server once the domain points to it.

6. Afterwards

  • Keep the old account running for at least a week in case something was missed.
  • Watch error logs and email delivery for a few days.
  • Raise the DNS TTL back to its normal value.

Email is the part most often broken by a migration. If mailboxes are moving too, plan their copy separately and check MX, SPF and DKIM after the switch.