Configure WAL archiving for pgBackRest (archive-push/archive-get)
PostgreSQLBackup & PITRCommand
# postgresql.conf (changing archive_mode requires a restart):
wal_level = replica
archive_mode = on
archive_command = 'pgbackrest --stanza=<stanza> archive-push %p'
# On the restore/standby side (in postgresql.conf on PG12+):
restore_command = 'pgbackrest --stanza=<stanza> archive-get %f "%p"'
# /etc/pgbackrest/pgbackrest.conf (database host, local repo example):
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
archive-async=y
spool-path=/var/spool/pgbackrest
process-max=4
compress-type=zst
start-fast=y
[<stanza>]
pg1-path=/var/lib/pgsql/16/dataWhat it does
Makes PostgreSQL send every completed WAL segment to the pgBackRest repository (archive-push) and fetch it from there during recovery (archive-get); archive-async makes pushing parallel and asynchronous through a spool directory.
When to use it
As the first step of setting up physical backups and PITR with pgBackRest, before stanza-create.
Caution
As long as archive_command fails, WAL accumulates in pg_wal and the primary stops when the disk fills; monitor pg_stat_archiver.failed_count. With Patroni, set these parameters through patroni.yml / edit-config instead of postgresql.conf. Archiving from two different clusters into the same stanza corrupts the repository.
Related
- Create the pgBackRest stanza and verify archiving (stanza-create/check)
- Take full, differential and incremental backups with pgBackRest
- Show the pgBackRest backup catalog and WAL archive range (info)
- Restore the latest backup with pgBackRest
- Restore to a point in time with pgBackRest (PITR, --type=time)
- Quickly rebuild a standby with pgBackRest delta restore