PostgreSQL high availability keeps service running through selected failures. Backups preserve recoverable data. Disaster recovery restores an acceptable service after a wider failure. A production database often needs all three. A healthy replica does not prove that the team can recover from a destructive change or the loss of its operating environment.
Choose the design by failure scenario and recovery objective. Then test the application against restored data, rather than treating a successful backup job as the acceptance criterion.
Agree RPO and RTO for each failure
Recovery Point Objective, or RPO, describes the acceptable data-loss window. Recovery Time Objective, or RTO, describes the target time to restore service. They are business objectives, not properties supplied automatically by a database topology. AWS's recovery objectives guidance explains the distinction.
Ask the product owner what must work after recovery. Can users sign in, see recent orders and create new ones? Are payment and fulfilment states consistent? Include those checks in the recovery definition.
Separate objectives for a failed database host, an unavailable region and accidental deletion. The cost and recovery method may differ. Record who can accept a longer outage or a known data gap when the preferred route is unavailable.
Match protection to the failure
This decision table is a planning aid. Confirm each result against the actual deployment and permissions.
| Failure scenario | Protection to evaluate | Evidence needed |
|---|---|---|
| Primary host stops | Standby and controlled failover | Promotion, single-writer enforcement and application reconnection test |
| Faulty deployment deletes data | Earlier recovery point and reconciliation | Successful restoration before the destructive transaction |
| Main operating environment is unavailable | Independent recovery location and dependencies | Access, capacity, keys and application startup without the lost environment |
| Production credentials are compromised | Separately protected recovery copies | Proof that production access cannot destroy every usable copy |
| Backup job reports success | Restore and application validation | Recoverable chain, correct data and measured recovery duration |
A replica can reproduce an unwanted transaction faithfully. That makes replication valuable for availability while leaving a separate requirement for historical recovery points. Draw the common failure boundaries: storage, credentials, region, account and operators. Two servers inside the same boundary may still fail together.
Understand what replication commits to
PostgreSQL streaming replication is asynchronous by default. A standby may therefore lack transactions acknowledged by the primary when that primary fails. Synchronous replication changes the acknowledgement conditions and introduces waiting; its durability depends on configuration. PostgreSQL's standby documentation describes these behaviours.
Review the configured commit behaviour and failure policy with the service owner. Do not promise zero data loss simply because a dashboard labels the cluster synchronous. Test what happens when the required standby becomes unreachable and whether the organisation prefers paused writes or a deliberate change in durability.
A read replica also needs an explicit role. The PostgreSQL high availability overview distinguishes warm standby and hot standby. Read capacity and readiness to take over writes should have separate acceptance checks.
Keep failover to a single writer
Before a standby takes over, the failover design must prevent the former primary from continuing to accept writes. This is fencing. PostgreSQL warns about both servers believing they are primary, and notes that core PostgreSQL does not supply the external system that detects failure and coordinates takeover. Its failover documentation explains the requirement.
Make a network partition part of the exercise. A server that cannot be reached by the monitor may still be alive and reachable by application clients. Record who decides which node can write and how that decision is enforced.
Test application connection pools, retries and routing as well as promotion. After takeover, rebuild the required redundancy. A service running on its last usable node has recovered availability but remains exposed to another failure.
Use WAL and PITR for a recoverable history
Continuous recovery combines a suitable base backup with the required sequence of archived Write-Ahead Log, or WAL, records. Point-in-time recovery, or PITR, can stop replay at a chosen point. A logical dump is a different backup method and cannot serve as that physical recovery base. PostgreSQL documents the recovery chain.
Give retention a reason: how long might a destructive change remain unnoticed? Keep the necessary backup and log history for that window, with room for investigation. Monitor archive failures and storage capacity. A retention setting in a policy document is not proof that the required objects are present.
Track configuration, extensions, access rules and keys separately. Restoring database files cannot reconstruct every dependency of the service. In particular, WAL recovery does not restore manual changes to PostgreSQL configuration files.
Run this restore acceptance test
Use an isolated recovery environment and a written scenario. Prevent the restored application from sending real emails, taking payments or running production integrations during the exercise.
| Acceptance step | Pass condition |
|---|---|
| Declare scenario and target | Failure, recovery point, RPO/RTO and decision owner recorded |
| Obtain recovery access | Backup store and required keys accessible without relying on failed production access |
| Restore and replay | Selected backup and required WAL produce a running database at the intended point |
| Check data | Known reference records and application invariants pass |
| Exercise the service | Representative reads and writes work through the actual application |
| Compare objectives | Measured data gap and service recovery duration assessed against targets |
| Record next actions | Gaps assigned, restored test data removed according to policy |
For suitable base backups, pg_verifybackup can detect integrity problems. PostgreSQL explicitly says backup verification still needs test restores. Keep the tool result and the application result as distinct evidence.
Illustrative scenario: a team sets a five-minute RPO and a two-hour RTO for loss of its primary environment. A test restores data only to twelve minutes before the simulated failure and returns the application to service after ninety minutes. It meets the time target and fails the data-loss target. A single “restore passed” label would hide the failure.
Include recovery dependencies in the observability strategy. If the database runs on Kubernetes, review the wider operations maturity rather than assuming an operator covers every recovery dependency.
Frequently asked questions
Does a PostgreSQL replica replace backups?
No. It can carry the same destructive changes as the primary. Keep recoverable history and test the route to a known-good state.
Does a managed database remove the need for a recovery plan?
No. Confirm the provider's recovery scope, retention and access requirements, then test application recovery and the dependencies your team still owns.
How often should a restore be tested?
Choose a cadence based on criticality and change rate. Repeat after material changes to backup configuration, keys, extensions or topology, and after a test reveals a gap.
Alongside's technical advisory service can help review failure boundaries and define a PostgreSQL recovery exercise with measurable acceptance criteria.



