| |

Zero-Downtime Dedicated & Cloud Server Migration Playbook (Rsync, Replication & Cutover)

Zero-Downtime Server Migration Playbook & Cutover Guide technical architecture diagram
Verified Technical Answer

A zero-downtime server migration decouples bulk data transfer from the final traffic switchover through a four-phase pipeline: lowering authoritative DNS TTLs to 60 seconds 48 hours ahead, performing an initial live baseline rsync and database snapshot restore while production remains online, establishing continuous asynchronous database replication (MySQL binlog or PostgreSQL WAL streaming) to catch live writes, and executing an atomic cutover by proxying or locking writes for seconds during the final delta rsync and DNS/reverse-proxy pointer flip.

Moving a live production workload between bare-metal providers, upgrading legacy SATA servers to NVMe clusters, or escaping cloud egress bottlenecks does not require an overnight maintenance blackout. Naive tar-and-SCP transfers force prolonged read-only freezes, leave stale DNS caches hitting retired IPs, and risk silent file-permission or database character-set drift. Engineering a phased replication and cutover playbook shrinks the visible switchover window to seconds—or true zero downtime when fronted by a proxy.

Two-Pass Delta Sync

Transfer 99.9% of static assets live over SSH/rsync first so the final cutover delta finishes in seconds.

Continuous DB Streaming

Keep MySQL/MariaDB or PostgreSQL replicas synchronized within milliseconds of primary writes until cutover.

60-Second DNS & Proxy Flip

Lower TTLs 48 hours early and proxy lingering cached DNS clients from old IP to new host cleanly.

1. Pre-Migration Dependency Audit & DNS TTL Preparation

Every failed migration stems from an unmapped dependency discovered mid-cutover: hardcoded IP addresses in environment files, outbound webhook IP allowlists, missing TLS private keys, cron jobs writing to local temp paths, or stale DNS records cached for 24 hours. Before copying a single byte, capture an inventory of listening sockets (ss -tulpn), active systemd units, installed runtime versions (PHP, Node, Python, OpenSSL), SSL certificates, and external API firewall whitelists.

Why DNS TTL Reduction Must Happen 48 Hours Before Cutover

Authoritative DNS records commonly ship with 3600-second (1 hour) or 86400-second (24 hour) TTLs. Lower A, AAAA, MX, and CNAME TTLs to 60 seconds at least two full prior-TTL cycles before migration day so recursive resolvers worldwide expire old entries promptly. Simultaneously, benchmark disk throughput on the target server—understanding NVMe vs. SATA SSD dedicated server storage latency ensures the destination storage subsystem can absorb both live replication I/O and incoming cutover reads without queue saturation. Before copying live datasets, ensure you also capture an immutable pre-migration snapshot via your automated offsite backup workflow.

  • Verify backup restore point: Confirm an immutable offsite snapshot exists and passes checksum verification before starting replication.
  • Pre-issue TLS certificates: Provision Let’s Encrypt or wildcard certificates on the target node using DNS-01 validation so HTTPS works before DNS A-records point there.
  • Align UID/GID mappings: Match service user IDs (www-data, mysql, postgres) across source and target hosts before rsync preserves numeric ownership.

2. Two-Pass Rsync File Synchronization & Checksum Validation

Using rsync cleanly separates bulk transfer time from application downtime. In Pass 1, transfer gigabytes or terabytes of uploads, media libraries, and application trees while the source server continues serving requests normally. Throttle network or disk I/O with --bwlimit or ionice -c 3 if Pass 1 runs during peak business hours so production latency never spikes. Consult the official Samba rsync documentation for exact flag semantics when preserving extended attributes (-X), POSIX ACLs (-A), hardlinks (-H), and sparse files (-S).

Avoiding Metadata Corruption and Phantom Deletions

Never enable --delete during Pass 1 against a target directory until you have dry-run the path with --dry-run --itemize-changes—a missing trailing slash can wipe destination files instantly. During the final freeze window (Pass 2), run rsync with --delete and --checksum on critical config directories so files modified within the same second still synchronize accurately.

# Pass 1 (Live Bulk Sync): preserve permissions, ACLs, xattrs, hardlinks, numeric IDs
ionice -c 3 nice -n 19 rsync -aHAX --numeric-ids --info=progress2 \
  --exclude='/var/www/app/storage/logs/*' \
  --exclude='/var/www/app/cache/*' \
  -e 'ssh -i /root/.ssh/migrate_ed25519 -T -c [email protected] -o Compression=no' \
  /var/www/app/ [email protected]:/var/www/app/

# Pass 2 (Final Cutover Delta after source writes paused): fast delta + exact delete
rsync -aHAX --numeric-ids --delete --checksum \
  -e 'ssh -i /root/.ssh/migrate_ed25519 -T -c [email protected] -o Compression=no' \
  /var/www/app/ [email protected]:/var/www/app/

3. Live Database Replication (MySQL Binlog & PostgreSQL Streaming)

Copying a multi-hundred-gigabyte SQL dump during a maintenance window destroys zero-downtime goals because single-threaded import and secondary index rebuilds take hours. Instead, bootstrap the target database as a live read-only replica connected to the source primary over an encrypted SSH tunnel or WireGuard link. Ensure the destination node’s InnoDB buffer pool or PostgreSQL shared_buffers are properly sized beforehand using our high-memory database dedicated server tuning guide.

MySQL/MariaDB & PostgreSQL Logical/Physical Cutover Flow

For MySQL/InnoDB, capture a consistent online backup with mysqldump --single-transaction --master-data=2 (or physical hot backup via Percona XtraBackup/Mariabackup), restore it to the target server, configure CHANGE REPLICATION SOURCE TO at the exact binlog coordinates, and let replication catch up to zero seconds lag. For PostgreSQL, use pg_basebackup -R for major-version parity or logical replication slots for zero-downtime major upgrades across versions.

Rollback & Safety Precaution: Never allow both source and target databases to accept simultaneous non-replicated writes without active-active conflict resolution—split-brain writes cause irreversible primary-key collisions. Keep the target database strictly read_only=ON (super_read_only=ON) until the source is switched read-only, replication lag reads zero, and you are ready to promote the target. If post-cutover validation fails within minutes, leave the source intact and point traffic back before discarding old state.

4. Comparing Server Migration Patterns & Downtime Profiles

Choose the migration pattern that aligns with your dataset size, database write rate, and tolerance for brief read-only windows.

Migration Strategy Write Freeze Window Best Workload Profile Rollback Speed Complexity
Cold Backup + Restore 30 min – 6+ hours Dev/staging or scheduled overnight maintenance Instant (old host untouched) Low
Two-Pass Rsync + Dump 5 – 20 minutes Small databases (<10 GB) + large static media Fast (<5 minutes) Low-Medium
Live DB Replica + Rsync + Proxy 0 – 15 seconds High-traffic e-commerce, SaaS, APIs (>50 GB DB) Controlled (reverse sync optional) Medium-High
Load Balancer Blue-Green Drain 0 seconds Stateless microservices + external managed DB Instant (shift LB weight back) Medium

5. Atomic Cutover Sequence, Reverse-Proxy Bridging & Smoke Tests

Even with a 60-second DNS TTL, stubborn enterprise resolvers and mobile clients often cache the old IP address for hours. Eliminating split-brain traffic requires turning the retiring server into a transparent Layer-4/Layer-7 reverse proxy immediately upon cutover so every lingering request landing on the old IP forwards seamlessly to the promoted target node.

# Cutover sequence executed via automated runbook:
# 1. Place source app in brief read-only / maintenance gate & stop cron writers
# 2. Confirm target DB caught up: SHOW REPLICA STATUS\G -> Seconds_Behind_Source: 0
# 3. Promote target DB: STOP REPLICA; RESET REPLICA ALL; SET GLOBAL read_only=OFF;
# 4. Run final rsync Pass 2 + update DNS A/AAAA records to new server IP
# 5. On old server, replace app vhost with proxy_pass to new server over private VPN:
server {
    listen 443 ssl;
    server_name app.example.com;
    location / {
        proxy_pass https://10.66.0.2;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
  1. Pre-DNS hosts-file validation: Map the domain to the new server IP in your local /etc/hosts or run curl --resolve example.com:443:NEW_IP to verify HTTP 200 responses, checkout flows, and TLS chains before flipping DNS.
  2. Monitor error rates & proxy logs: Tail Nginx/HAProxy access logs on the old server for 48 hours; decommission only after legacy IP hit rate drops to zero.
  3. Update reverse DNS (PTR) & SPF: Register PTR records for the new IP immediately if the server sends transactional email.

Frequently Asked Questions

How do I prevent users from hitting the old server after updating DNS records?

Reduce DNS TTLs to 60 seconds 48 hours ahead of cutover, and immediately configure Nginx or HAProxy on the old server to forward all HTTP/HTTPS requests to the new server’s IP over a private tunnel until old-node access logs go quiet.

Why does rsync run faster with [email protected] and Compression=no?

Modern CPUs accelerate AES-GCM in hardware at tens of gigabits per second, whereas single-threaded SSH zlib compression (-z) bottlenecks fast 1Gbps/10Gbps links on CPU. Disabling SSH compression on already-compressed media and binaries drastically increases transfer speed.

Can I migrate between different Linux distributions (e.g., CentOS 7 to AlmaLinux 9) with rsync?

Yes, but only rsync application data, web roots, user home directories, and selected /etc service configurations—never overwrite /bin, /usr, /lib, or /etc/passwd wholesale across different OS major releases.

What if database replication breaks right before the scheduled cutover?

Pause the cutover while production continues uninterrupted on the source server. Inspect SHOW REPLICA STATUS or PostgreSQL logs to fix missing binlogs or constraint drift, re-seed the replica cleanly, and reschedule without impacting live users.

How do I verify all migrated files match the source server identically?

Run rsync in dry-run checksum mode (rsync -rcn –delete /src/ root@target:/dst/) after syncing. Any file differing in content checksum or missing at the destination prints cleanly without modifying data.

How long should I keep the old server online after a successful migration?

Keep the retiring server powered on in proxy/standby mode for at least 48 to 72 hours (or through one full business billing cycle) so residual DNS caches drain and an emergency fallback snapshot remains immediately accessible.

Migrate to High-Speed NVMe Dedicated Hardware

Upgrade aging workloads to dedicated bare-metal servers with 1Gbps/10Gbps uplinks, private migration VLANs, and root access for zero-downtime cutovers.

View Dedicated Server Plans

NR
Naveen Rajput — Infrastructure & Cloud Systems Architect

Reviewed by Onlive Server Infrastructure Engineering for technical accuracy, kernel/network safety, and global bare-metal operations.