Guides & Tutorials
Step-by-step tutorials for common backup scenarios and advanced configurations.
Backup Strategies
Setting Up the 3-2-1 Backup Rule
The 3-2-1 rule is a backup best practice: 3 copies of data, on 2 different media, with 1 copy offsite.
- Primary copy: Your production database
- Local backup: pgBackRest on local storage
- Remote backup: Replicate to cloud storage (S3, Azure Blob)
# pgbackrest.conf
[main]
pg1-path=/var/lib/postgresql/14/main
[global]
repo1-path=/backup/local
repo1-retention-full=7
repo2-type=s3
repo2-s3-bucket=my-backups
repo2-s3-region=us-east-1
repo2-retention-full=30Implementing Point-in-Time Recovery (PITR)
PITR allows you to restore your database to any specific moment in time.
Performance Optimization
Parallel Backup Processing
Speed up large database backups using parallel processing:
pgbackrest --stanza=main --type=full \
--process-max=4 backupDisaster Recovery
Creating a DR Runbook
Document your disaster recovery procedures:
- Identify critical systems and their RPO/RTO requirements
- Document restore procedures with exact commands
- Test quarterly with full restore drills
- Maintain contact list for emergency escalation
Security Best Practices
Encrypting Backups
Protect sensitive data with encryption:
# pgbackrest.conf
[global]
repo1-cipher-type=aes-256-cbc
repo1-cipher-pass=<your-encryption-key>💡 Pro Tip
Always test your restore procedures before you need them. Schedule quarterly DR drills to ensure your team knows the process and your backups are reliable.