DBAtlas · Atlas für Datenbankbetrieb

WAL-Archivierung für pgBackRest konfigurieren (archive-push/archive-get)

PostgreSQLBackup & PITR

Befehl

# 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/data

Was es tut

Lässt PostgreSQL jedes abgeschlossene WAL-Segment an das pgBackRest-Repository senden (archive-push) und es bei der Recovery von dort holen (archive-get); archive-async macht das Senden über ein Spool-Verzeichnis parallel und asynchron.

Wann einsetzen

Als erster Schritt beim Einrichten physischer Backups und PITR mit pgBackRest, vor stanza-create.

Vorsicht

Solange archive_command fehlschlägt, sammelt sich WAL in pg_wal an, und die Primary stoppt, wenn die Platte voll ist; überwache pg_stat_archiver.failed_count. Setze diese Parameter bei Patroni über patroni.yml / edit-config statt in postgresql.conf. Archivieren zwei verschiedene Cluster in dieselbe Stanza, wird das Repository beschädigt.

In DBAtlas öffnen →

Verwandte Einträge