NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle1 view

A 1 TB PostgreSQL database with hot data that must not be lost is running in the cluster. A pg_dump is created once a day. What’s wrong with this, and how can it be improved?

Practice

AI answer

A daily pg_dump implies a potential loss of up to a day’s worth of data (RPO of about 24 hours), while restoring 1 TB can take a very long time (high RTO). A single logical dump can also impose a significant load, and the time and reliability of restoration need to be tested.

First, determine the acceptable RPO and RTO. Point-in-time recovery is usually implemented with regular physical base backups and continuous WAL archiving, for example with pgBackRest or Barman. This allows you to restore a base backup and apply WAL up to the desired point in time. For fast failover, you can add a replica; synchronous replication reduces the risk of losing acknowledged transactions, but by itself does not replace backups and does not protect against deletions or logical corruption that gets replicated.

Backups should be stored separately from the cluster, encrypted, and monitored for successful completion and retention period. Most importantly, regularly test restores in a separate environment and measure the actual RPO/RTO. pg_dump can still be used for logical or selective restores, but not as the sole strategy for a database of this size.