This is the multi-page printable view of this section. .
Backup
Snapshots
Snapshot types:
full— Complete backup (default, self-contained)diff— Changes since last full backupincr— Changes since last backup
Shared Backup Container
All instances share a single pgbackrest container; each instance gets its own stanza in the repository.
One repository per config file. The container serves exactly one repository — the local directory under
data_dir, or the singlebackup.repo.s3endpoint when configured — and every stanza in the environment (regular instances and Patroni clusters alike) pushes to it. There is no per-instance or per-cluster repo choice: one pgcli environment therefore backs up to one store. To aim a second store (e.g. a secondpg addon install minio) at a subset of clusters, run a second config (pg config init --namespace …) with its own backup container — worked out end to end in Example: HA Cluster with a Self-CA MinIO.
Backup infrastructure (network, image, directories, config, container) is prepared automatically on pg start; run pg backup setup manually to reinitialize, e.g. after changing the base directory.
S3 Object Storage Repository
Patroni cluster backups and WAL archiving can push to any S3-compatible store
(MinIO, silo, rustfs, garage, AWS S3, …). Configure it under backup.repo.s3
in pg.yaml:
Then re-run setup — it performs the archiving orchestration:
- HTTPS is mandatory. pgBackRest refuses plaintext S3 (upstream won’t
implement it), so the endpoint must serve TLS. pgcli’s own MinIO does via
pg addon install minio --tls— pgcli generates a self-signed CA whoseca.crtpath you put inca_fileabove. (silo and rustfs take--tlsthe same way; garage has no native TLS, so front it with the nginx addon — see Garage.) Publicly-caught endpoints (real AWS S3) just omitca_file; if you truly cannot supply a CA,verify_tls: falseis the escape hatch (no certificate verification). - Fetching the CA from a remote store — no scp. When the MinIO lives on
another machine, get its trust anchor with one TLS handshake instead of
copying files:
pg backup fetch-ca <store-host>:9002pulls it out of the endpoint’s served chain, saves it under<base-dir>/backup/repo-ca/and prints a SHA-256 fingerprint — trust-on-first-use, so cross-check the fingerprint against the store host before feeding the file topg backup setup --s3-ca-file <path>. It covers exactly the two TLS shapes pgcli serves: a MinIO with--tls(the generated leaf+CA chain — the signing root is pulled from the chain) and a MinIO with apg cert-minted BYO self-signed leaf (the leaf is the anchor, and is saved as-is). Publicly-trusted endpoints need noca_fileat all, so this command is pointless there. - Cross-host HA needs no key/CA hand-copy. For a Patroni cluster spread
over several hosts,
ca_fileand the backup SSH public key only have to be set up on one host:pg backup setuppublishes the CA to the cluster’s etcd registry and a joiner withca_fileempty pulls it; each host’s backup public key is likewise published onpg ha createand merged into every member’s authorized_keys bysetup. Only public material (the CA certificate, SSH public keys) enters the registry — never private keys or the S3 secret_key. See the HA doc, “Backing up a cross-host leader”. - Archiving is automated. When setup finds a Patroni member whose archiving
config is stale, it pauses the cluster, recreates members replicas-first
(the recreate restarts PostgreSQL, which postmaster-level
archive_modeneeds), then resumes. Each member’s patroni.yml gets the samearchive_command— one stanza per cluster, members listed aspg*-hostso pgBackRest finds the primary itself — and WAL streams to S3 from then on. - Blast radius. The S3 repo applies only to Patroni cluster stanzas;
pg-managed regular instances keep backing up to the local repo, unchanged.
One-shot flag equivalent (secret_key is best edited into pg.yaml so it never
lands in shell history):