Backups, Point-in-Time Recovery, and Restore Drills
A PostgreSQL backup is useful only if it can restore the required data within the declared recovery point and recovery time. Logical dumps reconstruct selected objects; physical base backups plus archived WAL enable cluster recovery and point-in-time recovery. Retention, encryption, access, version compatibility, dependencies, and isolated restore drills complete the system.
What will you be able to do?
- Translate RPO/RTO into backup and WAL requirements.
- Compare pg_dump/pg_restore with physical backup and PITR.
- Design encrypted, immutable, monitored retention.
- Run a restore drill with application-level validation.
Prerequisites and mental model
RPO asks how much committed data loss is acceptable; RTO asks how long service restoration may take. A backup file, a replica, and WAL archive are different capabilities.
Which backup serves which need?
- pg_dump creates a logical, transactionally consistent export of one database and is useful for selective restore/migration; it is not continuous PITR.
- Physical backups copy cluster files in a supported way and pair with WAL for recovery.
- WAL archiving preserves the change stream needed to replay from a base backup to a target.
- Managed services expose provider-specific snapshots/PITR with limits that must be tested.
Safe logical learning example:
Restore into a newly created isolated database, never over the source during practice. Use current-version tools and official compatibility guidance.
What proves recovery?
Record:
- backup identity, checksum, encryption, location, and retention;
- restore start/end and exact target;
- database/version/extension prerequisites;
- row-count and invariant checks;
- roles/grants/RLS/function verification;
- application smoke and tenant-negative tests;
- RPO reached and RTO measured;
- issues and runbook changes.
Why does this matter in AI-native systems?
Restore canonical documents, access policy, evaluation cases, approvals, and audit history first. Embeddings may be rebuilt, but only when source/version/model lineage exists and rebuild time fits RTO. External object storage and model-provider state need coordinated recovery plans.
Prove it worked
Dump signaldesk_learning, restore into signaldesk_restore_drill, run invariant/role/RLS checks, compare selected counts/checksums, and then remove only the explicitly named drill database when finished. Record elapsed time.
Production judgment
- Test expired credentials, missing extensions, and unavailable key scenarios.
- Keep copies outside the primary failure/credential domain and use immutability where justified.
- Backup monitoring must detect silent gaps and WAL archive failure.
- Logical dumps can be slow/large and do not capture cluster-wide configuration/roles automatically in the same way.
Common mistakes
- Backup job green, restore fails: no drill → schedule isolated restores.
- PITR gap: WAL archive missing → monitor continuity and restore test.
- RAG restored without sources: embeddings treated as truth → preserve source and lineage.
AI Pair-Programmer Prompt
Hands-on exercise
Perform the isolated logical restore drill and write a one-page evidence report.
Acceptance criterion: restored SignalDesk passes schema, count, constraint, role, tenant-negative, and application-query checks within measured time.
Knowledge check
- What enables PITR?
- Is a replica a backup?
- What makes embeddings safely rebuildable after restore?
Answers
- A suitable physical/base backup plus continuous required WAL and recovery configuration.
- No; it shares/replays many failures and lacks independent history.
- Restored canonical sources, versions, pipeline/model identity, and rebuild procedure/capacity.
Completion checklist
Primary references