Full answer
Elements of a sound setup:
- Physical base backups (for PostgreSQL,
pg_basebackupor a tool such as pgBackRest) plus WAL archiving, enabling recovery to any moment, for example one minute before an accidentalDELETE. - Logical dumps (
pg_dump) for moving single databases or tables between versions; slower to restore at scale. - Off-site and separate credentials: a compromised production account should not be able to delete backups.
- Retention matching business needs, such as daily for 30 days and monthly for a year.
- Restore drills: automated restores into a scratch server, with row counts or checksums checked, and the time taken recorded against the recovery time objective.
- Monitoring: alerts when a backup or WAL archive fails.
Replicas are not backups: a destructive statement replicates within seconds. For SQLite, the online backup API or VACUUM INTO produces consistent copies while the database is in use.
Key points
- Full backups plus WAL archiving enable point-in-time recovery
- Store backups off-site with separate credentials
- Test restores regularly
- Replicas are not backups
- Monitor backup jobs
Common mistakes
- Never testing restores
- Treating a replica as a backup
Follow-ups
- What are RPO and RTO?
- How would you recover a single dropped table?
Tips
- Stress restore testing