5.1 Stanza와 repository
pgBackRest의 stanza는 하나의 PostgreSQL cluster와 repository 설정을 묶는 이름입니다. Primary host 이름보다 service 역할을 나타내는 이름을 쓰면 failover 뒤에도 의미가 유지됩니다.
[app]
pg1-path=/var/lib/postgresql/18/main
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
start-fast=y
log-level-console=info
Repository directory는 PostgreSQL owner가 접근할 수 있어야 하지만 불필요하게 넓은 권한을 주지 않습니다.
sudo -u postgres pgbackrest --stanza=app stanza-create
sudo -u postgres pgbackrest --stanza=app check
check는 database와 repository 설정, WAL archive 동작을 검사합니다. archive_command는 다음처럼 pgBackRest로 연결합니다.
archive_mode = on
archive_command = 'pgbackrest --stanza=app archive-push %p'
restore_command = 'pgbackrest --stanza=app archive-get %f "%p"'
Local과 remote pgBackRest binary version은 일치시킵니다. Configuration, repository credential, encryption key를 secret 관리 체계에 넣고 backup data와 분리합니다.