WALF

Loading...

WalFetch.com helps database engineers configure wal fetch, WAL-G, and PostgreSQL continuous archiving.

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.

Step 1

List Available Backups

Run 'wal-g backup-list --detail --pretty' to see all available base backups with their timestamps and metadata.
Step 2

Restore Base Backup

Run 'wal-g backup-fetch /path/to/pgdata LATEST' to download the most recent full backup to the data directory.
Step 3

Configure restore_command

Set restore_command = 'wal-g wal-fetch "%f" "%p"' in postgresql.conf to enable WAL replay after base restore.
Step 4

Start PostgreSQL Recovery

Start PostgreSQL and monitor pg_log for WAL restore progress. Recovery completes when all available WAL is replayed.