Lesson 12 of 13 · 18m
The Restore Runbook
Dependencies first, PITR to the minute before the damage, a verification gate, then traffic — DNS TTL lowered long before the fire.
A restore is a dependency graph executed by a tired human under paging pressure. The runbook exists because the ordering is not obvious at 3 AM and the mistakes are expensive — restoring the app before its database, flipping DNS before verification, or the classic: restoring data back onto the compromised host the attacker is still sitting in.
The ordering constraint
Dependencies first, always. Identity and secrets before data (you need credentials, TLS keys, and repo passwords to restore anything), data before app (the app is useless and may actively corrupt state without its database), app before traffic (verify before you invite the world back).
Concretely, a Postgres-centric restore:
- Provision clean. If compromise is suspected: rebuild the host from a known-good image and rotate credentials first. Restoring into the blast radius just hands the data back to whoever took it. If it's hardware failure, provision normally.
- Restore the database. pgBackRest
restore, or PITR from base backup + WAL: PostgreSQL 12+ writes arecovery.signalfile and setsrecovery_target_time— point it at the minute before the damage ('2026-11-16 14:31:59', not after), withrecovery_target_action = promote(orpauseto inspect before committing). Targets can also be a named point (pg_create_restore_pointbeforehand), a transaction id (recovery_target_xid), or an LSN, withrecovery_target_inclusivecovering the edge where the bad transaction's own commit is the boundary.recovery_target_action = pausepluspg_wal_replay_pause()/pg_wal_replay_resume()lets you inspect tables mid-replay and step toward the damage instead of guessing the exact second once. - Restore the file layer.
restic restore <snapshot-id> --target / --include /srv/uploadsfor partial work;restic mountfor browse-and-grab. Single table from a custom-format dump:pg_restore -t orders -d dbname dump.pgc. - Verify before traffic. Row counts against expected ranges, the app's own health checks,
restic check, a human poking the critical paths. This is a gate, not a step — the runbook says what verifies it. - Flip traffic. DNS is last, and TTL is the trap: lowering a 24-hour TTL during the incident does nothing for records already cached in resolvers worldwide. Lower TTLs before the disaster, as standing policy on records DR will touch. If a CDN or load balancer fronts you, the flip happens there instead — same verification-first rule. And keep the failover inside the existing hosted zone: changing DNS providers mid-incident propagates on registrar delegation TTLs measured in days, not the record TTL you lowered.
Partial restores are a skill
Most real restores are surgical: one dropped table, one nuked bucket path, yesterday's config before the bad deploy. Know the incisions per tool: pg_restore -t, --include/--exclude on restic restore, mysqldump on the restored scratch DB then export the one table, pg_basebackup+PITR to a throwaway instance for forensic row mining without touching production.
Two mechanical details worth having written down before the night you need them. recovery_target_timeline = 'latest' tells Postgres to follow the newest timeline when the archive has already branched from a previous PITR — omitting it can replay into a dead branch. And recovery.signal means "recover then serve"; standby.signal means "keep following a primary" — write the wrong one and your restore comes up as a replica chasing a dead master.
The wrong model
"Restore = untar everything and see." The untar version has no ordering, no verification gate, no damage-point logic — and replays the corruption you were trying to escape. PITR to after the DROP TABLE faithfully replays the DROP TABLE.
The practice
One page: the ordered steps, the literal commands, the verification gate's contents, the comms step (status page, who posts it — and the status page lives outside the failure domain, on a hosted service or second provider, not on the infrastructure currently on fire), and the decision points (restore point selection, restore-vs-rebuild). Literal commands means copy-pasteable — restic -r s3:s3.amazonaws.com/bucket/repo snapshots, the actual repo URL, the actual target paths — because at 3 AM nobody should be reconstructing flags from memory. Rehearsed quarterly — the drill is where you learn that step 2 needs the repo password that lives in a password manager whose master key is on the dead laptop. Write the page, time the steps, fix what the drill breaks.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Self-Hosting Prometheus and Grafana: Infrastructure Monitoring That Actually Works
Build a production-grade monitoring stack with Prometheus and Grafana from scratch. Covers architecture, Docker Compose deployment, Node Exporter, alerting with Alertmanager, PromQL from basics to advanced, pre-built dashboards, and everything SudoSecurity uses to monitor its own infrastructure.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.
Running a Minecraft Network: Four JVMs, One Box, and the Settings That Lie to You
Four servers on one host means four JVMs each sizing its thread pools for a machine it does not own. The measured cost of that, the systemd ordering that guarantees nothing, and the throttle that switches itself back on when your forwarding breaks.
Building a Minecraft Network: Four Servers Pretending to Be One Place
A proxy, a lobby, an SMP and a PvP arena is four JVMs that know nothing about each other. What actually has to be shared, why your permissions don't follow players, and the two LuckPerms defaults that silently share nothing at all.