Commit d1ba873b authored by Jonathan S. Katz's avatar Jonathan S. Katz Committed by Jonathan S. Katz
Browse files

Add support for multi-repo backups

This starts with an example for setting up multiple backup repos
for both a local Kubernetes volume and S3.
parent 4996a02f
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
{{/* Allow for S3 secret information to be stored in a Secret */}}
{{- define "postgres.s3" }}
[global]
{{- if .Values.s3 }}
{{- if .Values.s3.key }}
repo1-s3-key={{ .Values.s3.key }}
{{- if .s3 }}
  {{- if .s3.key }}
repo{{ add .index 1 }}-s3-key={{ .s3.key }}
  {{- end }}
{{- if .Values.s3.keySecret }}
repo1-s3-key-secret={{ .Values.s3.keySecret }}
  {{- if .s3.keySecret }}
repo{{ add .index 1 }}-s3-key-secret={{ .s3.keySecret }}
  {{- end }}
{{- if .Values.s3.encryptionPassphrase }}
repo1-cipher-pass={{ .Values.s3.encryptionPassphrase }}
  {{- if .s3.encryptionPassphrase }}
repo{{ add .index 1 }}-cipher-pass={{ .s3.encryptionPassphrase }}
  {{- end }}
{{- end }}
{{ end }}
+13 −2
Original line number Diff line number Diff line
{{- if .Values.s3 }}
{{- if or .Values.multiBackupRepos .Values.s3 }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ default .Release.Name .Values.name }}-pgbackrest-secret
type: Opaque
data:
{{- if .Values.multiBackupRepos }}
  {{- range $index, $repo := .Values.multiBackupRepos }}
  {{- if $repo.s3 }}
  {{- $args := dict "s3" $repo.s3 "index" $index }}
  s3.conf: |-
        {{ include "postgres.s3" . | b64enc }}
        {{ include "postgres.s3" $args | b64enc }}
  {{- end }}
{{- end }}
{{- else if .Values.s3 }}
  {{- $args := dict "s3" .Values.s3 "index" 0 }}
  s3.conf: |-
        {{ include "postgres.s3" $args | b64enc }}
{{- end }}
{{- end }}
+28 −0
Original line number Diff line number Diff line
@@ -40,6 +40,34 @@ spec:
{{- end }}
{{- if .Values.pgBackRestConfig }}
{{ toYaml .Values.pgBackRestConfig | indent 6 }}
{{- else if .Values.multiBackupRepos }}
      configuration:
      - secret:
          name: {{ default .Release.Name .Values.name }}-pgbackrest-secret
      global:
        {{- range $index, $repo := .Values.multiBackupRepos }}
        {{- if $repo.s3 }}
        repo{{ add $index 1 }}-path: /pgbackrest/{{ $.Release.Namespace }}/{{ default $.Release.Name $.Values.name }}/repo{{ add $index 1 }}
        {{- end }}
        {{- end }}
      repos:
      {{- range $index, $repo := .Values.multiBackupRepos }}
      - name: repo{{ add $index 1 }}
        {{- if $repo.volume }}
        volume:
          volumeClaimSpec:
            accessModes:
            - "ReadWriteOnce"
            resources:
              requests:
                storage: {{ default "1Gi" $repo.volume.backupsSize | quote }}
        {{- else if $repo.s3 }}
        s3:
          bucket: {{ $repo.s3.bucket | quote }}
          endpoint: {{ $repo.s3.endpoint | quote }}
          region: {{ $repo.s3.region | quote }}
        {{- end }}
      {{- end }}
{{- else if .Values.s3 }}
      configuration:
      - secret:
+23 −2
Original line number Diff line number Diff line
@@ -165,8 +165,8 @@
# Backups / pgBackRest Settings #
#################################

# backupsSize sets the storage size of the backups to a PVC. This can be
# overridden by "pgBackRestConfig", if set. Defaults to the value velow.
# backupsSize sets the storage size of the backups to a volume in Kubernetes.
# can be overridden by "pgBackRestConfig", if set. Defaults to the value velow.
# backupsSize: 1Gi

# s3 allows for AWS S3 or an S3 compatible storage system to be used for
@@ -189,6 +189,27 @@
#   # built-in encrpytion system.
#   encryptionPassphrase: ""

# multiBackupRepos allows for backing up to multiple repositories. This is
# effectively uses the "quickstarts" for each of the backup types (volume, s3,
# gcs, azure). You can have any permutation of these types. You can set up to 4.
# can be overwritten by "pgBackRestConfig".
#
# You can't set "multiBackupRepos" and any of the individual quickstarts at the
# same time. "multiBackupRepos" will take precedence.
#
# Below is an example that enables one of each backup type. Note all of the
# available quickstart options are presented below; please see the backup types
# if you want to see how each option works.
# multiBackupRepos:
# - volume:
#     backupsSize: 1Gi
# - s3:
#     bucket: ""
#     endpoint: ""
#     region: ""
#     key: ""
#     keySecret: ""

# pgBackRestConfig allows for the configuration of every pgBackRest option
# except for "image", which is set by "pgBackRest".
# pgBackRestConfig: {}