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.

  1. Primary copy: Your production database
  2. Local backup: pgBackRest on local storage
  3. 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=30

Implementing 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 backup

Disaster Recovery

Creating a DR Runbook

Document your disaster recovery procedures:

  1. Identify critical systems and their RPO/RTO requirements
  2. Document restore procedures with exact commands
  3. Test quarterly with full restore drills
  4. 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.

Ready to protect your PostgreSQL data?