Take full, differential and incremental backups with pgBackRest
PostgreSQLBackup & PITRCommand
sudo -u postgres pgbackrest --stanza=<stanza> --type=full backup
sudo -u postgres pgbackrest --stanza=<stanza> --type=diff backup # changes since the last full
sudo -u postgres pgbackrest --stanza=<stanza> --type=incr backup # changes since the last backup of any type
# cron example (postgres user): full on Sunday, diff on other days
# 30 1 * * 0 pgbackrest --stanza=<stanza> --type=full backup
# 30 1 * * 1-6 pgbackrest --stanza=<stanza> --type=diff backupWhat it does
A full backup copies the whole cluster, diff copies files changed since the last full, incr copies files changed since the last backup of any type; at the end the required WAL is verified as archived and expire runs automatically according to retention.
When to use it
In a regular backup schedule: typically weekly full + daily diff/incr, more frequent incr on large clusters.
Caution
Without a prior full, diff/incr requests are automatically promoted to full. A longer incr chain increases restore time and dependency; losing one backup in the chain makes later ones unusable. To offload the primary, back up from a standby with backup-standby=y (the primary is still needed for coordination).
Related
- Configure WAL archiving for pgBackRest (archive-push/archive-get)
- Create the pgBackRest stanza and verify archiving (stanza-create/check)
- 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)
- Quickly rebuild a standby with pgBackRest delta restore