Skip to main content
RunBook Academy

PostgreSQLXIII · Backup, Archiving and Point-in-Time RecoveryBackup

Backup success is not recovery capability

Intermediate⏱ ~30 minpsqlpg_dump

What you'll learn

  • State an RPO and RTO and identify what each one constrains
  • Distinguish what a backup job proves from what a restore proves
  • Enumerate what a given backup method does not capture
  • Design a verification that would catch a silently incomplete backup

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

Not yet marked complete on this device.

Every organisation that has lost data had backups. The backups ran, the jobs reported success, and the monitoring was green. What they did not have was a demonstrated ability to reconstruct a working system.

This part is about the difference, and it starts with a measurement.

A backup that succeeds and cannot be restored

Data-loss riskhow many role definitions a pg_dump contains
$ pg_dump -U postgres -F p postgres | grep -cE "^CREATE ROLE|^CREATE TABLESPACE|^ALTER ROLE"
0

Zero. pg_dump dumps one database, and roles and tablespaces are cluster-level objects. They are not in it.

Read-only / Safewhere they actually live
$ pg_dumpall -U postgres --globals-only | grep -E "^CREATE ROLE|^ALTER ROLE"
CREATE ROLE postgres;
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS PASSWORD 'SCRAM-SHA-256$...';
CREATE ROLE reporter;
ALTER ROLE reporter WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-256$...';

The backup job that produced the first output exited zero. Its monitoring was green. A restore from it produces a database whose every GRANT references a role that does not exist — errors on each one, and a database that comes up with the privileges missing.

The job succeeded. The recovery capability did not exist.

The two numbers that define the requirement

Before choosing a method, the requirement has to be stated. Two numbers do it.

RPO — Recovery Point Objective. How much data may be lost, expressed as time. “Fifteen minutes” means a failure may lose up to fifteen minutes of committed transactions.

RTO — Recovery Time Objective. How long the system may be down. “Four hours” means recovery must be complete within four hours of the decision to recover.

They constrain different things:

Constrained by
RPOBackup frequency, WAL archive frequency, replication mode
RTORestore speed, replay speed, the procedure, and who is available

A team with hourly base backups and no WAL archiving has an RPO of one hour, whatever anyone intended. A team whose restore has never been timed has an unknown RTO, and “unknown” is not a number you can put in a service agreement.

What each method captures

MethodGranularityCluster objectsPoint-in-timeRestore speed
pg_dumpOne databaseNoNoSlow — rebuilds indexes
pg_dumpallWhole clusterYesNoSlow
pg_basebackupWhole clusterYesOnly with WAL archiveFast — file copy
Base backup + WAL archiveWhole clusterYesYesFast
Filesystem snapshotWhole clusterYesOnly with WAL archiveFastest

The row that matters for most production systems is the fourth. Lessons XIII-03 through XIII-07 build it.

What a backup job proves

A backup job that exits zero proves:

  • A process ran.
  • It wrote a file.
  • It did not return an error.

It does not prove:

  • The file is complete.
  • The file is readable.
  • The file contains what you assume.
  • A database can be built from it.
  • Anyone knows how.
  • The result would pass an application’s own checks.

What a restore proves

Only a restore proves recoverability, and only a restore that is verified proves it fully:

  1. The artefacts are readable. They were fetched and opened.
  2. The database starts. It reached “ready to accept connections”.
  3. The data is there. Row counts and checksums match expectation.
  4. The procedure works. Somebody followed it, and it was correct.
  5. The time is known. It was measured, so RTO is a fact.

Lesson XIII-08 makes this a routine rather than an event.

What to take from this

  • Measured: pg_dump of a database with roles contains zero role definitions. The job still succeeds.
  • pg_dumpall --globals-only output contains password verifiers. Handle it as a credential file.
  • State RPO and RTO explicitly, derived from the cost of loss, with a date and an owner.
  • A backup job proves a file was written. Nothing more.
  • Only a restore proves recoverability, and only a timed one gives you an RTO.
  • A replica is availability, not recoverability. It replays the DROP TABLE too.

Cross-course references

  • Linux for Production Sysadmins — Part XLVII (Backup strategy) and Part XLIX (Restore) cover the same distinction for the host: a backup job that exits zero has proved the job ran, not that the data returns.
  • Ceph & Distributed Storage — Part CV (Backup strategy) covers why replication inside a storage system is not a backup either, which is the same argument one layer down.
  • Observability for Production Sysadmins — Part XCI (Backup strategy) covers alerting on backup age rather than on the last job’s exit status.

Quiz

Knowledge check · 6 questions

  1. Q1. A nightly pg_dump of the application database has run successfully for two years. During a restore, every GRANT statement fails. What was missing?

  2. Q2. A team argues their streaming replica removes the need for backups. What failure does that reasoning not survive?

  3. Q3. A backup script runs pg_dump piped to gzip and checks the exit status of the pipeline. What can go undetected?

  4. Q4. Which failures leave a backup job reporting success while recovery is impossible? Select all that apply.

  5. Q5. An RTO that has never been measured by performing a restore is not a number that can be committed to in a service agreement.

  6. Q6. How would you establish an organisation's RPO and RTO, and what does each one constrain?

Passing score: 75%. Answers are checked in this browser.