PostgreSQL Backup with pgBackRest: Full, Incremental & Point-in-Time Recovery
pg_dump is a fine tool for small databases, but it takes a logical snapshot: restores are slow on large data, and you can only go back to the moment the dump ran. Production PostgreSQL needs physical backups plus continuous WAL archiving, which lets you restore to any point in time, such as one second before somebody ran DELETE without a WHERE.
pgBackRest is the most widely used open-source tool for exactly that. This guide sets it up on PostgreSQL 18 on Rocky Linux 10: stanza creation, WAL archiving, full and differential backups, encryption, retention, scheduling, verification, restore, and point-in-time recovery.
Table of Contents
- Project status in 2026: read this first
- How pgBackRest works
- Backup types compared
- Prerequisites
- Step 1: Install pgBackRest
- Step 2: Create the repository and configuration
- Step 3: Configure PostgreSQL for archiving
- Step 4: Create the stanza and check
- Step 5: Take backups
- Step 6: Schedule backups
- Step 7: Restore and point-in-time recovery
- Off-site repositories: S3 and a dedicated repo host
- Monitoring and verification
- SELinux and firewall notes
- Troubleshooting
- FAQ
1. Project status in 2026
pgBackRest had an unusual year, and anyone choosing a backup tool should know it.
| Date (2026) | Event |
|---|---|
| 19 Jan | Release 2.58.0 |
| 27 Apr | The maintainer announced that pgBackRest was no longer being maintained and archived the repository, citing lack of sponsorship after the end of corporate funding |
| 4 and 7 May | Updates saying a sponsor coalition was likely to fund continued work; the maintainer reminded users that the current release worked and there were no critical outstanding bugs |
| 18 May | Announcement: pgBackRest will continue, funded by a coalition of sponsors rather than a single company |
| 20 Jul | Release 2.59.0 with PostgreSQL 19 (beta) support |
| Oct | Further releases published; check the official release page for the current number |
What this means for you:
- The project is active again and supports PostgreSQL 18 (support arrived in 2.55.0).
- It is free and open source under the MIT license.
- The episode shows the risk of single-maintainer projects. Keep your restore procedure documented and tested, and watch the project’s news page. Percona stated at the time that it would continue to support pgBackRest for its customers.
- Alternatives exist (Barman, WAL-G, pg_basebackup plus WAL archiving). The concepts in this guide carry over.
2. How pgBackRest works
PostgreSQL server (primary) Repository (disk, remote host, or S3)
+--------------------------------------+ +---------------------------------------+
| data directory /var/lib/pgsql/data | | /var/lib/pgbackrest |
| | | |
| WAL segments --> archive_command ---+--------> | archive/main/ (WAL stream) |
| (continuous) pgbackrest | | |
| archive-push | | backup/main/ (full + diff + incr) |
| | backup | 20261124-020000F |
| pgbackrest backup ----------------+--------> | 20261124-020000F_20261125-020000D |
+--------------------------------------+ +---------------------------------------+
|
restore (latest, or to a time / LSN / named restore point)
v
new data directory + WAL replay = recovered database
Key terms:
| Term | Meaning |
|---|---|
| Stanza | pgBackRest’s name for one PostgreSQL cluster and its backup/archive configuration |
| Repository | Where backups and archived WAL are stored |
| Archive | The continuous stream of WAL files that makes PITR possible |
| Backup set | A full, differential or incremental backup |
| PITR | Point-in-time recovery: restore a backup, then replay WAL up to a chosen moment |
3. Backup types compared
| Type | Contains | Restore needs | Use |
|---|---|---|---|
| Full | Everything | Itself | Weekly or monthly baseline |
| Differential | Changes since the last full | Last full + this diff | Daily |
| Incremental | Changes since the last backup of any type | Full + diff (if any) + all incrementals in the chain | Frequent, small backups |
A common schedule: full weekly, differential daily. Retention is based on counts of full backups, and WAL is kept as long as any retained backup needs it.
4. Prerequisites
| Requirement | Detail |
|---|---|
| PostgreSQL | 18 installed and running, see PostgreSQL 18 on Rocky Linux 10.2 |
| Disk | Repository space of at least 1x to 2x the database size for a start, ideally on a different disk or host than the data |
| Access | sudo and the postgres OS user |
| Time | Synchronized (chrony), because backup labels and PITR use timestamps |
A repository on the same disk as the database is not a backup. It is a convenience copy. Put at least one repository on separate storage, and ideally off-site (section 12).
5. Step 1: Install pgBackRest
pgBackRest is distributed through the PostgreSQL community (PGDG) repositories and many distributions. On Rocky Linux 10 the common route is PGDG:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-10-x86_64/pgdg-redhat-repo-latest.noarch.rpm
If you installed PostgreSQL from the native AppStream packages, avoid mixing PostgreSQL server packages from PGDG. Install only pgbackrest from PGDG’s common repository, and disable the PostgreSQL-version repositories:
sudo dnf config-manager --disable 'pgdg1*'
dnf repolist --all | grep -i pgdg
sudo dnf install -y --enablerepo=pgdg-common pgbackrest
pgbackrest version
Verify that pgdg-common provides the package (dnf info pgbackrest) and that the version matches what you intend to run. Pin the version in change control; do not let an unattended update change your backup tool.
6. Step 2: Create the repository and configuration
sudo mkdir -p /var/lib/pgbackrest /etc/pgbackrest /var/log/pgbackrest
sudo chown postgres:postgres /var/lib/pgbackrest /var/log/pgbackrest
sudo chmod 750 /var/lib/pgbackrest
# Generate an encryption passphrase and store it OFF the server too
openssl rand -base64 48
Create /etc/pgbackrest/pgbackrest.conf:
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
repo1-retention-diff=7
repo1-cipher-type=aes-256-cbc
repo1-cipher-pass=PASTE_THE_GENERATED_PASSPHRASE_HERE
repo1-bundle=y
repo1-block=y
process-max=2
start-fast=y
compress-type=zst
log-level-console=info
log-level-file=detail
log-path=/var/log/pgbackrest
[main]
pg1-path=/var/lib/pgsql/data
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
| Option | Meaning |
|---|---|
repo1-path | Local repository location |
repo1-retention-full=2 | Keep two full backups (and their dependent diff/incr) |
repo1-retention-diff=7 | Keep seven differentials |
repo1-cipher-* | Encrypt the repository. Lose the passphrase and you lose the backups |
repo1-bundle / repo1-block | Bundle small files and enable block-level incremental backups; check pgbackrest help backup on your version |
process-max | Parallel processes; raise carefully on busy servers |
start-fast=y | Force an immediate checkpoint at backup start |
[main] | The stanza name; pg1-path is the data directory |
For the native packages the data directory is /var/lib/pgsql/data. With PGDG PostgreSQL packages it is /var/lib/pgsql/18/data.
Store the passphrase in a password manager and in a sealed envelope or vault. Do not keep the only copy on the server being protected.
7. Step 3: Configure PostgreSQL for archiving
Add these settings to /var/lib/pgsql/data/postgresql.conf (or a file included from it):
archive_mode = on
archive_command = 'pgbackrest --stanza=main archive-push %p'
wal_level = replica
max_wal_senders = 3
archive_timeout = 60
archive_mode requires a restart:
sudo systemctl restart postgresql.service
sudo -u postgres psql -c "SHOW archive_mode;" -c "SHOW archive_command;"
archive_timeout = 60 forces a WAL switch at least once a minute on quiet servers, so your recovery point objective (RPO) is bounded even when there is little write activity.
8. Step 4: Create the stanza and check
sudo -u postgres pgbackrest --stanza=main stanza-create
sudo -u postgres pgbackrest --stanza=main check
check forces a WAL switch, archives it, and confirms the whole chain works. Do not skip it: a silently failing archive_command is the most common way backups turn out to be useless.
sudo -u postgres pgbackrest info
9. Step 5: Take backups
# First backup must be a full backup
sudo -u postgres pgbackrest --stanza=main --type=full backup
# Later: differential and incremental
sudo -u postgres pgbackrest --stanza=main --type=diff backup
sudo -u postgres pgbackrest --stanza=main --type=incr backup
sudo -u postgres pgbackrest info
Example info output (abridged):
stanza: main
status: ok
wal archive min/max (18): 000000010000000000000010/000000010000000000000019
full backup: 20261124-020000F
timestamp start/stop: 2026-11-24 02:00:00 / 2026-11-24 02:03:41
database size: 5.2GB, database backup size: 5.2GB
repo1: backup size: 1.3GB
Look for status: ok, an advancing WAL range, and a reasonable compression ratio. Add a test table and insert rows between backups so you can prove restores later.
10. Step 6: Schedule backups
A systemd timer is easier to monitor than cron.
# /etc/systemd/system/pgbackrest-full.service
[Unit]
Description=pgBackRest full backup
After=postgresql.service
[Service]
Type=oneshot
User=postgres
ExecStart=/usr/bin/pgbackrest --stanza=main --type=full backup
# /etc/systemd/system/pgbackrest-full.timer
[Unit]
Description=Weekly pgBackRest full backup
[Timer]
OnCalendar=Sun *-*-* 02:00:00
Persistent=true
RandomizedDelaySec=300
[Install]
WantedBy=timers.target
Create the equivalent pgbackrest-diff.service and .timer with --type=diff and OnCalendar=Mon..Sat *-*-* 02:00:00, then:
sudo systemctl daemon-reload
sudo systemctl enable --now pgbackrest-full.timer pgbackrest-diff.timer
systemctl list-timers 'pgbackrest*'
Check the binary path with command -v pgbackrest. Make sure a failed unit raises an alert (see Prometheus Alertmanager guide for notifications).
11. Step 7: Restore and point-in-time recovery
Practice this before you need it. Ideally restore onto a separate test server.
Restore the latest state
sudo systemctl stop postgresql.service
# Delta restore: reuse files that already match, restore only what differs
sudo -u postgres pgbackrest --stanza=main --delta restore
sudo systemctl start postgresql.service
sudo -u postgres psql -c "SELECT pg_is_in_recovery();"
For a restore into an empty data directory, remove --delta. pgBackRest writes the recovery settings and the recovery.signal file; PostgreSQL replays archived WAL and then opens for connections.
Point-in-time recovery
Scenario: a developer dropped a table at 10:42. Recover to 10:41:00.
sudo systemctl stop postgresql.service
sudo -u postgres pgbackrest --stanza=main --delta \
--type=time "--target=2026-11-24 10:41:00+07" \
--target-action=promote \
restore
sudo systemctl start postgresql.service
sudo journalctl -u postgresql.service -n 40 --no-pager
| Option | Meaning |
|---|---|
--type=time | Recover to a timestamp. Use the server’s time zone or an explicit offset |
--type=lsn / --type=name | Recover to an LSN or a named restore point created with pg_create_restore_point() |
--type=immediate | Stop as soon as the backup is consistent |
--target-action=promote | Open the database read-write once the target is reached |
--set=<label> | Restore from a specific backup set instead of the latest |
Choose the target just before the mistake. If recovery stops too early or too late, restore again with a different target; the repository is unchanged.
After a PITR, take a new full backup so the new timeline is protected.
Restore only part of the cluster
You can restore specific databases with --db-include, and relocate directories with --link-map or --tablespace-map. Use these on a scratch host first.
12. Off-site repositories
Keep more than one copy:
[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
repo2-type=s3
repo2-path=/pgbackrest
repo2-s3-bucket=my-pg-backups
repo2-s3-endpoint=s3.example.com
repo2-s3-region=ap-southeast-3
repo2-s3-key=ACCESS_KEY
repo2-s3-key-secret=SECRET_KEY
repo2-retention-full=4
repo2-cipher-type=aes-256-cbc
repo2-cipher-pass=ANOTHER_LONG_PASSPHRASE
Run backups to a chosen repo with --repo=2, and WAL is pushed to all repositories. Use bucket policies, versioning, and object lock if available, and store credentials in a file readable only by postgres.
Dedicated repository host: for stronger isolation, run the repository on a separate backup server over SSH or TLS, so a compromised database server cannot delete its own backups. This is the recommended design for important systems and is described in the project’s user guide.
For cold, long-term copies, you can export backup sets to tape; see Linear Tape-Open (LTO) Explained.
13. Monitoring and verification
| Check | Command or signal | Frequency |
|---|---|---|
| Stanza health | pgbackrest info shows status: ok | Daily, alert if not |
| Archive working | SELECT * FROM pg_stat_archiver; shows no growing failed_count | Continuously |
| Repository integrity | pgbackrest --stanza=main verify | Weekly |
| Restore test | Restore to a scratch server and run queries | At least monthly |
| Last backup age | Alert if the last full or diff is older than the schedule allows | Continuously |
| Repository free space | Disk usage alert at 80% | Continuously |
sudo -u postgres psql -c "SELECT archived_count, failed_count, last_archived_wal, last_failed_wal FROM pg_stat_archiver;"
sudo -u postgres pgbackrest --stanza=main verify
Export pg_stat_archiver metrics and backup age to your monitoring system. See Prometheus and Grafana on Rocky Linux 10.
14. SELinux and firewall notes
- SELinux:
archive_commandruns inside the PostgreSQL process domain, so the repository and log paths must be writable from that context. If archiving fails with permission errors while file permissions look right, checksudo ausearch -m AVC -ts recentand fix labels as described in the SELinux troubleshooting guide. Prefer a targeted label on the repository directory over a custom policy module. - Remote repository host or TLS server: open only the required port to the database server’s address with a rich rule; see the firewalld guide.
- S3 repositories: allow outbound HTTPS to the endpoint.
15. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
archive_command fails; WAL piles up in pg_wal | pgBackRest error, repo full, wrong stanza | journalctl -u postgresql, /var/log/pgbackrest/; fix and verify with check; watch disk usage of pg_wal |
ERROR: [055]: unable to load info file or stanza not found | Stanza not created or wrong name | stanza-create; confirm --stanza=main in archive_command |
WAL segment ... was not archived before the 60000ms timeout | Archiving slow or failing | Check pg_stat_archiver; raise archive-timeout only after fixing the cause |
backup command requires option: pg1-path | Config not loaded or stanza section missing | Check /etc/pgbackrest/pgbackrest.conf and run as postgres |
unable to find primary cluster - cannot proceed | PostgreSQL stopped, wrong socket or path | Start PostgreSQL; check pg1-path, pg1-socket-path |
permission denied writing to the repository | Directory owner or SELinux | chown postgres:postgres; check ausearch -m AVC |
archive_mode shows off after editing | No restart | Restart PostgreSQL (reload is not enough) |
cipher ... passphrase mismatch / cannot decrypt | Wrong or changed repo1-cipher-pass | Use the original passphrase; the passphrase of an existing repo cannot be changed in place |
database system identifier does not match | Cluster re-created or restored from another server | stanza-upgrade or a new stanza; do not reuse a stanza for a different cluster |
| Backup very slow | Single process, slow disk, or network | Raise process-max, use compress-type=zst, enable block incremental, check I/O |
| Restore: PostgreSQL refuses to start | Data directory not empty (no --delta), wrong permissions | Use --delta or empty the directory; restore as postgres; check postgresql.auto.conf |
| PITR stops at the wrong time | Time zone or target format | Use an explicit offset; inspect logs for “recovery stopping before commit” |
| Disk fills after restore failure | WAL replay needs space | Provision space for WAL; clean up failed attempts |
pgbackrest: command not found in timer | Path differs in systemd | Use the full path from command -v pgbackrest |
| After PostgreSQL major upgrade, backups fail | Stanza tied to the old version | Run pgbackrest stanza-upgrade after upgrading the cluster, then take a new full backup |
16. FAQ
Is pgBackRest still maintained?
Yes. It was announced as unmaintained in April 2026, then a coalition of sponsors funded its continuation in May 2026, and new releases followed.
pgBackRest or pg_dump?
Use both when it makes sense. pgBackRest gives fast physical backups and PITR for production. pg_dump is useful for logical exports, partial restores, and upgrades between major versions.
Does pgBackRest support PostgreSQL 18?
Yes, since release 2.55.0, and later releases add support for newer versions as they appear.
How often should I run backups?
A weekly full and daily differential is a common start, with WAL archived continuously. Tighten it according to your recovery point and recovery time objectives.
Can I back up from a standby?
Yes. pgBackRest can take backups from a standby to reduce load on the primary; see PostgreSQL Streaming Replication on Rocky Linux 10 for the replication setup.
What if I lose the encryption passphrase?
The encrypted repository cannot be read, and there is no recovery. Keep the passphrase in at least two secure places.
Do backups include roles and global objects?
Yes. A physical backup includes the whole cluster, including roles and all databases.
Can I use pgBackRest for n8n or other PostgreSQL-backed apps?
Yes. Any application using PostgreSQL benefits. For application-level export routines, see n8n Backup, Upgrade & Disaster Recovery Strategy.







