Server management · Migrations

Zero-downtime server migration: the checklist I actually use

A practical, step-by-step checklist for moving a live website or app to a new server or cloud without downtime or data loss.

To migrate a live server without downtime: lower your DNS TTL two days early, build and test the new server in parallel, keep data in sync until the switch, rehearse the cut-over, freeze writes for the final sync, switch DNS or the load balancer, and keep the old server running untouched for a week as your rollback.

I've moved a lot of production systems between hosts, clouds and data centres, including the products we run at LOLCorp. The migrations that go wrong almost never fail because of a hard technical problem. They fail because a step was skipped: a forgotten cron job, a DNS record nobody knew existed, an email setting that only breaks three days later. This is the checklist I work through every time.

1. Inventory everything the old server does

Before touching the new machine, write down every job the old one performs. Not just the website. Check:

  • Services: systemctl list-units --type=service --state=running
  • Scheduled jobs: every user's crontab (crontab -l -u <user>), /etc/cron.* and systemd timers (systemctl list-timers)
  • Open ports: ss -tulpn tells you what is listening and which process owns it
  • Outbound dependencies: SMTP relays, payment webhooks, third-party API allowlists that pin your current IP address
  • DNS: export the whole zone, including MX, SPF, DKIM, DMARC and any verification TXT records
  • Certificates, secrets and environment files that live outside your repository

IP allowlists are the classic trap. A payment provider or partner API that only accepts your old IP address will fail silently the moment traffic moves. Find those early and ask for the new address to be added in advance.

2. Lower the DNS TTL 48 hours ahead

If your records have a TTL of a day, resolvers around the world can keep sending visitors to the old server for up to a day after you switch. Drop the TTL on the records you will change to 300 seconds at least one full old-TTL period before the migration. On switch day, changes then spread in minutes. Raise it again once you are settled.

3. Build the new server from code, not by hand

Provision the new environment with a script, Ansible, or at minimum a written runbook you follow line by line. Two reasons: you will probably build it more than once (rehearsals), and the next migration becomes trivial. Match runtime versions exactly first; upgrade later, separately. Changing hosts and upgrading PHP, Node or PostgreSQL in the same night doubles the places a fault can hide.

4. Keep the data in sync

Files and databases need different strategies:

  • Files and uploads: run rsync -aHAX --delete repeatedly. The first run is slow; each later run only copies changes, so the final sync during the cut-over takes seconds.
  • Small databases: a dump and restore during a short write freeze is fine. Time it in rehearsal so you know exactly how long the freeze lasts.
  • Large or busy databases: set up replication from old to new (native streaming replication for PostgreSQL, a replica for MySQL), let it catch up, then promote the new server at cut-over.

5. Test the new server before anyone can see it

Point your own machine at the new server with a hosts-file entry and click through everything: sign-in, checkout, uploads, emails, background jobs, admin screens. Run your test suite against it. Check the logs for errors while you do. This is where the forgotten cron job usually shows up.

6. Rehearse the cut-over

Write the cut-over as a numbered list with owners and expected timings, then run it end to end against a copy. The rehearsal tells you how long the write freeze really is and catches the steps that only exist in someone's head.

7. Cut over, with a rollback ready

  1. Put the app into maintenance or read-only mode to freeze writes.
  2. Run the final file sync and database sync, or promote the replica.
  3. Switch DNS or the load balancer to the new server.
  4. Run your smoke tests on the live domain.
  5. Lift the write freeze.

Decide the rollback trigger before you start, for example: "If checkout fails for more than five minutes, we point DNS back." With a 300-second TTL, rolling back is as fast as rolling forward.

8. Watch, then decommission slowly

Keep the old server running, untouched, for at least a week. Watch error rates, response times, email deliverability and scheduled job output. Only then take a final backup of the old machine and switch it off. Raise the DNS TTL back to normal.

FAQ

How long does a server migration take?

A typical small business site or app takes one to two weeks end to end, including inventory, building the new server, rehearsal and a week of monitoring. The actual switch-over is usually under an hour, and visitors see little or no downtime.

Will my email stop working when I move servers?

Not if your MX, SPF, DKIM and DMARC records are copied exactly and you update SPF if the new server sends mail. Export the full DNS zone before you start and compare it record by record afterwards.

Can I migrate and upgrade at the same time?

You can, but you shouldn't. Move first with identical versions, confirm everything is stable, then upgrade as a separate step. If something breaks, you will know which change caused it.

Keep reading