CNPG B2 Backup Implementation Note
Current Status
I've updated the authentik PostgreSQL cluster as an example of how to add B2 offsite backups to CNPG clusters.
Approach
The configuration uses a dual-backup strategy:
-
Primary WAL Archive: Backblaze B2 (offsite, disaster recovery)
- Real-time WAL shipping to B2
- Compressed and encrypted
- 30-day retention
-
External Clusters: Both B2 and MinIO configured for recovery
- Can restore from either location
- B2 for disaster recovery (site loss)
- MinIO retained for fast local recovery (if available)
-
Velero: Still backs up entire PVCs to both MinIO (daily/weekly) and B2 (weekly)
Remaining Work
The same pattern needs to be applied to the other 5 PostgreSQL clusters:
/home/benjaminsanden/Dokument/Projects/homelab/k8s/applications/media/immich/immich-server/database.yaml/home/benjaminsanden/Dokument/Projects/homelab/k8s/applications/ai/litellm/database.yaml/home/benjaminsanden/Dokument/Projects/homelab/k8s/applications/automation/n8n/database.yaml/home/benjaminsanden/Dokument/Projects/homelab/k8s/applications/ai/bytebot/postgres/database.yaml/home/benjaminsanden/Dokument/Projects/homelab/k8s/applications/web/pinepods/database.yaml
For each file:
- Add ExternalSecret for
b2-cnpg-credentials(same as authentik) - Add
authentik-b2-storeObjectStore resource - Update
pluginssection to point to B2 store - Add
backupsection with barmanObjectStore to B2 - Add
externalClustersfor both B2 and MinIO
Prerequisites
Before applying these changes:
- Complete BACKBLAZE_B2_SETUP.md
- Verify B2 credentials are in Bitwarden
- Test B2 connectivity
- Apply changes during a maintenance window (WAL archive switch can cause brief disruption)
Testing
After applying:
# Verify ObjectStores are created
kubectl get objectstore -A
# Check cluster backup configuration
kubectl -n auth describe cluster authentik-postgresql
# Verify WAL archiving to B2
kubectl -n auth logs -l cnpg.io/cluster=authentik-postgresql -c postgres | grep "wal.*uploaded"
# Force a base backup to B2
kubectl cnpg backup authentik-postgresql -n auth
Recovery Examples
Documented in disaster recovery scenarios (to be created).