Brume · Docs
Maintenance

Clone an instance

Create a fresh instance from another's backups: the chart's recovery bootstrap, role alignment, guard rails — a full-scale restore test.

In brief

The chart can initialize a new instance's PostgreSQL from another instance's S3 backups (pg.recovery.*) instead of an empty database. It is the standard way to stand up a staging environment with production data — and to prove, along the way, that your backups actually restore.

This page assumes backups are in place on the source instance — see Backup & restore. To go back to a precise instant on the same instance, use PITR; cloning creates a separate instance, with its own namespace, secrets and domains.

In the commands, <source> is the origin instance and <clone> the new one; each maps to its global.instanceName (or its Helm release name when that value is empty).

What the clone carries — and what it does not

The restore is complete and as-is: accounts, workspaces, conversations, PostgreSQL roles and their passwords — the source's. Two consequences to plan for:

  • Object storage is not cloned. The database references files living in the source's S3. Give the clone its own bucket (never the source's: the clone would write to it) and sync the content if you need it, for instance with a read-only rclone copy from the source side.
  • The version gap resolves itself. If the clone starts on a newer version than the source, the missing migrations apply on the backend's first boot, as in a regular upgrade.

Provision the clone's secrets

As for any instance: <clone>-pg-app, <clone>-pg-superuser, <clone>-backend-env, the image pull secret — plus, in the clone's namespace, the S3 secret of the source's backups (the same keys as its cnpg-barman-s3; read access is enough).

Install the clone with the recovery bootstrap

In the clone's values, point pg.recovery at the source's barman archive:

pg:
  recovery:
    enabled: true
    # CNPG name of the source cluster (= "<source>-pg")
    sourceName: <source>-pg
    s3Path: s3://<your-bucket>/cnpg/<source>-pg
    s3Endpoint: https://<your-s3-endpoint>
    s3SecretName: cnpg-barman-s3

Then install normally (helm upgrade --install <clone> …). CNPG downloads the latest base backup, replays WAL up to the most recent point, and the clone's cluster starts with the source's data.

Expected result: kubectl get cluster <clone>-pg -n <namespace> shows Cluster in healthy state.

The bootstrap runs once — and never toward the source's archive

pg.recovery only applies on the cluster's first startup; once created, CNPG ignores it. And if you enable pg.backup on the clone, its s3Path must never point at the source's archive — it would overwrite its WAL.

Align the application role

The restored database belongs to the source's role. Grant the clone's role rights over those objects:

kubectl exec -n <namespace> <clone>-pg-1 -c postgres -- \
  psql -U postgres -d brume -c 'GRANT "<source>" TO "<clone>";'

Expected result: GRANT ROLE. The clone's backend then connects with its own, unchanged secrets.

Verify

The usual installation checks: healthy pods, migrations applied at backend boot, HTTP probes on the clone's domains, login with an account from the source.

On this page