--- # yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/helm.toolkit.fluxcd.io/helmrelease_v2beta2.json apiVersion: helm.toolkit.fluxcd.io/v2beta2 kind: HelmRelease metadata: name: cloudnative-pg-postgres16-pgdump namespace: default spec: interval: 30m chart: spec: chart: app-template version: 2.5.0 sourceRef: kind: HelmRepository name: bjw-s namespace: flux-system maxHistory: 2 install: createNamespace: true remediation: retries: 3 upgrade: cleanupOnFail: true remediation: retries: 3 uninstall: keepHistory: false values: controllers: main: type: cronjob cronjob: concurrencyPolicy: Forbid schedule: "@daily" initContainers: init-db: image: repository: ghcr.io/onedr0p/postgres-init tag: 16 env: EXCLUDE_DBS: "app home_assistant lidarr_log radarr_log sonarr_log prowlarr_log postgres template0 template1" envFrom: &envFrom - secretRef: name: cloudnative-pg-postgres16-pgdump-secret command: - "/bin/bash" - "-c" - | #!/bin/bash set -o nounset set -o errexit # File to store the list of databases OUTPUT_FILE="/config/db_list" # Export PG password to avoid password prompt export PGPASSWORD=$POSTGRES_PASSWORD # Generate a regex pattern for exclusion EXCLUDE_PATTERN=$(echo $EXCLUDE_DBS | sed 's/ /\\|/g') # List all databases, exclude the ones in EXCLUDE_DBS, and write to the file psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U $POSTGRES_USER -lqt | \ cut -d \| -f 1 | \ grep -Ev "^\s*($EXCLUDE_PATTERN)\s*$" > "$OUTPUT_FILE" # Unset PG password unset PGPASSWORD echo "Database list saved to $OUTPUT_FILE" cat $OUTPUT_FILE containers: main: image: repository: prodrigestivill/postgres-backup-local tag: 16-alpine command: ["/backup.sh"] env: POSTGRES_DB_FILE: /config/db_list POSTGRES_EXTRA_OPTS: "-Z9 --schema=public --blobs" BACKUP_KEEP_DAYS: "7" BACKUP_KEEP_WEEKS: "4" BACKUP_KEEP_MONTHS: "3" HEALTHCHECK_PORT: "8080" envFrom: *envFrom service: main: enabled: false persistence: config: enabled: true type: emptyDir globalMounts: - path: /config backups: enabled: true type: nfs server: "192.168.9.10" path: /mnt/storage/backups/postgresql globalMounts: - path: /backups