Backups prove disaster recovery. Logical backups (pg_dump) are portable; physical backups (base backups + WAL archiving) suit large databases and point-in-time recovery.
pg_dump basics
# Shell — custom format supports parallel restore
pg_dump -Fc -d practice -f practice.dump
pg_restore -d practice_restored practice.dumpPractice: Use local or staging environments only for backup/restore and pooling experiments.
SQL plain dump
pg_dump -d practice --schema-only -f schema.sql
pg_dump -d practice --data-only -t customers -f customers.sql
Restore drill checklist
- Restore to isolated instance monthly
- Verify row counts and critical queries
- Document RTO/RPO with stakeholders
- Combine with managed automated snapshots in production
Important interview questions and answers
- Q: pg_dump -Fc?
A: Custom compressed archive—parallel pg_restore. - Q: PITR?
A: Point-in-time recovery needs WAL archiving plus base backup—not just a single plain SQL file.
Self-check
- Which tool creates a logical backup?
- Why test restores, not just backups?
Tip: A backup file you never restored is hope, not insurance.
Interview prep
- pg_dump?
Logical backup tool producing portable dump files.
- Restore drill?
Proves backups work—file existence is not enough.