WAL-G Backup Fetch: Restoring Full PostgreSQL Base Backups
While wal-g wal-fetch retrieves individual WAL segments, wal-g backup-fetch restores a complete PostgreSQL base backup from cloud storage. Together, these two commands form the full recovery workflow: restore the base backup first, then replay WAL archives via wal-fetch to reach the desired recovery point.
The basic backup-fetch command is: wal-g backup-fetch /var/lib/postgresql/data LATEST. This downloads the most recent full backup to the specified PostgreSQL data directory. Replace LATEST with a specific backup name from wal-g backup-list to restore a particular snapshot.
After backup-fetch completes, configure postgresql.conf (or recovery.conf in older versions) with the restore_command pointing to wal-g wal-fetch. When PostgreSQL starts, it will apply all available WAL archives on top of the base backup to reach consistency.
UserData targeting: use --target-user-data flag with backup-fetch to restore a backup identified by custom metadata rather than a backup name. This enables workflows where backups are tagged with business-meaningful labels.
Restore point targeting: the --restore-point flag allows restoring to a named restore point created with pg_create_restore_point(), combining the precision of named snapshots with the automation of wal-fetch.
Partial restore: for Greenplum and similar distributed databases, backup-fetch supports --content-ids to restore only specific segments, allowing surgical recovery of individual database nodes without full cluster downtime.
“Backup-fetch and wal fetch are two sides of the same coin—the base backup provides the starting state, while wal fetch fills in every transaction since.”
Step-by-Step: List Available Backups
Follow these steps to implement wal fetch in your PostgreSQL environment effectively.
List Available Backups
Restore Base Backup
Configure restore_command
Start PostgreSQL Recovery
Related topics: wal-g backup-fetch, PostgreSQL restore, base backup recovery