PostgreSQLXV · High Availability, Failover and Disaster RecoveryHA
HA versus backup versus DR; RPO and RTO with real arithmetic
What you'll learn
- Separate high availability, backup and disaster recovery by the failure each addresses
- Compute an RPO and RTO from measurements rather than from policy
- Identify which failures your current design does not cover
- Present the trade-offs to someone who must fund them
Prerequisites
Verified against PostgreSQL 18.x · PostgreSQL (comparison targets) 17.11, 16.15 · PostgreSQL (support calendar) 18, 17, 16, 15, 14 supported · pgBackRest 2.59.1 · PgBouncer 1.25.2 · Patroni 4.1.5 · Ubuntu (host baseline) 26.04 LTS · 2026-08-27
Three different problems, frequently conflated, and each one leaves the others uncovered.
What each addresses
| Covers | Does not cover | |
|---|---|---|
| High availability | A host or process failing | Anything that replicates |
| Backup | Data destroyed or corrupted | Being unavailable meanwhile |
| Disaster recovery | A site, region or provider lost | Either of the above on its own |
The dividing line between HA and backup is sharp and worth stating plainly:
HA protects against a machine stopping. Backup protects against data becoming wrong.
A DROP TABLE replicates to every standby in milliseconds. So does a
migration that updated every row with a bad WHERE clause, an
application bug writing nonsense, and a DELETE without a predicate.
Every one of those is faithfully copied to every replica, because
faithful copying is exactly what replication is.
RPO and RTO, computed
Both are two numbers, and only the measured ones mean anything.
Recovery point objective
Asynchronous replication. Whatever had not reached the standby. Measured in lesson XIV-04: 2.5 ms at 1,623 tps on a healthy pair — and lesson XIV-07 measured the same pair 30 seconds and 124 MB behind when one query conflicted with replay. Your RPO is the second number, not the first, because failures do not wait for the system to be healthy.
Synchronous replication. Zero, for anything acknowledged. Lesson XIV-05 measured the cost at 9% throughput on a loopback pair, dominated by the network round trip in any real deployment.
Backup plus archive. Bounded by archive_timeout and archive lag.
With archive_timeout = 60, up to 60 seconds — plus however long the
archive is behind, which lesson XIII-05’s pg_stat_archiver query is
for.
Backup alone. The interval between backups. Nightly dumps mean a 24-hour RPO, and no amount of care changes that.
Recovery time objective
Add the terms, and be honest about each:
| Term | Automated failover | Manual failover | Restore from backup |
|---|---|---|---|
| Detection | ttl, ~30 s | Minutes to hours | Same |
| Decision | Seconds | Minutes | Minutes |
| Fencing | Seconds | Minutes | n/a |
| Promotion / restore | 89 ms (measured) | 89 ms | Hours for a large cluster |
| Rerouting | Seconds to minutes | Minutes | Minutes |
| Client reconnection | Seconds to minutes | Same | Same |
The database’s own contribution is 89 milliseconds in two of those three columns. Everything else is detection, humans, routing and clients.
What a complete design covers
Work down the list and mark what your current design actually handles:
- A PostgreSQL process crashing → restart; Part XII’s crash recovery
- A host failing → HA, Part XV
- A disk failing → RAID, or HA
- A table being dropped → backup and PITR, Part XIII
- Data corrupted by the application → backup and PITR
- Silent corruption discovered late → backups with enough history
- A rack, AZ or region lost → DR: replication and backups elsewhere
- A cloud account compromised or deleted → backups outside that account
- Ransomware → immutable or offline backups
- A person deleting the backups → backups they cannot delete
The bolded items are not covered by any amount of replication. The last three are not covered by backups either, unless the backups are somewhere the same credentials cannot reach — which is the practical meaning of the “3-2-1” convention, and the reason the last line exists.
What to take from this
- HA covers a machine stopping. Backup covers data becoming wrong. DR covers losing a site. None substitutes for another.
- A
DROP TABLEreplicates in milliseconds. Replicas do not protect against it. - Measured RPO: 2.5 ms healthy, 30 s when replay was blocked. Plan for the second.
- Measured promotion: 89 ms. The RTO is detection, humans, routing and clients.
- Write down intended and measured numbers, with the date measured.
- Backups must be somewhere the credentials that run production cannot delete them.
- A distant standby is not DR. Backups elsewhere, a rehearsed restore there, and a decision procedure are.
Cross-course references
- Linux for Production Sysadmins — Part L (Disaster recovery) covers RPO and RTO as commitments with arithmetic behind them, and Part LII (High availability fundamentals) covers why availability and recoverability are separate budgets.
- Ceph & Distributed Storage — Part CIX (Disaster recovery) and Part CXIX (Disaster recovery architecture) cover the storage layer’s version of the same three-way distinction.
- Observability for Production Sysadmins — Part XCII (Disaster recovery) covers monitoring that survives the disaster it reports.
Quiz
Knowledge check · 6 questions
Q1. A team has three streaming replicas across two regions and no tested restore. Which failure are they not protected against?
Q2. Replication lag on a healthy pair measures 2.5 ms. What RPO should be planned for?
Q3. Why is a standby in another region not, by itself, disaster recovery?
Q4. Which failures does replication alone leave uncovered? Select all that apply.
Q5. In both automated and manual failover, PostgreSQL's own contribution to the RTO is under a tenth of a second.
Q6. Explain why high availability, backup and disaster recovery are three separate problems, and what each leaves uncovered.
Passing score: 75%. Answers are checked in this browser.