
kubectl get cluster.postgresql.cnpg.io -n <namespace>
kubectl get backup -n <namespace>



apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: <pgclustername>-restored
spec:
  instances: <instancenumber>

  storage:
    size: <dbstorage>
    storageClass: csi-rbdfs-sc

  walStorage:
    storageClass: csi-rbdfs-sc
    size: <dbstorage>

  bootstrap:
    recovery:
      source: <pgclustername>-origin

    backup:
      name: sporteams-backup-20260718020000        # nome dell'oggetto Backup  da kubectl get backup -n <namespace>
    recoveryTarget:                                # opzionale in assenza applica tutto il journal (wal) a partire dal backup 
      targetTime: "2026-07-18 15:30:00.000000+00"  # timestamp in cui si ferma rebuild dal WAL

  externalClusters:
    - name: <pgclustername>-origin
      barmanObjectStore:
        endpointURL: http://minio.minio.svc.cluster.local:9000
        destinationPath: s3://cnpgbackup2/<pgclustername>
        s3Credentials:
          accessKeyId:
            name: minio-backup-creds
            key: ACCESS_KEY_ID
          secretAccessKey:
            name: minio-backup-creds
            key: ACCESS_SECRET_KEY
        wal:
          compression: gzip
          maxParallel: 2
        data:
          compression: gzip
          immediateCheckpoint: false
          jobs: 2

  # Dopo il restore, il cluster ripristinato può avere un backup indipendente:
  backup:
    barmanObjectStore:
      endpointURL: http://minio.minio.svc.cluster.local:9000
      destinationPath: s3://cnpgbackup2/<pgclustername>-restored
      s3Credentials:
        accessKeyId:
          name: minio-backup-creds
          key: ACCESS_KEY_ID
        secretAccessKey:
          name: minio-backup-creds
          key: ACCESS_SECRET_KEY
      wal:
        compression: gzip
        maxParallel: 2
      data:
        compression: gzip
        immediateCheckpoint: false
        jobs: 2
    retentionPolicy: "30d"

  postgresql:
    parameters:
      max_connections: "300"
      shared_buffers: "1GB"

  resources:
    requests:
      cpu: "500m"
      memory: "1Gi"
    limits:
      cpu: "2"
      memory: "2Gi"
	  
	  
### Utility varie ##########
kubectl get cluster.postgresql.cnpg.io -n stsharedservices-dev
kubectl -n minio exec -it minio-0 -- sh
mc alias set local http://localhost:9000 minioadmin KAYQE1QA7uwUZ8uI
mc ls local cnpgbackup2
