From 151f596bf16a27e52c7a4087fd2a2fe98f525f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=8B=D1=82=D0=BA=D0=BE=D0=B2=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD?= Date: Mon, 25 Mar 2024 02:29:11 +0300 Subject: [PATCH] Fix backup/restore --- cnpg-liquid/templates/cnpg-cluster.yaml | 7 ++----- cnpg-liquid/templates/scheduled-backup.yaml | 11 +++++++++++ cnpg-liquid/values.yaml | 1 + .../templates/pre-install-migration.yaml | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 cnpg-liquid/templates/scheduled-backup.yaml diff --git a/cnpg-liquid/templates/cnpg-cluster.yaml b/cnpg-liquid/templates/cnpg-cluster.yaml index 611bd99..ff6e2bb 100644 --- a/cnpg-liquid/templates/cnpg-cluster.yaml +++ b/cnpg-liquid/templates/cnpg-cluster.yaml @@ -2,9 +2,6 @@ apiVersion: postgresql.cnpg.io/v1 kind: Cluster metadata: name: {{ required "Cluster name required" .Values.cnpg.clusterName }} - annotations: - "helm.sh/hook": pre-install - "helm.sh/hook-weight": "-1" spec: startDelay: 300 stopDelay: 300 @@ -18,7 +15,7 @@ spec: externalClusters: - name: {{ required "Old cluster name required" .Values.cnpg.recovery.oldClusterName }} barmanObjectStore: - destinationPath: {{ .Values.cnpg.recovery.oldClusterName }} + destinationPath: {{ .Values.cnpg.recovery.sourcePath }} endpointURL: {{ .Values.s3.endpointUrl | quote }} s3Credentials: accessKeyId: @@ -57,4 +54,4 @@ spec: data: compression: bzip2 retentionPolicy: "7d" - {{ end }} + {{ end }} \ No newline at end of file diff --git a/cnpg-liquid/templates/scheduled-backup.yaml b/cnpg-liquid/templates/scheduled-backup.yaml new file mode 100644 index 0000000..acc5d87 --- /dev/null +++ b/cnpg-liquid/templates/scheduled-backup.yaml @@ -0,0 +1,11 @@ +{{ if .Values.cnpg.backup.enable }} +apiVersion: postgresql.cnpg.io/v1 +kind: ScheduledBackup +metadata: + name: {{ required "Cluster name required" .Values.cnpg.clusterName }}-scheduled-backup +spec: + method: barmanObjectStore + schedule: {{ .Values.cnpg.backup.schedule | quote }} + cluster: + name: {{ required "Cluster name required" .Values.cnpg.clusterName }} +{{ end }} \ No newline at end of file diff --git a/cnpg-liquid/values.yaml b/cnpg-liquid/values.yaml index 02935fb..cf8a4a4 100644 --- a/cnpg-liquid/values.yaml +++ b/cnpg-liquid/values.yaml @@ -7,6 +7,7 @@ cnpg: clusterName: liquid-db backup: enable: true + schedule: "0 0 0 * * *" destinationPath: "s3://liquid-code/backup" recovery: enable: false diff --git a/liquid-code-chart/templates/pre-install-migration.yaml b/liquid-code-chart/templates/pre-install-migration.yaml index 0cbc4ee..67514c3 100644 --- a/liquid-code-chart/templates/pre-install-migration.yaml +++ b/liquid-code-chart/templates/pre-install-migration.yaml @@ -9,6 +9,7 @@ metadata: helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" annotations: "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded spec: template: metadata: