liveBook · Manning

Backup testing

As explained in PostgreSQL Mistakes and How to Avoid Them

Backup testing is the practice of restoring backups in an isolated environment to verify that the backups and recovery process work correctly.

Backup testing restores a PostgreSQL backup in a fresh testing environment to verify both the backup and the recovery procedure. A successful backup command alone does not prove that recovery will work. section 9.4

A practical restore test checks the following:

  • Copy the base backup into the test PGDATA directory. section 9.4
  • Verify the base backup with pg_verifybackup. section 9.4
  • Copy subsequent WAL files into the test PGDATA directory and check that they are parsable with pg_waldump. section 9.4
  • Start PostgreSQL, confirm recovery reaches a consistent state, and optionally inspect every relation page with pageinspect. section 9.4

The failed restore nobody tested

A company discovers that its restore command fails after its production database is lost. The backup may have been unusable, corrupted in storage, deleted, or accompanied by an unworkable recovery procedure. A restore drill exposes these failures before an emergency. section 9.4

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Details a restore checklist from checksum and WAL validation through consistent recovery and optional page-level inspection.
Examples
Uses a fresh PostgreSQL instance, a base backup, subsequent WAL files, checksum verification, and optional relation-page inspection.
What it assumes
Assumes familiarity with PostgreSQL backups, PGDATA, WAL, and starting a PostgreSQL instance.
What you can do after
Operate/configure a PostgreSQL restore drill and diagnose whether backups and recovery inputs reach a consistent database state.
How it connects
Connects backups with PostgreSQL recovery, WAL, PGDATA, pg_verifybackup, pg_waldump, and pageinspect.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.