CNPG backup: the whole homelab-pg cluster
homelab-pg (ns cnpg-database) holds the databases app (wordsworth),
keycloak and seaweedfs (the SeaweedFS filer metadata). Until 2026-11-08 it
had no spec.backup at all: only the document_keys table was dumped
(key backups).
What runs
- WAL archiving, continuous, through barman-cloud (
spec.backupincluster-config/infra/cnpg-database/cluster.yaml). - A base backup every day at 03:37 UTC (
scheduledbackup.yaml), after the key backups at 03:17 and 03:27. - Retention 30 days (
retentionPolicy: "30d"); CNPG deletes older base backups and the WAL they no longer need.
Target: the SeaweedFS bucket homelab-pg-backups, replication 001 (each
file on two data nodes), set when the bucket was made:
lock
s3.bucket.create -name homelab-pg-backups
fs.configure -locationPrefix=/buckets/homelab-pg-backups/ -replication=001 -apply
unlock
Mechanism: CNPG's in-tree barmanObjectStore. CNPG 1.29.1 still supports it
and the -system- PostgreSQL image carries barman-cloud 3.19.1. It is removed
in CloudNativePG 1.30.0 (the operator warns on every apply): do not upgrade
the operator to 1.30 before moving to the Barman Cloud plugin.
Secret (out of band, never in git)
homelab-pg-backup-s3 in cnpg-database, keys ACCESS_KEY_ID and
ACCESS_SECRET_KEY: the same SeaweedFS S3 identity as wordsworth-s3. To
recreate it from jumpy (nothing is printed):
AK=$(kubectl -n wordsworth get secret wordsworth-s3 -o jsonpath='{.data.WORDSWORTH_S3_ACCESS_KEY}' | base64 -d)
SK=$(kubectl -n wordsworth get secret wordsworth-s3 -o jsonpath='{.data.WORDSWORTH_S3_SECRET_KEY}' | base64 -d)
kubectl -n cnpg-database create secret generic homelab-pg-backup-s3 \
--from-literal=ACCESS_KEY_ID="$AK" --from-literal=ACCESS_SECRET_KEY="$SK"
Check that it works
kubectl -n cnpg-database get cluster homelab-pg \
-o jsonpath='{.status.conditions[?(@.type=="ContinuousArchiving")].status}{"\n"}{.status.firstRecoverabilityPoint}{"\n"}{.status.lastSuccessfulBackup}{"\n"}'
kubectl -n cnpg-database get backups
ContinuousArchiving must be True, and the last backup completed.
An extra backup on demand:
kubectl -n cnpg-database apply -f - <<'EOF'
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: homelab-pg-ondemand-YYYYMMDD
namespace: cnpg-database
spec:
method: barmanObjectStore
cluster:
name: homelab-pg
EOF
Restore test (throwaway namespace)
- Copy the secret into a throwaway namespace (
cnpg-restore-test). - Create a Cluster there with
bootstrap.recovery.sourcepointing at anexternalClustersentry with the samebarmanObjectStoreandserverName: homelab-pg. Use one instance, nospec.backup(a test cluster must never archive into the production path), and a small PVC. - Compare per database: the table count, and
count(*)per table inapp, against the live cluster. - Delete the namespace.
First base backup after enabling archiving: wait until a WAL file has
really reached the bucket (fs.ls /buckets/homelab-pg-backups/homelab-pg/wals/)
before the first backup. On 2026-11-08 the first on-demand backup started at
WAL …D9, which had still been "archived" by CNPG's no-op archiver before
spec.backup took effect. That backup cannot be restored ("WAL not found");
the second one, started at …DC, can. Retention removes the broken one after
30 days.
Result 2026-11-08
| Step | Result |
|---|---|
| WAL archiving | ContinuousArchiving=True; WAL …DA onwards in the bucket |
on-demand backup 20261108T093406 | completed in 11 s, WAL …DC–…DD |
recovery into cnpg-restore-test (1 instance, 2Gi) | ready in 41 s |
app | 17 tables, 90,233 rows, identical per table (incl. audit_records 8,767, document_keys 0) |
keycloak | 89 tables, 2 users, same as live |
seaweedfs | 5 tables; filemeta 44 vs 45 live: the newest backup object, written after the last archived WAL |
The throwaway namespace was deleted afterwards.
Restore for real
Restore into a new cluster name (for example homelab-pg-r1), never over
the existing one:
- Pause ArgoCD auto-sync for
cnpg-database,seaweedfsandwordsworth, and scalewordsworth-apito 0. - Apply a Cluster
homelab-pg-r1withbootstrap.recoveryfromhomelab-pginhomelab-pg-backups(addrecoveryTarget.targetTimefor a point in time). Keep the samemanaged.rolesand the same image. - When it is healthy: point the consumers at it (the
-rwservice name in the wordsworth, keycloak and seaweedfs filer configs, through a GitOps PR), or rename in git sohomelab-pgis the restored one. Give the new cluster its ownspec.backupwith a newserverName, so it doesn't write into the old backup's path. - Resume, then check
/health, the S3 probe and Keycloak login.
Not covered
- A circle: the SeaweedFS filer keeps its metadata in this same cluster.
Lose
homelab-pgcompletely and the filer can no longer map thehomelab-pg-backupskeys to chunks. The chunks are still on the volume servers, but you first need the filer metadata back: anfs.meta.savesnapshot (see the HA migration) or a filer rebuilt from the volumes. The backup protects well against a lost instance, a lost node, a dropped table or a bad migration; against a total cluster loss it needs an off-cluster copy, the open gap already listed in key backups.