liveBook · Manning

Pg_verifybackup

As explained in PostgreSQL Mistakes and How to Avoid Them

pg_verifybackup is a PostgreSQL command-line utility that verifies the integrity of a base backup.

A base backup is not proven usable merely because it was created successfully. pg_verifybackup verifies the backup’s checksums as part of a recovery fire drill, exposing corruption before an emergency. section 9.4

Use it within a complete backup test:

  • Copy the base backup into a test PGDATA directory. section 9.4
  • Run pg_verifybackup to check the base backup’s checksums. section 9.4
  • Copy subsequent WAL files, inspect them with pg_waldump, and start PostgreSQL to confirm consistent recovery. section 9.4

Do not treat checksum verification as a complete restore test. For stronger assurance, read restored relation pages with pageinspect and automate the procedure with error alerts. section 9.4

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Explains checksum verification within a restore workflow, while deferring WAL parsing and page-level checks to other tools.
Examples
Uses a fresh PGDATA restore, checksum verification, WAL parsing, consistent startup, and optional relation-page inspection.
What it assumes
Assumes PostgreSQL backup and WAL concepts, while demonstrating the verification sequence from a test PGDATA directory.
What you can do after
Operate pg_verifybackup within an automated restore drill and detect invalid base-backup checksums before an emergency.
How it connects
Connects base backups with WAL, pg_waldump, PostgreSQL recovery, 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.