Restore to a point in time with pgBackRest (PITR, --type=time)
PostgreSQLBackup & PITRCommand
sudo systemctl stop postgresql-16
sudo -u postgres pgbackrest --stanza=<stanza> --delta --type=time "--target=2026-10-08 14:30:00+03" --target-action=pause restore
sudo systemctl start postgresql-16
# Recovery stops at the target (read-only); validate the data:
psql -X -c "SELECT pg_is_in_recovery(), pg_last_xact_replay_timestamp();"
# If correct, end recovery and open read-write on a new timeline:
psql -X -c "SELECT pg_wal_replay_resume();"What it does
Restores a backup that finished before the target time and replays WAL only up to the target; target-action=pause stops at the target so you can validate the data, and pg_wal_replay_resume() promotes.
When to use it
To return to the moment just before a logical error such as an accidental DELETE/DROP/UPDATE.
Caution
All changes after the target are lost on this cluster; where possible, run PITR on a separate server and move back only the affected data with pg_dump. State the time zone explicitly in the target. pgBackRest 2.24+ selects a suitable backup before the target automatically; on older releases specify a backup that finished before the target with --set. If the target is earlier than the backup's stop time, the restore cannot reach consistency.
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
- Quickly rebuild a standby with pgBackRest delta restore