CrunchyData / postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
https://access.crunchydata.com/documentation/postgres-operator/v5/
Apache License 2.0
3.96k stars 594 forks source link

Restored backup from s3 bucket is keep promoting the cluster to recovery mode. #3644

Open amitabhajana opened 1 year ago

amitabhajana commented 1 year ago

Hi,

I have a high availablility postgresql cluster with 2 replicas. the daily pgbackrest backup is scheduled at a S3 bucket. But when i'm trying to restore the the backup from the s3 bucjet i can see the postgresql cluster is keep promoting into standby recovery mode. Then I've check the backed up data at the S3 bucket , there i can see the daily backup size is 2GB . But i have only 1 databas whose size is 800 MB . Then I've checked the pgbackrest configmap and found the the cluster is taking backup from primary and secondary pods. Is there any way to configure the backup from primary pod only in HA mode of PGO cluster ??

amitabhajana commented 1 year ago

This is my cluster manifest

apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
  name: hippo-ha
spec:
  image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:ubi8-15.2-0
  postgresVersion: 15
  instances:
    - name: pgha1
      replicas: 2
      dataVolumeClaimSpec:
        accessModes:
        - "ReadWriteOnce"
        resources:
          requests:
            storage: 10Gi
      resources:
        limits:
          cpu: 2.0
          memory: 4Gi
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            podAffinityTerm:
              topologyKey: kubernetes.io/hostname
              labelSelector:
                matchLabels:
                  postgres-operator.crunchydata.com/cluster: hippo-ha
                  postgres-operator.crunchydata.com/instance-set: pgha1
  patroni:
    dynamicConfiguration:
      postgresql:
        pg_hba:
          - "host all all 0.0.0.0/0 md5"
        parameters:
          listen_addresses: '*'
          archive_timeout: 60
          password_encryption: md5
          shared_preload_libraries: 'timescaledb'
  users:
    - databases:
      - hippodb
      name: hippo_db_user
      options: "SUPERUSER CREATEDB CREATEROLE REPLICATION BYPASSRLS"

  backups:
    pgbackrest:
      image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:ubi8-2.41-4
      configuration:
      - secret:
          name: hippo-pgo-s3
      global:
        repo1-path: /pgbackrest/postgres-operator/hippo-pgo/repo1
        repo1-s3-uri-style: path
        repo1-retention-full: "14"
        repo1-retention-full-type: "count"                
      manual:
        repoName: repo1
        options:
        - --type=full
      repos:
      - name: repo1
        schedules:
          full: '0 1 * * *'
          incremental: "0 */4 * * *"
        s3:
          bucket: "myhippohadb"
          endpoint: "s3.amazonaws.com"
          region: "eu-central-1"