Full answer
Building blocks:
- Base backups: full physical copies (pg_basebackup, or pgBackRest full and incremental backups; PostgreSQL 17 adds native incremental backups with pg_combinebackup), taken daily or weekly.
- WAL archiving: archive_command or archive_library ships every completed WAL segment to durable storage in another location; archive lag is monitored.
- Retention: keep base backups and all WAL since the oldest one you may restore from, here at least 14 days plus one full backup cycle.
- Recovery: restore the nearest base backup before the target, set recovery_target_time, and replay WAL; the server stops at the target and can be promoted.
Targets to agree on: RPO (how much data may be lost, driven by archive frequency or synchronous replicas) and RTO (how long a restore may take, driven by database size, backup format and WAL volume).
Practices that matter more than the tool: automated restore tests into a scratch environment with checks that the data is sane, encryption and access control for the backup bucket, alerts on failed archiving, and a written runbook. Replicas are not backups, because an accidental DELETE replicates immediately; delayed replicas (recovery_min_apply_delay) can help for quick recovery from such mistakes.
This item describes infrastructure and has nothing to run in a single schema.
Key points
- PITR needs base backups plus WAL archiving
- Restore to recovery_target_time
- Define RPO and RTO
- Test restores regularly
- Replicas are not backups
Common mistakes
- Relying only on nightly pg_dump
- Never testing a restore
Follow-ups
- How do you recover a single dropped table quickly?
- What does PostgreSQL 17's incremental backup change?
Tips
- State RPO and RTO