Lesson 14 of 14 · 20m
Migration Day: The Restore Drill With Traffic
TTL prep, provision-from-config, hot-then-cold rsync, and keeping the old box alive a week — the audit of every other lesson.
Every claim your setup makes — backups that restore, config as code, DNS understood — gets audited on the day you move providers. A migration is a restore drill that also has to keep serving live traffic. Done right it's a checklist; done wrong it's the day you learn your dumps were empty and your TTL is a week.
The order that works
Days before: lower the A/AAAA TTL to ~300 seconds and let the old records age out of caches — "propagation" is just resolvers honoring old TTLs, so you shrink them ahead of time. Then audit where the old IP is pinned: firewall allowlists, the PTR record if the box sends mail, Healthchecks ping targets, hardcoded addresses in configs. Every place the IP lives is a place that breaks.
Provision from config, not from memory: build the new box from your repo — blueprint/compose files, nginx configs, env templates. This is the honest test of infrastructure-as-code: if the new box can't be built from the repo alone, the repo was never the source of truth and you just found out.
Two-phase data sync: a hot pass while the old box serves — rsync -aHAX for volumes, uploads, and anything file-backed — then a freeze: maintenance mode on the app (writes stop; reads can keep serving), a final rsync --delete delta that copies only what changed during the hot pass, pg_dump → pg_restore on the new DB.
Flip and watch both: update the A/AAAA records, then watch access logs on both boxes — TTL means the world lands on both for the next few minutes, and the old box's traffic draining to zero is your confirmation the cutover took. dig from a resolver outside your network is the external truth.
Keep the old box alive ~a week. Untouched, still running — it's the rollback path. Destroy it only after the new box has survived real traffic, a cert renewal cycle, and one nightly backup.
The wrong model: copy once, flip DNS
The naive plan — one big rsync, point DNS at the new box, done — fails twice. First, a live filesystem changes under you: the files copied at the start are already stale by the end, and the DB is mid-write the entire time; that's why the freeze-and-delta pass exists. Second, "flipping DNS" isn't a switch — cached lookups keep sending users to the old box for its TTL duration, so naive plans put stale service on half the internet for hours.
The other landmines are absolute paths and pinned IPs: bind mounts pointing at /opt/app that exists on the old box but not the new, an nginx upstream hardcoded to the old IP, a backup cron still targeting the old host. grep -r the repo for the old IP and old paths before you flip anything.
Why this is the capstone
Everything previous lessons claimed is now load-bearing: your SSH config and keys let you reach both boxes; the firewall rules document what's supposed to be reachable; DNS TTL discipline makes the flip fast instead of gradual; the compose files rebuild the stack; the backup pipeline produced the dumps you're restoring. If any of it was theoretical, this is where the theory meets the invoice.
Field notes
- New IP means new mail reputation if the box sends — check it against RBLs on day one, and move the PTR record when you move the A record.
- Certbot issues fresh certs on the new box fine — same domain, same CA; the challenge path just has to work on the new nginx.
- Decommission checklist: cancel/snapshot the old box, remove its DNS records, pull it out of healthchecks and backup crons, revoke its SSH keys and provider tokens. A dead box you still half-run is an attack surface that doesn't patch itself.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Self-Hosting Vaultwarden Without Trusting the Defaults
Vaultwarden gives you a Bitwarden-compatible password server in one container and about ten minutes. The defaults that make that possible leave org creation open, audit logging off, accounts on PBKDF2, and a rate limiter that trusts a header anyone can set.
What You Can Self-Host on Oracle Cloud Free Tier (2026)
What actually fits on Oracle Cloud free tier after the June 2026 cut: Ghost, Vaultwarden, Syncthing, monitoring, and a small AI model, sized in real RAM.
The Complete Self-Hosted AI Stack for 2026
Building a local AI server is more than installing Ollama. This guide builds a full production AI stack with Open WebUI, LiteLLM, Qdrant, Traefik, and Langfuse — what each component does, why it's needed, and three complete Docker Compose configurations for beginners, power users, and small teams.
Self-Host OpenClaw: VPS Setup to Production (2026)
Self-host OpenClaw from zero to production. Server provisioning, SSH lockdown, Docker, reverse proxy, Fail2ban, performance tuning, and full backup strategy in one guide.