Brume · Docs
Maintenance

Back up & restore

One store to back up, point-in-time recovery: the exact procedure, from scheduled backup to PITR.

In brief

Back up the PostgreSQL database to your S3 storage, verify every run, then use PITR to return to a specific point in time. The procedure covers configuration, immediate backup, restore, and application switch-over.

One store to back up

PostgreSQL is the only stateful component. Everything else (frontend, backend, real-time relay, worker) is stateless and redeploys from images. Four families of data live in this single database:

DataTable / extensionConsequence
Application datapublic tablesAccounts, workspaces, files, conversations.
Processing queueprocrastinate_* tablesIn-progress indexing jobs are restored with their state.
Conversation event logconv_eventsMessage replay remains intact after restore.
Agent checkpointsLangGraph tablesAn interrupted execution can resume where it stopped.

A PostgreSQL restore returns all this data to the same point in time. See the single-store architecture.

Where backups go

CloudNativePG (CNPG) continuously archives WAL and pushes base backups to your S3 object storage.

In commands, replace <namespace> with your namespace; the example value used by the chart by default is misty. <instance> is global.instanceName, or the Helm release name when that value is empty.

ParameterValue
Destinations3://<your-bucket>/cnpg/<instance>-pg
S3 endpointhttps://<your-s3-endpoint>
K8s secret for credentialscnpg-barman-s3 (namespace <namespace>)
Secret fieldsACCESS_KEY_ID, ACCESS_SECRET_KEY
WAL compressiongzip
Retention30 days

Configuration is driven by the pg.backup.* Helm values of the brume-chart chart:

pg:
  backup:
    enabled: true
    s3Path: "s3://<your-bucket>/cnpg/<instance>-pg"
    s3Endpoint: "https://<your-s3-endpoint>"
    s3SecretName: cnpg-barman-s3
    s3AccessKeyField: ACCESS_KEY_ID
    s3SecretKeyField: ACCESS_SECRET_KEY
    retentionPolicy: "30d"
    # CNPG ScheduledBackup: 6-field cron (sec min hour day month weekday)
    schedule: "0 0 */4 * * *"

Backups encrypted in transit

Transit to S3 uses HTTPS. Validate at-rest encryption with your object storage provider. S3 credentials live in the cnpg-barman-s3 K8s secret, never in the chart or repository.

Scheduled backup

CNPG creates a ScheduledBackup object from the pg.backup.schedule key. CNPG cron has six fields (second, minute, hour, day of month, month, day of week): 0 0 */4 * * * triggers a base backup every four hours. Between two base backups, continuous WAL archiving covers the interval, which enables point-in-time recovery (see below).

Freeze cadence at deployment

The configured cadence lives in pg.backup.schedule. Confirm the selected value for the instance before production: it determines base backup granularity and WAL replay duration in case of restore.

Trigger an immediate backup

Before an upgrade or sensitive operation, force an unscheduled base backup.

With the CNPG plugin

Use the CNPG plugin if it is installed.

kubectl cnpg backup <instance>-pg -n <namespace>

Expected result: CNPG creates a backup for the <instance>-pg cluster.

Or by manifest

Without the plugin, create a Backup object directly.

kubectl apply -f - <<EOF
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
  name: <instance>-pg-manual-$(date +%s)
  namespace: <namespace>
spec:
  cluster:
    name: <instance>-pg
EOF

Expected result: Kubernetes accepts the manifest and CNPG starts the backup.

The same operation is available from the operations console (Tower): on the PostgreSQL record, "Backup now".

List backups

List the CNPG objects before any restore.

kubectl get backups -n <namespace>

Expected result: the output gives the name, phase (completed, running, failed), and timestamp; a recent backup is completed.

Restore to a specific point in time (PITR)

The restore does not touch the current cluster. It creates a new PostgreSQL cluster from the S3 backups, rebuilds up to the requested timestamp by replaying WAL, then the application is switched to it once consistency has been verified.

Choose the restore point

Set the target timestamp in UTC, within the 30-day retention window.

RESTORE_TARGET="<horodatage-UTC>"

Expected result: RESTORE_TARGET contains an ISO 8601 instant, for example 2026-04-04T14:30:00Z.

Create the restore cluster

Create a new cluster without modifying the current cluster.

kubectl apply -f - <<EOF
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: <instance>-pg-restored
  namespace: <namespace>
spec:
  instances: 1
  bootstrap:
    recovery:
      source: <instance>-pg
      recoveryTarget:
        targetTime: "${RESTORE_TARGET}"
  externalClusters:
    - name: <instance>-pg
      barmanObjectStore:
        destinationPath: s3://<your-bucket>/cnpg/<instance>-pg
        endpointURL: https://<your-s3-endpoint>
        s3Credentials:
          accessKeyId: { name: cnpg-barman-s3, key: ACCESS_KEY_ID }
          secretAccessKey: { name: cnpg-barman-s3, key: ACCESS_SECRET_KEY }
EOF

Expected result: CNPG downloads the latest backup before targetTime, then replays WAL up to that point.

Verify the restore

Check the new cluster state before any switch-over.

kubectl get cluster <instance>-pg-restored -n <namespace>
kubectl cnpg status <instance>-pg-restored -n <namespace>

Expected result: the command displays Cluster in healthy state. Inspect the restored data before switching traffic.

Switch the application

Edit the application resource that provides DATABASE_URL, then point it to the restored cluster service.

kubectl edit <ressource-applicative> -n <namespace>

Expected result: the application uses the restored cluster; the procrastinate_* tables, conv_events, and agent checkpoints have the same state as the application data.

Recovery objectives

IndicatorValueMechanism
RTO (recovery time)<your-RTO>Switch-over defined by your deployment topology.
RPO (maximum data loss)A few secondsAsynchronous replication between the two PostgreSQL instances.

Validate the RTO with an exercise on your topology. PITR restore responds to logical corruption or accidental deletion.

RPO=0 with synchronous replication

Synchronous replication between PostgreSQL instances brings RPO to zero, at the cost of higher write latency. It is a cluster configuration option, to enable according to the instance requirement.

To analyze failure points and adapt redundancy to your deployment, see Architecture. The upgrade process, which relies on an immediate backup before helm upgrade, is covered in Upgrade.

Final checklist

  • The pg.backup.* values target your S3 bucket and endpoint.
  • A recent backup appears in the completed phase.
  • The restored cluster reaches Cluster in healthy state.
  • Data is checked before switching DATABASE_URL.

On this page