Backup & Restore
Pigsty uses pgBackRest for PostgreSQL backups. It supports full, differential, and incremental backups, parallel processing, encryption, and Silo/S3 object storage. Every PGSQL cluster is configured for backup and WAL archiving by default.
This chapter is the operational manual for backup configuration, management, recovery, and drills. For design concepts and tradeoffs, see Point-in-Time Recovery.
All backup and recovery operations ultimately invoke pgBackRest. Pigsty provides several wrapper layers:
| Layer | Interface | Form | Scope |
|---|---|---|---|
| Cluster orchestration | pg_pitr + pgsql-pitr.yml |
Ansible playbook | HA, etcd, and multi-node recovery |
| Instance orchestration | pig pitr |
CLI | Local-node recovery without the admin node |
| Command primitives | pig pb, pb, and pg-backup |
pgBackRest wrappers | Backup, inspection, expiry, and unmanaged restore |
| Engine | pgbackrest |
Native CLI | Underlying backup, archive, and restore engine |
| Section | Content |
|---|---|
| Mechanism | Stanzas, repositories, retention, timelines, and Pigsty wrapper mapping |
| Policy | Scheduling, recovery windows, and storage planning |
| Repository | Local, Silo, and external S3 repositories; encryption, versioning, and locking |
| Administration | Backup commands, inspection, expiration, and stanza management |
| Restore | Recovery targets, staged PITR, and complete parameter reference |
| Clone | Restore production history into another cluster and perform drills |
| Tutorial | A sandbox restore using pgBackRest primitives |
Pigsty makes every effort to provide a reliable PITR solution, but accepts no liability for data loss caused by restore operations. If you need assistance, consider professional services.
Before PITR, inspect pig pg list <target-cluster> and pig pb info, verify a recent usable backup and recovery window,
have the operator state the exact target cluster and recovery point, then run the target-scoped ./pgsql-pitr.yml -l <target-cluster> ... command.
pgsql-pitr.yml prints a plan but does not pause for approval. Production recovery also requires a maintenance window and an independently verified backup.
Quick Start
- Design a backup policy: declare scheduled backups in
pg_crontaband select a repository withpgbackrest_repo. - Manage backups: run
pg-backupand inspect recovery coverage withpb info. - Perform recovery: declare
pg_pitr, then runpgsql-pitr.yml.
Design backup policies according to your needs
Perform PITR with pgsql-pitr.yml, pig pitr, or pig pb restore; select targets, run stages, and verify the result.
Restore one cluster’s historical state into another for data recovery, restore drills, and forensic inspection.
pgBackRest concepts—stanzas, repositories, backup chains, retention, and timelines—and how Pigsty maps parameters to commands.
Configure local, Silo, and external S3 backup repositories, including retention, encryption, versioning, and Object Lock.
Backup administration reference covering setup and removal, manual backups, inspection, expiration, stanza management, logs, and alternative tools.