This episode dissects the pgBackRest architecture: the stanza as the backup unit per cluster, the repository as the storage destination (local, remote, or object storage), and the full, differential, and incremental backup process. You'll also learn the roles of the pgbackrest binary, the /etc/pgbackrest.conf config, archive_command, and the main commands such as backup, restore, archive-push/get, and info.

After understanding the history and philosophy in episode 1, it's time to dissect the anatomy of pgBackRest. If episode 1 answered "why," episode 2 answers "how it's put together" — and this matters because all the configuration and commands in the following episodes reference these concepts. Understand the architecture and every command feels logical; don't, and you'll only be memorizing commands.
Three key concepts you must master: the stanza, the repository, and the backup process. All three will appear in nearly every line of configuration and every command we write.
A stanza is the backup unit for one PostgreSQL cluster. Each cluster (primary, or later in episode 18, standby) has its own stanza with a freely chosen name we decide — for example main, prod, or analytics. The stanza separates all data (backups, WAL, metadata) between clusters inside the same repository.
[global]
repo1-path = /var/lib/pgbackrest
[main]
pg1-path = /var/lib/postgresql/16/mainHere [main] is the stanza for the cluster whose PGDATA is at /var/lib/postgresql/16/main. A single repository can hold many stanzas — imagine one host with three clusters: main, reports, warehouse, each with its own stanza.
The repository is where all backups and WAL are stored. Three repository types are supported:
repo1-path).repo1-host).repo1-type=s3 etc.).pgBackRest supports up to two repositories (repo1, repo2) at once — the common pattern is one local for fast recovery and one object storage for off-site. We'll build this configuration in episode 12.
pgBackRest organizes backups into three complementary types:
Full (Sun) ── Diff (Mon) ── Incr (Tue) ── Incr (Wed)
└── basis └── since Full └── since Incr └── since IncrBecause each backup only stores the changes, this combination saves space and time — we'll break down the details in episode 5.
pgbackrest BinaryOne binary does everything. Check the available commands:
pgbackrest helpCore commands: backup (create a backup), restore (recover), archive-push (accept WAL from PostgreSQL), archive-get (send WAL during restore), info (status), check (validation), stanza-create (initialize a stanza), and expire (retention).
/etc/pgbackrest.conf ConfigAll options are stored in a config file (INI format). Its structure has two parts: [global] for options that apply to all stanzas, and [stanza-name] for cluster-specific options:
[global]
repo1-path = /var/lib/pgbackrest
log-level-file = info
process-max = 4
[main]
pg1-path = /var/lib/postgresql/16/main
pg1-port = 5432Both global and per-stanza options can be overridden per command via --option arguments, for example pgbackrest --stanza=main --type=diff backup.
This is the bridge between PostgreSQL and pgBackRest. When archive_mode=on, every time WAL is rotated PostgreSQL calls archive_command — which we point at pgBackRest:
archive_mode = on
archive_command = 'pgbackrest --stanza=main archive-push %p'
archive_timeout = 60%p is the full path of the WAL being archived. pgBackRest copies, compresses, and encrypts that WAL into the repository. The reverse direction (during restore) uses archive-get, which is integrated automatically by the restore command.
Let's follow the data path in a single backup cycle:
archive_command calls pgbackrest archive-push %p → WAL enters the repository.pgbackrest backup copies the data files + consults the already-archived WAL for consistency.pgbackrest restore copies the data files back + uses archive-get to replay WAL up to the desired point. PostgreSQL ──archive-push──▶ Repository ◀──backup── pgbackrest
▲ │
└──────── archive-get ─────────────┘
(during restore)Throughout this series you'll use these five commands in nearly every episode:
pgbackrest --stanza=main stanza-create
pgbackrest --stanza=main check
pgbackrest --stanza=main backup --type=full
pgbackrest info
pgbackrest --stanza=main restoreNote the pattern: --stanza determines which cluster is touched, followed by the command you want to run. info displays the status of all stanzas and backups in a table.
Note
A stanza is like a "filing cabinet" per cluster. Never use the same stanza name for two different clusters — pgBackRest locks a stanza to the cluster's metadata, and mixing them will make check fail with a cluster identity mismatch error.
Key takeaways:
pgbackrest binary, the /etc/pgbackrest.conf config, archive_command in postgresql.conf.In the next episode we'll install and configure pgBackRest for real — from installing the distribution package or building from source, creating the user and directories, to writing your first /etc/pgbackrest.conf with correct [global] and [stanza] sections. It's time to get your hands on the keyboard!