WALF

Loading...

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

Wal Fetch PostgreSQL: Continuous Archiving and PITR with WAL-G

PostgreSQL's Write-Ahead Logging (WAL) is the foundation of its durability and replication system. By combining PostgreSQL's archive_command with WAL-G's wal-fetch restore_command, you get a complete continuous archiving solution capable of point-in-time recovery (PITR) to any second in your database history.

Continuous PostgreSQL backups using wal fetch work in two directions. The archive_command pushes new WAL segments to cloud storage using wal-g wal-push, while the restore_command pulls them back using wal-g wal-fetch during recovery. Together they form a fully automated backup pipeline.

WAL-G supports PostgreSQL, MySQL/MariaDB, and MS SQL Server, making it a versatile multi-database archival solution. For PostgreSQL, it leverages non-exclusive base backups and supports LZ4, LZMA, ZSTD, and Brotli compression algorithms.

Point-in-time recovery (PITR) with wal fetch lets you restore your database to any previous state by replaying archived WAL segments up to the desired recovery_target_time. This is invaluable for recovering from accidental data deletions, corruption, or failed migrations.

Delta backups minimize storage usage by only storing the differences between full backups. The WALG_DELTA_MAX_STEPS environment variable controls how many delta backups are allowed between full backups, balancing storage efficiency with restore time.

For production environments, WAL-G supports failover storage configurations. If the primary storage becomes unavailable, WAL-G automatically switches to a failover storage, preventing backup gaps during storage incidents.

“With wal fetch properly configured in PostgreSQL, every WAL segment is a safety net—recovery becomes a matter of minutes, not hours.”

Step-by-Step: Configure archive_command

Follow these steps to implement wal fetch in your PostgreSQL environment effectively.

Step 1

Configure archive_command

Set archive_command = 'wal-g wal-push %p' in postgresql.conf to enable continuous WAL archiving to cloud storage.
Step 2

Set restore_command

Add restore_command = 'wal-g wal-fetch "%f" "%p"' so PostgreSQL can retrieve archived WAL segments during recovery.
Step 3

Push a Base Backup

Run 'wal-g backup-push /path/to/pgdata' to create the initial full base backup in cloud storage.
Step 4

Recover with PITR

Create a recovery.conf or use recovery_target_time in postgresql.conf to restore to a specific point in time.