pg_verifybackup
Verify PostgreSQL backup integrity
TLDR
Verify a backup stored in a specific directory
Verify a backup showing progress information
Verify a backup and exit immediately on first error
Verify a backup ignoring specific files or directories
Verify a backup with a manifest file in a different location
Display help
SYNOPSIS
pg_verifybackup [OPTION...] BACKUP
PARAMETERS
-D, --debug
Output debug messages for detailed diagnostics
-L, --list
List contents of the backup archive
--verify-checksums
Verify checksums in all data files
--version
Output version information and exit
--waldir=DIRECTORY
Specify directory holding additional WAL files
-?, --help
Show help message and exit
DESCRIPTION
pg_verifybackup is a PostgreSQL utility that checks the validity and integrity of backup archives created by pg_basebackup, supporting both plain directory and tar formats. It examines key components including WAL files, tablespace maps, and data files without requiring a full restore, saving time and resources. The tool detects corruption by verifying file structures, checksums (if enabled), and consistency of backup metadata.
Usage involves pointing it at an unmodified backup directory or tar file. It outputs a summary of verification results, listing any issues found. This is essential for production environments to confirm backup reliability before disasters. Debug mode provides detailed logs for troubleshooting, while list mode inventories contents. Note that it assumes backups are complete; partial or tampered archives will fail validation.
CAVEATS
Backup must be unmodified and complete; does not support compressed tar files or backups from before PostgreSQL 12. WAL verification limited unless --waldir specified. Exits with 0 on success, 1 on invalid backup, 2 on errors.
EXAMPLES
pg_verifybackup /path/to/backup_dir
pg_verifybackup --list --verify-checksums backup.tar
EXIT CODES
0: Valid backup
1: Backup invalid
2: Command error or usage issue
HISTORY
Introduced in PostgreSQL 12 (2019) to address need for non-restorative backup validation; enhanced in later versions with checksum support and WAL directory option.
SEE ALSO
pg_basebackup(1), pg_dump(1), pg_restore(1)


