| |

Zero-Downtime Website Migration to Linux Hosting: Complete Runbook

Zero-downtime website migration to Linux hosting process flow diagram from audit to DNS cutover

Verified Answer

A zero-downtime migration to Linux hosting lowers DNS A record TTL to 300 seconds 48 hours ahead, pre-seeds files via SSH rsync -avz, verifies the new host via local /etc/hosts override, runs a final delta rsync and mysqldump –single-transaction sync, and switches DNS records.

Switching hosting providers without careful DNS timing causes split-brain database writes and lost orders. Follow this 48-hour zero-downtime Linux migration protocol using 300s TTLs, SSH rsync, hosts testing, and a final delta sync.

T-48h TTL Reduction

Drop DNS A and AAAA record TTLs to 300 seconds early so global resolvers pick up the new IP within minutes.

Two-Pass Rsync Sync

Pre-seed 99% of media while live, then run a fast --delete delta pass right before DNS cutover.

Private /etc/hosts QA

Verify PHP versions, database connections, and SSL certificates on the destination server before anyone else sees it.

The Four-Phase Zero-Downtime Migration Timeline

Successful migrations treat time as an ally. By splitting the workload across four distinct phases—starting 48 hours before cutover—each step becomes small, verifiable, and reversible. If anything unexpected appears during Phase 3 testing, your live site has not been touched and you can fix the issue calmly.

Migration Phase Timing Primary Action Visitor Impact
Phase 1: DNS & Provisioning T-48 Hours Lower DNS TTL to 300s; create DB & SSH access on target Zero impact
Phase 2: Bulk Rsync Pre-Seed T-24 Hours Copy media, themes, and core files via rsync -avz Zero impact
Phase 3: Private QA T-4 Hours Test database import and site rendering via /etc/hosts Zero impact
Phase 4: Delta & Cutover T-0 (Off-Peak) Brief write freeze, final rsync + SQL sync, flip DNS A record < 60s write pause (or 0s for static/read sites)

Phase 1: Reducing DNS TTL and Preparing the Target Host

DNS resolvers cache your domain’s A record for the duration of its Time to Live (TTL). Many registrars default to a TTL of 14400 seconds (4 hours) or 86400 seconds (24 hours). If you change your IP address while a 24-hour TTL is active, half your visitors will hit the old server while the other half hit the new server for an entire day—a split-brain scenario that breaks shopping carts and user comments.

At least 48 hours before your planned cutover, log into your DNS provider and lower the TTL on your root @, www, and any application subdomain records to 300 seconds (5 minutes). Do not change the IP addresses yet. If you use Cloudflare as your authoritative DNS, set the proxy status to DNS-only (grey cloud) temporarily during the cutover window if you want to verify direct origin IP responses cleanly, or keep orange-cloud proxying enabled and simply update the origin IP in Cloudflare’s dashboard for near-instant edge cutover.

On the new Linux host, provision the domain, create an empty MySQL/MariaDB database with a strong password, and match the PHP version currently running on your source server. Also verify that SSH key authentication works between the destination server and source server so rsync runs unattended without password timeouts during large media transfers. Finally, audit any custom php.ini directives—such as upload_max_filesize, post_max_size, and memory_limit—so the new environment mirrors production before you import a single byte.

Phase 2: Server-to-Server Rsync Pre-Seeding

Instead of compressing a 15 GB public_html directory into a zip file that eats up disk quota on both servers, use rsync over SSH to stream files directly from the source host to the destination host. Running the first pass a day ahead transfers the bulk of static assets—images, PDFs, plugins, and framework libraries—while your site continues serving traffic normally.

bash — Run Initial Bulk Rsync from Target Server (Pull Mode)
# Execute on the NEW target Linux server (pulls from old server)
rsync -avz --progress \
  --exclude 'wp-content/cache/' \
  --exclude 'error_log' \
  --exclude '.well-known/' \
  -e "ssh -p 22" \
  [email protected]:/home/olduser/public_html/ \
  /home/newuser/public_html/

If your source server uses a non-standard SSH port, update -e "ssh -p 2222" accordingly. Should the network connection drop mid-transfer on a 20 GB media library, simply re-run the exact same command: rsync automatically resumes from where it left off without re-transferring completed files.

Streaming Multi-Gigabyte Databases Without Disk Bloat

When migrating databases larger than 2 GB, avoid writing an uncompressed .sql dump to disk on the source server, which can exhaust your account’s storage quota mid-export. Instead, stream mysqldump directly through an SSH tunnel into the target MySQL instance—and strip legacy DEFINER clauses on the fly so views and triggers never fail on the new username:

bash — Stream Compressed SQL Dump Over SSH and Strip Legacy DEFINERs
ssh [email protected] "mysqldump --single-transaction --quick --routines --triggers old_prod_db | gzip -3" \
  | gunzip \
  | sed -E 's/DEFINER=[^*]+\*/\*/g' \
  | mysql new_prod_db

Because the stream compresses over the wire with gzip -3 and pipes directly into mysql on the destination host, zero temporary dump files touch either disk. For databases exceeding 10 GB, consider mydumper and myloader with 4–8 parallel threads on VPS hosts to cut import times by up to 70%.

Phase 3: Testing the New Server via /etc/hosts and SSL

Before touching public DNS, verify that the new Linux server renders every page cleanly. Import a test snapshot of your database into the new host using the streaming terminal method from our CLI SQL import guide, update wp-config.php or .env with the new database credentials, and override DNS locally on your own workstation:

hosts — Override DNS Locally to Preview the New Linux Server
# macOS / Linux: /etc/hosts
# Windows (Run as Administrator): C:\Windows\System32\drivers\etc\hosts
198.51.100.25   yourdomain.com www.yourdomain.com

Flush your local DNS cache (sudo dscacheutil -flushcache on macOS or ipconfig /flushdns on Windows) and open https://yourdomain.com in an incognito browser window. Click through checkout, login forms, and API endpoints, and inspect Apache/PHP error logs on the new server to catch missing PHP extensions (such as imagick, intl, or mbstring) early.

Pre-Provisioning SSL Without Downtime: Let’s Encrypt HTTP-01 validation fails before DNS points to the new server. To avoid a 5-minute HTTPS warning at cutover, either issue a commercial/wildcard certificate beforehand, use Cloudflare Origin SSL, or validate a Let’s Encrypt certificate via DNS-01 TXT records as explained in our Let’s Encrypt vs commercial SSL guide.

Handling Email Accounts, Cron Jobs, and Webhooks

Web files and databases are only half the migration surface. Before cutover, recreate every mailbox on the destination server (if you host mail locally rather than on Google Workspace or Microsoft 365) and sync existing IMAP folders using imapsync or rsync against ~/mail/. Once DNS flips, run one final imapsync pass against the old server’s IP so any message delivered during propagation lands safely in the new inbox.

Equally important, audit crontab -l on the old server and pause automated billing, invoice, or backup cron jobs right at T-0. Leaving cron active on both servers simultaneously during the 72-hour cooldown window can trigger duplicate subscription charges or conflicting offsite S3 backups.

Phase 4: Final Delta Sync, Database Freeze, and DNS Cutover

During your scheduled off-peak cutover window, your goal is to ensure zero data divergence between the old and new servers. For brochure sites or blogs with no user-submitted data, you can skip the freeze. For WooCommerce stores, forums, or SaaS apps, briefly enable a read-only or maintenance banner on the old server for 60 seconds so no new orders are written while the final database dump runs.

bash — Final Delta Rsync and Atomic Database Cutover
# 1. Run final delta rsync (only transfers files changed since Phase 2)
rsync -avz --delete \
  --exclude 'wp-content/cache/' \
  --exclude 'wp-config.php' \
  --exclude '.env' \
  -e "ssh -p 22" \
  [email protected]:/home/olduser/public_html/ \
  /home/newuser/public_html/

# 2. Stream final consistent InnoDB snapshot directly to the new server
ssh [email protected] "mysqldump --single-transaction --quick old_prod_db | gzip -1" \
  | gunzip | mysql new_prod_db

Notice that wp-config.php and .env are explicitly excluded in the final rsync --delete pass so your updated database credentials on the new server are preserved. As soon as the database import exits with status 0, update your DNS A and AAAA records to point to the new server’s IP address.

Post-Cutover Verification and 72-Hour Decommission Rule

Remove the temporary line from your local /etc/hosts file immediately after flipping DNS so your browser tests real public resolution. Then run three quick checks:

  • Verify DNS Propagation: Query authoritative resolvers with dig +short yourdomain.com @1.1.1.1 and @8.8.8.8 to confirm the new IP is live globally.
  • Confirm SSL & Security Headers: Run curl -I https://yourdomain.com to verify HTTP 200 status, valid TLS termination, and active HSTS/security headers.
  • Check Outbound Email Routing: If you host business email externally, confirm your MX, SPF, and DKIM records remain intact, or review our Google Workspace and Microsoft 365 DNS routing guide.

Keep your old hosting account online and untouched for at least 72 hours after cutover. That safety buffer guarantees any straggling DNS resolver with a sticky cache still resolves cleanly, and gives you an instant fallback target if an unexpected edge case surfaces. Once traffic logs on the old host drop to zero, raise your DNS TTL back to 3600 seconds and decommission the legacy server.

Frequently Asked Questions

How long does a zero-downtime website migration take? ▼

Preparation starts 48 hours ahead when you lower DNS TTL to 300 seconds, but the active cutover window—running the final delta rsync, importing the final database snapshot, and switching DNS—typically takes less than 2 to 5 minutes.

Why use rsync instead of cPanel full account backup restore? ▼

Full cPanel backups work well when moving between two cPanel servers with root access, but they cannot run incrementally. With rsync, you can pre-seed 99% of your files days ahead and sync only changed deltas at cutover, even across different control panels or VPS setups.

How do I prevent losing WooCommerce orders during migration? ▼

Enable a brief 60-second maintenance banner on the source site right before running the final mysqldump --single-transaction export and DNS switch. Once the new server receives the import and DNS flips, disable maintenance mode on the new host.

How can I preview my migrated website before changing DNS? ▼

Add an entry mapping your domain to the new server’s IP address inside your computer’s /etc/hosts file (or C:\Windows\System32\drivers\etc\hosts on Windows) and flush your local DNS cache. Only your machine will route to the new server.

What happens to my SSL certificate during a Linux hosting migration? ▼

You should pre-install an SSL certificate on the destination server before switching DNS using DNS-01 Let’s Encrypt validation, a commercial certificate, or Cloudflare Origin SSL so visitors never encounter browser security warnings during propagation.

How do I migrate business email accounts without losing messages during DNS propagation? ▼

Pre-create all mailboxes on the new server and run an initial imapsync pass before cutover. After switching MX/A records, run a final incremental imapsync against the old server’s IP address to pull any messages that arrived during propagation.

Execute Zero-Downtime Website Migrations With SSH rsync and Low TTL

Pre-seeding files over SSH, testing via /etc/hosts, and running a final delta sync avoids split-brain orders during launch. Move your site onto modern NVMe Linux infrastructure without downtime.

Migrate websites cleanly to Linux web hosting