[REVISIT] Reliable PostgreSQL Backups & DR with CloudNativePG and Cloudflare R2
🚀 Overview
Re-implement the database backup strategy using CloudNativePG (CNPG) and Cloudflare R2. The goal is to move away from unreliable volume-based backups and adopt a declarative, WAL-archiving approach that allows for Point-in-Time Recovery (PITR).
🎯 Goals
🏗️ The "Restore" Logic (The Missing Piece)
When a disaster occurs:
- We do not run
pg_restore.
- We create a new
Cluster manifest.
- We define the dead cluster as an
externalCluster.
- We set
bootstrap.recovery.source to the name of that external cluster.
📋 Implementation Task List
Phase 1: R2 Bucket & Credentials
Phase 2: Cluster Configuration
Phase 3: The Disaster Recovery Guide
- [ ] Create docs/dr-postgres.md with a template for bootstrapping a new cluster from the R2 bucket.
- [ ] Perform a "live" test: Create a dummy DB, wait for a backup, delete the cluster, and restore it as dummy-db-v2.
📚 References
Official CNPG Backup & Recovery Docs
Bootstrap from Backup (Recovery)
Cloudflare R2 S3 Compatibility
Notes: Cloudflare R2 is ideal because it has zero egress fees, making frequent recovery tests free of charge.
[REVISIT] Reliable PostgreSQL Backups & DR with CloudNativePG and Cloudflare R2
🚀 Overview
Re-implement the database backup strategy using CloudNativePG (CNPG) and Cloudflare R2. The goal is to move away from unreliable volume-based backups and adopt a declarative, WAL-archiving approach that allows for Point-in-Time Recovery (PITR).
🎯 Goals
databasenamespace.🏗️ The "Restore" Logic (The Missing Piece)
When a disaster occurs:
pg_restore.Clustermanifest.externalCluster.bootstrap.recovery.sourceto the name of that external cluster.📋 Implementation Task List
Phase 1: R2 Bucket & Credentials
homeops-postgres-backups).Object Read & Writepermissions.r2-backups-credscontainingACCESS_KEY_IDandACCESS_SECRET_KEY.Phase 2: Cluster Configuration
Clustermanifests to include thebackupblock:Phase 3: The Disaster Recovery Guide
📚 References
Official CNPG Backup & Recovery Docs
Bootstrap from Backup (Recovery)
Cloudflare R2 S3 Compatibility
Notes: Cloudflare R2 is ideal because it has zero egress fees, making frequent recovery tests free of charge.