Backups, PITR & Restore Drills in SQL
Untested backups are Schrödinger backups
Logical dumps (pg_dump) for portability and small DBs; physical base backups + WAL archiving for point-in-time recovery on large systems. RPO/RTO targets pick strategy: dumps for simplicity, PITR for tight windows. Restore drills (not backup logs) prove recoverability — rehearsed restores to staging on cadence.
Dumps for portable
pg_dump custom format — small DBs, migrations, per-table restores.
Base + WAL for PITR
Physical base + streaming WAL — any-moment replay for large systems.
Write RPO/RTO
Loss tolerance + speed target per dataset — strategy follows numbers.
Drill restores
Monthly staging restores, timed + documented. Keys backed separately.
1-- logical:2pg_dump -Fc app > app.dump3-- PITR target:4-- restore base + replay WAL to '2024-06-01 14:30'
| strategy | fit |
|---|---|
| dumps | portable, small-scale |
| PITR | base + WAL, any moment |
Dump restores whole snapshots simply. PITR replays the log to just before the accident — the only answer for mid-day drops on large tables.
Pick by numbers
Targets choose tooling, not habit.
1-- RPO 24h + RTO hours → nightly pg_dump2-- RPO minutes → base + WAL streaming + PITR
| strategy | window |
|---|---|
| dumps | simple, coarse |
| PITR | tight RPO/RTO |
Mid-day DROP rescue
Replay to just before the accident.
1-- restore base + replay WAL to '2024-06-01 14:29'
| target | point |
|---|---|
| PITR target | one minute before DROP |
Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Take the queries you just visualized and see the data structures that power real databases.