This episode moves the repository off the database host: a remote repository on another host via SSH (repo1-host), and S3-compatible object storage with repo1-type=s3 along with its endpoint and bucket. You'll understand the use cases: location-disaster-proof off-site backups and cheap cloud storage.

So far our repository has been on the same host as the database. This works, but leaves one big gap: if that host dies — broken disk, seized machine, burned data center — the backup goes with it, along with the data it was supposed to protect. In episode 12 we move the repository out: to a remote host via SSH, or to S3-compatible object storage for cloud scale.
This is a crucial step toward real disaster recovery. A correct backup must always live somewhere that can't be lost at the same time as its data source.
In a remote architecture, the database runs on host A and the repository is on host B. All backup operations are still triggered from host A, but files are written to host B over SSH. The advantage: full physical separation, and you directly control the storage media.
On the database host, add the remote repository options in /etc/pgbackrest.conf:
[global]
repo1-host = backup01.internal
repo1-host-user = postgres
repo1-path = /var/lib/pgbackrest
[main]
pg1-path = /var/lib/postgresql/16/mainrepo1-host — the host where the repository lives.repo1-host-user — the SSH user on that host (usually postgres or a dedicated pgbackrest user, episode 13).repo1-path — the repository directory on the remote host.All pgBackRest commands run from the database host and connect to the remote host automatically. No need to run anything on host B — pgBackRest uses SSH according to the configuration.
sudo -u postgres pgbackrest --stanza=main check
sudo -u postgres pgbackrest --stanza=main backup --type=fullcheck validates the SSH connection to repo1-host — a connection error at this stage is almost always about SSH keys (not pgBackRest). Make sure key authentication works without a password (episode 13).
Note
A remote repository adds a new single point of failure: the SSH connection. Network latency and bandwidth now also determine backup and WAL archiving duration. For a tight RPO, make sure the inter-host link is stable and fast — or consider S3, which is more latency-tolerant.
With repo1-type = s3, pgBackRest talks directly to S3-compatible object storage: AWS S3, MinIO, Cloudflare R2, Backblaze B2, or another S3 gateway. There's no SSH host to maintain — the storage media is managed by the cloud provider.
[global]
repo1-type = s3
repo1-s3-bucket = db-backup-prod
repo1-s3-endpoint = s3.ap-southeast-1.amazonaws.com
repo1-s3-region = ap-southeast-1
repo1-s3-key = AKIAXXXXXXXX
repo1-s3-key-secret = aBcDeFgH...
repo1-s3-uri-style = virtual-hostOptions commonly adjusted:
repo1-s3-endpoint — regional endpoint; for local MinIO, replace it with the MinIO host and repo1-s3-uri-style = path.repo1-s3-key / repo1-s3-key-secret — static credentials.repo1-s3-region — bucket region.repo1-s3-role — a credentials alternative: use an IAM role instead of static keys (we cover this in episode 20).After the config, the flow is exactly the same:
sudo -u postgres pgbackrest --stanza=main stanza-create
sudo -u postgres pgbackrest --stanza=main check
sudo -u postgres pgbackrest --stanza=main backup --type=fullNotice that the stanza, check, and backup concepts don't change — only the storage location differs. This is the strength of pgBackRest's design: one workflow, many media.
Tip
S3-compatible is ideal for off-site and long-term archives: low storage cost, no backup server to maintain, and location-disaster-proof. For very fast RTO, combine: repo1 local for fast recovery + repo2 S3 for the off-site archive.
pgBackRest supports repo1 and repo2 simultaneously. A common production pattern: repo1 local (fast RTO) + repo2 S3 (off-site/archive).
[global]
repo1-path = /var/lib/pgbackrest
repo2-type = s3
repo2-s3-bucket = db-backup-archive
repo2-s3-endpoint = s3.ap-southeast-1.amazonaws.com
repo2-s3-region = ap-southeast-1
repo2-s3-key = AKIAXXXXXXXX
repo2-s3-key-secret = aBcDeFgH...When backing up, use --repo1 --repo2 (the default when both are configured). Restore can pull from either repository:
sudo -u postgres pgbackrest --stanza=main --repo=2 restoreThis combination answers two needs at once: speed (local) and location security (cloud).
Warning
S3 credentials in a config file are secrets — set 600 permissions and consider an IAM role / environment variable instead of static keys. In episode 20 we use an IAM role for cloud instances; for local MinIO, use static keys rotated periodically.
Key takeaways:
repo1-host + SSH physically separates data and backups.repo1-type = s3) stores backups in provider-managed object storage.In the next episode we'll secure the transport path: SSH & networking — creating a dedicated pgbackrest user with key authentication, configuring access via pg1-host/repo1-host and SSH options in the config, plus network rules: don't expose the backup server, use VPN or tunnels for remote. Data security in transit is half of overall security!