Backup & Restore

Back up and restore namespaces and volumes with Velero, PostgreSQL with CloudNativePG including point-in-time recovery, and MongoDB.

The SDP protects your data on two levels: Velero backs up Kubernetes resources and volumes of entire namespaces, while database-native mechanisms back up databases consistently. This page covers both levels and how to restore from them. Provisioning and operating the databases themselves is covered in Databases.

Overview

What Mechanism Target Recovery
Kubernetes resources and volumes Velero (Kopia file-system backup) S3 object storage namespace, individual resources, or volumes
PostgreSQL (CloudNativePG) Barman Cloud Plugin: base backups plus continuous WAL archiving S3 object storage (alternatively Azure Blob Storage) new cluster, point-in-time recovery (PITR)
MongoDB daily logical dump (mongodump) from the mongodb-operator CronJob S3 object storage mongorestore, full or selective
Valkey, ClickHouse, Elasticsearch no dedicated backup mechanism by default; volumes via Velero S3 object storage volume restore or as agreed with ayedo

The platform provides S3 buckets as backup targets (see Storage). Keep backups separate from the cluster they protect.

Kubernetes Resources and Volumes with Velero

Velero backs up a namespace's Kubernetes resources (Deployments, ConfigMaps, Secrets, Services, Ingresses, PVCs) together with the contents of the associated persistent volumes as a Kopia file-system backup.

The Velero block's default configuration runs two schedules:

  • every 12 hours, kept for 72 hours,
  • weekly on Sundays at 02:00, kept for four weeks.

All namespaces are included except system namespaces such as kube-system, velero, or ingress. Data volumes of CloudNativePG clusters are excluded because PostgreSQL is backed up through the Barman Cloud Plugin.

Listing and Creating Backups

If you operate the platform yourself or have the required permissions, use the Velero CLI:

# Existing backups and schedules
velero backup get
velero schedule get

# Extra backup of a namespace, e.g. before a release
velero backup create acme-pre-release \
  --include-namespaces acme-prod \
  --wait

Restoring from Velero Backups

# Restore a whole namespace from a backup
velero restore create --from-backup acme-pre-release \
  --include-namespaces acme-prod

# Restore into a new namespace to inspect the state first
velero restore create --from-backup acme-pre-release \
  --include-namespaces acme-prod \
  --namespace-mappings acme-prod:acme-restore-test

# Check progress
velero restore describe <restore-name>

By default, Velero does not overwrite existing resources. For a full in-place restore, delete the affected resources first or restore into a new namespace. In managed operation, ayedo performs restores on request: contact us with the cluster, namespace, and the point in time you need.

PostgreSQL with CloudNativePG

CloudNativePG backs up PostgreSQL to S3-compatible object storage through the Barman Cloud Plugin (barman-cloud.cloudnative-pg.io). It combines regular physical base backups with continuous archiving of the write-ahead log (WAL), which lets you restore any point in time within the retention window (point-in-time recovery).

In managed operation, ayedo sets up the backups. If you define PostgreSQL clusters yourself, configure backups in three steps.

Setting Up Backups

1. Define the backup target as an ObjectStore:

apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
  name: acme-db-backup-store
  namespace: acme-prod
spec:
  retentionPolicy: "14d"
  configuration:
    destinationPath: s3://acme-db-backups/
    endpointURL: https://s3.example.com
    s3Credentials:
      accessKeyId:
        name: acme-db-s3-credentials
        key: ACCESS_KEY_ID
      secretAccessKey:
        name: acme-db-s3-credentials
        key: ACCESS_SECRET_KEY
    wal:
      compression: gzip

2. Enable WAL archiving in the Cluster:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: acme-db
  namespace: acme-prod
spec:
  instances: 3
  storage:
    size: 50Gi
  plugins:
    - name: barman-cloud.cloudnative-pg.io
      isWALArchiver: true
      parameters:
        barmanObjectName: acme-db-backup-store

3. Schedule base backups:

apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
  name: acme-db-scheduled
  namespace: acme-prod
spec:
  # Six fields, starting with seconds: daily at 02:00
  schedule: "0 0 2 * * *"
  backupOwnerReference: self
  cluster:
    name: acme-db
  method: plugin
  pluginConfiguration:
    name: barman-cloud.cloudnative-pg.io

Checking Backup Status and Triggering On-Demand Backups

kubectl get backup,scheduledbackup,objectstore -n acme-prod
# Shows, among other things, the last successful backup and the WAL archiving status
kubectl describe cluster acme-db -n acme-prod

Before major schema migrations, trigger an additional on-demand backup:

apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
  name: acme-db-pre-migration
  namespace: acme-prod
spec:
  method: plugin
  pluginConfiguration:
    name: barman-cloud.cloudnative-pg.io
  cluster:
    name: acme-db

Restoring and Point-in-Time Recovery

CloudNativePG never restores into the existing cluster. Instead, it bootstraps a new cluster from the backup, leaving the previous state untouched. You verify the restored cluster and then switch your application over, for example by pointing the Secret or connection URL at <new-cluster>-rw.

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: acme-db-restore
  namespace: acme-prod
spec:
  instances: 3
  storage:
    size: 50Gi
  bootstrap:
    recovery:
      source: acme-db-origin
      # Optional: point-in-time recovery
      recoveryTarget:
        targetTime: "2026-11-29T10:30:00Z"
  externalClusters:
    - name: acme-db-origin
      plugin:
        name: barman-cloud.cloudnative-pg.io
        parameters:
          barmanObjectName: acme-db-backup-store
          serverName: acme-db

Without recoveryTarget, CloudNativePG restores the latest available state. Other recoveryTarget options:

Field Meaning
targetTime point in time in RFC 3339 format
targetLSN PostgreSQL log sequence number
targetXID transaction ID
targetName named restore point (created with pg_create_restore_point())
targetImmediate earliest consistent state after the base backup

The same approach lets you clone a production database into a staging environment.

Restoring Individual Tables and Exporting Data

For individual tables, migrations between PostgreSQL major versions, or portable exports, use a logical export. Take it from a restored cluster or from a replica (Service <cluster>-ro):

# Dump in custom format (allows selective restores)
pg_dump -h localhost -U app -d app --format=custom --file=acme-export.dump

# Restore a single table into the target database
pg_restore -h localhost -U app -d app_target \
  --table=orders --clean --if-exists \
  acme-export.dump

Connect to the Service through kubectl port-forward (see Access & Identity).

Inspecting and Restoring Backups Outside the Cluster

For audits or a restore outside the SDP, you need read access to the backup bucket:

  • Managed operation: request time-limited S3 read credentials by contacting us. Include the cluster, namespace, and the name of the PostgreSQL cluster.
  • Self-managed: the reference to the credentials Secret is in the ObjectStore resource (kubectl get objectstore -n acme-prod -o yaml).

Under <destinationPath>/<cluster>/, the bucket contains the directories base/ (base backups) and wals/ (WAL archive):

mc alias set acme-backup https://s3.example.com "$AWS_ACCESS_KEY_ID" "$AWS_SECRET_ACCESS_KEY"
mc ls acme-backup/acme-db-backups/acme-db/base/
mc du acme-backup/acme-db-backups/acme-db/

To restore a physical backup on a host running the same PostgreSQL major version, use the Barman Cloud tools (pipx install "barman[cloud]"):

barman-cloud-restore \
  --cloud-provider aws-s3 \
  --endpoint-url https://s3.example.com \
  s3://acme-db-backups/acme-db \
  <backup-id> \
  /var/lib/postgresql/restore

For point-in-time recovery, then set restore_command in postgresql.auto.conf to barman-cloud-wal-restore (using absolute paths) and create a recovery.signal file.

MongoDB

How MongoDB is backed up

The ayedo/k8s/mongodb-operator block creates a CronJob (<name>-mongodump-s3) that writes a daily logical dump (mongodump) of all databases straight to the configured S3 bucket. Velero is not the primary MongoDB backup path.

# Show the backup CronJob and recent runs
kubectl get cronjob,job -n <mongodb-namespace>

Responsibilities are split as follows:

Task Owner
Backing up the whole instance ayedo in managed operation, as defined in the Service Annex
Restoring individual databases or collections you, unless agreed otherwise
Checking restored data from a business perspective you

Restoring MongoDB

  1. Obtain the dump: Download the dump you need from the backup bucket. In managed operation, ayedo does this on request via the contact page.
  2. Restore the data: With network access to the replica set, replay the dump with mongorestore.
# Restore the whole dump (existing collections are replaced)
mongorestore --uri "$MONGODB_URI" --gzip --archive=/backup/<dump-file> --drop

# Restore a single collection under a new name for review
mongorestore --uri "$MONGODB_URI" --gzip --archive=/backup/<dump-file> \
  --nsInclude "acme.orders" \
  --nsFrom "acme.orders" --nsTo "acme.orders_restored"

Your own dumps for shorter intervals or longer retention

If you need more frequent backups or your own retention, run an additional CronJob that executes mongodump with an application user and uploads the archive to your own S3 bucket:

mongodump --uri "$MONGODB_URI" --readPreference=secondary \
  --gzip --archive=/tmp/acme-$(date +%Y%m%d-%H%M).gz

--readPreference=secondary keeps the dump off the primary.

Valkey, ClickHouse, and Elasticsearch

For these engines, the default installation sets up no dedicated backup mechanism. Velero captures their volumes like any other volume, as long as the namespace is backed up. Such a file-system backup is not transactionally consistent. In managed operation, ayedo agrees backup and recovery for your setup with you. Database-native options:

  • Valkey: Valkey writes its data to an append-only file on the volume. If you use Valkey purely as a cache, you usually don't need a backup because the application rebuilds the data.
  • ClickHouse: the SQL command BACKUP writes tables or databases to an S3 bucket, and RESTORE brings them back.
  • Elasticsearch: snapshots back up indices to an S3 snapshot repository, and Snapshot Lifecycle Management (SLM) schedules them. Test restoring individual indices with sample data.

Restore Tests

A backup is only reliable once you have tested restoring it. Regularly restore into a separate namespace or a staging environment, validate the data, and measure how long the restore takes. Before major migrations or releases, create an additional, named backup.

Further Reading