DBAtlas · Database operations atlas

Take full, differential and incremental backups with pgBackRest

PostgreSQLBackup & PITR

Command

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 backup

What 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).

Open in DBAtlas →

Related