Configure pgBackRest retention and run expire
PostgreSQLBackup & PITRCommand
# /etc/pgbackrest/pgbackrest.conf [global] - count based:
repo1-retention-full-type=count
repo1-retention-full=2
repo1-retention-diff=6
# Time-based alternative (at least a 14-day PITR window):
# repo1-retention-full-type=time
# repo1-retention-full=14
# Expire runs automatically after each backup; to trigger it manually:
sudo -u postgres pgbackrest --stanza=<stanza> --log-level-console=info expireWhat it does
Defines how many full/diff backups (count) or how many days of full backups (time) to keep; expire deletes backups outside the policy, the diff/incr backups depending on them, and WAL archive no longer needed.
When to use it
To keep repository size under control and guarantee the RPO/PITR window requirement (e.g. being able to go back 14 days).
Caution
The PITR window is bounded by the oldest retained full backup; with weekly fulls and retention-full=2, you can go back at most about 2 weeks. repo1-retention-archive follows full retention by default; setting it lower leaves older backups usable only up to their consistency point. Expire cannot be undone.
Related
- Configure WAL archiving for pgBackRest (archive-push/archive-get)
- Create the pgBackRest stanza and verify archiving (stanza-create/check)
- Take full, differential and incremental backups with pgBackRest
- Show the pgBackRest backup catalog and WAL archive range (info)
- Restore the latest backup with pgBackRest
- Restore to a point in time with pgBackRest (PITR, --type=time)