Skip to content

Backup and restore

Helm with CloudNativePG (continuous)

The chart creates the CloudNativePG Cluster with continuous WAL archiving to S3 and a daily base backup (ScheduledBackup, backup.schedule, retention backup.retention). archive_timeout = 60s closes a WAL segment at least every minute, so the data at risk is bounded by about a minute even on an idle database.

Value Default
backup.method plugin Barman Cloud plugin (ObjectStore resource); inTree uses barmanObjectStore (removed in CNPG 1.31)
backup.destinationPath s3://extractit-backups/pg bucket and prefix; each cluster writes under its serverName
backup.endpoint — S3 endpoint for non-AWS stores (SeaweedFS, Ceph RGW)
backup.existingSecret — Secret with ACCESS_KEY_ID and ACCESS_SECRET_KEY (empty: IAM role)
backup.schedule / retention 0 0 2 * * * / 30d daily base backup, recovery window

The CloudNativePG operator version is pinned in the tests (1.30.1); the backup method changes between versions, so read its release notes before upgrading the operator.

Point-in-time restore

A restore creates a new cluster from the backup store and must archive under a new server name:

helm upgrade extractit <chart> -n extractit --reuse-values \
  --set postgresql.cnpg.recovery.enabled=true \
  --set postgresql.cnpg.recovery.serverName=extractit-pg \
  --set postgresql.cnpg.recovery.targetTime=2026-11-12T10:00:00Z \
  --set postgresql.cnpg.serverName=extractit-pg-r1
kubectl -n extractit wait --for=condition=Ready cluster/extractit-pg --timeout=1h
kubectl -n extractit rollout restart deploy extractit-api extractit-worker

Without targetTime the cluster recovers to the end of the archived WAL. If the backup store is unreachable the recovery pod fails and the cluster stays not Ready; nothing is overwritten. Afterwards, replay the certified deletions made after the restored instant (T50): extractit admin erasure replay --org <id> (see deletion certificates). The master key (<release>-kek) and the documents in S3 are not part of the database backup: back up the Secret separately and keep S3 versioning on.

Measured RPO and RTO

deploy/tests/restore_test.sh (kind, CloudNativePG 1.30.1, PostgreSQL 16.13, SeaweedFS as S3, in-tree Barman): load ≥ 1 GB, base backup, one marker row per second, delete the cluster and its volumes, restore, application smoke test. RPO = last marker written − last marker restored; RTO = restore request → database Ready + API smoke test passing.

Date Environment Data RPO measured RTO measured Target Log
pending kind (laptop, 1 instance) ≥ 1 GB — — RPO ≤ 60 s (SLO 15 min), RTO ≤ 15 min restore_test.sh log
not run staging ≥ 5 GB — — RTO ≤ 60 min —

The RTO grows with the data size and the S3 throughput of your store; measure it on yours.

Docker Compose (logical, no RPO guarantee)

deploy/compose/backup.sh takes a pg_dump (custom format), an archive of the key volume (master key, governance keys) and, with documents on the local volume, an archive of the documents, plus checksums; with DX_BACKUP_S3_URI it copies them to S3. Schedule it daily:

15 2 * * * /opt/extractit/deploy/compose/backup.sh --env-file /opt/extractit/deploy/compose/.env.production

There is no recovery-point guarantee: everything written after the last dump is lost when the volumes are. Keep the key archive apart from the dump. Restore (stops API, worker and web; the preflight refuses a dump from a newer release):

deploy/compose/restore.sh --env-file deploy/compose/.env.production --stamp 20261112T021500Z