CNPG Restore

  1. Flux suspendieren

  2. Cluster löschen

  3. bootstrap.recovery konfigurieren

  4. externalClusters konfigurieren

  5. Recovery durchführen

restore from backup

  • suspend flux kustomization if in gitops

  • delete cluster rexource

  • create new cluster from backup

    • use the “old” cluster definition

    • replace bootstrap.initdb with bootstrap.recovery

    • add externalClusters definition

    • keep the rest

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cnpg-paperless-ngx
spec:
  instances: 1
  imageName: ghcr.io/cloudnative-pg/postgresql:18-standard-trixie
  storage:
    size: 50Gi
  bootstrap:
    recovery:
      source: origin
      database: paperless
      owner: paperless
  externalClusters:
    - name: origin
      plugin:
        name: barman-cloud.cloudnative-pg.io
        parameters:
          barmanObjectName: cnpg-paperless-ngx
          serverName: cnpg-paperless-ngx
  • a full-recovery pod will start and restore the cluster

  • after it finished, restore the cluster definition back to its’ original state

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cnpg-paperless-ngx
spec:
  instances: 1
  imageName: ghcr.io/cloudnative-pg/postgresql:18-standard-trixie
  storage:
    size: 50Gi
  bootstrap:
    initdb:
      database: paperless
      owner: paperless
  plugins:
    - name: barman-cloud.cloudnative-pg.io
      isWALArchiver: true
      parameters:
        barmanObjectName: cnpg-paperless-ngx
  • then you can resume flux again