4 Hours

18. Disaster Recovery: Backups & PITR

Ops

Preparing for the Worst

Data is the lifeblood of a company. Senior Engineers don't just take backups' — they design Recovery Strategies. This module covers how to protect against hardware failure, human error (accidental DELETE), and site-wide disasters.

Logical vs Physical Backups

  • Logical (pg_dump): Exports data into a SQL script. Best for small databases or moving data between versions.
  • Physical (pg_basebackup): Copies the raw database files. Best for large production systems. Fast to restore.

WAL Archiving: The Time Machine

Postgres allows you to archive your Write-Ahead Logs (WAL). By combining a weekly base backup with your archived logs, you can perform PITR (Point-in-Time Recovery).

The PITR Magic

If a developer accidentally runs DELETE FROM users at 2:05 PM, you can restore your backup and replay the logs until 2:04 PM. You lose only 1 minute of data instead of 24 hours.

Knowledge Check

Ready to test your understanding of 18. Disaster Recovery: Backups & PITR?

Back