23 Incident recovery, disaster recovery and migration
Confirm the symptom using a user-facing observation and timestamp. Identify the target and recent changes. Select one incident coordinator and name who can authorize consequential recovery actions.
Type: recovery procedure and decision guide. Prerequisites: service inventory, authorized access, tested release identity, backups and recovery objectives. Outcome: restore the intended user outcome while preserving evidence and avoiding unintended replay. Environment: local owned lab for executable demonstrations; a separate approved destination for offsite/host/region recovery. Evidence: incident timeline, recovered records, measured loss interval, recovery duration and unresolved effects.
Stabilize before diagnosing everything
Confirm the symptom using a user-facing observation and timestamp. Identify the target and recent changes. Select one incident coordinator and name who can authorize consequential recovery actions. Preserve relevant logs and records before changing state. If credentials may be compromised, containment and evidence preservation may need different actors from routine availability repair.
Choose a mitigation that contains impact: remove a bad candidate from traffic, stop a damaging writer, reduce optional workload or restore a known compatible release. Avoid several unrelated changes at once. A restart may restore service temporarily, but it does not establish why the fault occurred or whether data is correct afterward.
Use runbooks/incident.md to keep decisions visible. State what is known, what is inferred and what remains unknown. Update people at an agreed cadence. Do not claim “no data loss” until the records and effect history support it. An API timeout means the client did not receive a timely result; it does not prove the upstream operation was never performed.
Choose the correct recovery unit
If code is broken and data is sound, compatible artifact rollback may be enough. If one record is corrupted, a reviewed selective repair may have less impact than restoring an entire database. If storage is lost, restoration needs a separate data destination and the keys/configuration required to use it. If a region or identity system is unavailable, those dependencies must be represented in the recovery plan.
A snapshot, logical dump, replicated standby and archival backup protect different failure modes. Replication may rapidly copy an accidental deletion; a same-host backup may disappear with that host; an encrypted artifact is useless if its only decryption identity is lost. Inventory both data and recovery dependencies, then choose independent copies according to the actual failure requirement.
The native PostgreSQL drill performs a real process restart and encrypted logical restore to another local cluster. The local lifecycle lab tests owned service backup/restore and migration under its stated contract. Those are useful executed cases. They do not establish recovery after losing the Mac, offsite account or region. Keep these proof scopes separate in the phase records.
Measure RPO and RTO honestly
Record the newest committed event known to be recoverable and compare it to the incident/cutoff point. That gives an observed loss interval for the test. If a backup captures all fixture events written before the dump, state that exact boundary. Do not extrapolate it to continuous recovery when no continuous archive exists.
Start the recovery clock at the agreed event, such as incident declaration, and stop only when the defined workflow is verified and accepted. Retain sub-times: locating backup, obtaining keys, provisioning replacement, restoring, validating and routing traffic. A fast restore command on a tiny fixture is narrower than full operational recovery time.
For PostgreSQL point-in-time recovery, a logical pg_dump is not a base backup for WAL replay. A PITR design needs the appropriate physical base backup and a continuous required WAL sequence, protected retention and an exercised target-time recovery. Consult the version-matched [PostgreSQL continuous-archiving documentation](https://www.postgresql.org/docs/current/continuous-archiving.html). The logical dump drill does not claim to implement that design.
Restore into an isolated destination first
Choose a new destination with confirmed ownership and sufficient capacity. Retrieve the reviewed backup and decryption identity through independent access. Verify artifact integrity and provenance as your recovery process requires. Restore schema/data and recreate necessary roles, extensions, configuration and permissions. Keep outbound effects disabled until duplicate/replay decisions are made.
Validation must go beyond row counts. Compare representative records, constraints, expected schema revision, accepted job identities, authorization behavior and a new synthetic workflow. Validate recovery credentials and administrative access. Check that the restored service is actually using the new destination, not accidentally querying the original database through an old environment variable.
For a failed decrypt or integrity check, stop using that artifact. Determine whether the wrong key, wrong file, damaged transport or malicious alteration is involved. Try another approved recovery copy according to policy; do not strip encryption or ignore the failed verification to make the runbook continue. Preserve the failed artifact where appropriate for investigation.
Migration is a controlled change of authority
A migration replaces a host, platform, database, region or service implementation. Define source and destination owners, data transfer strategy, write cutoff, consistency requirements, DNS/traffic cutover, validation and rollback decision window. Identify which side is authoritative at every step. Two independently writable systems without a reconciliation design can create divergence that neither rollback nor simple resync safely resolves.
For a simple maintenance migration, pause ingestion, drain accepted work, take the chosen consistent transfer, restore to the destination, validate it, switch clients, and reopen writes. Retain the source read-only for an agreed window. This trades downtime for simpler correctness. A low-downtime migration requires tested replication/change-capture, lag monitoring, cutover fencing and explicit handling of divergent effects.
TLS, DNS, service discovery, allowlists, schedules and monitoring must move with the service. Inventory cached endpoints and scheduled clients. A DNS change alone does not instantly move every client: caches, existing connections and previous TTLs matter. Verify traffic and writes arriving at the destination before declaring the old source inactive.
Reconcile external effects and close the incident
For jobs that may have called an external provider, use the provider's request/event identity and supported reconciliation procedure. Idempotency in your database does not automatically provide exactly-once effects in another system. If a restored database predates an already-sent action, replay can duplicate it. Keep writes disabled until the decision is recorded for consequential operations.
After recovery, verify the original symptom and a fresh synthetic workflow. Confirm alert resolution and retained evidence. Communicate confirmed impact, mitigation, loss and uncertainty. Write a blameless review that explains contributing conditions and assigns owners to preventive work. Add a regression scenario where possible and retest it; the incident is a learning opportunity only if the improvement is made concrete.
Cleanup: retire temporary recovery environments only after acceptance, retention and key-handling decisions. Preserve the original source through the agreed rollback window. Pass: another operator can restore to a separate destination, prove data and permission behavior, explain the actual loss/time bounds, and reconcile external effects before resuming consequential work.