Skip to content

Commit e988790

Browse files
Modify backup job by adding PVC for backup
Updated backup-on-azure.yaml to change restart policy to OnFailure, added cleanup for backup tar files, and introduced PersistentVolumeClaim for Azure persistence.
1 parent 172cbfb commit e988790

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

charts/devtron-backups/templates/backup-on-azure.yaml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ spec:
3030
schedule: {{ .Values.global.schedule }}
3131
jobTemplate:
3232
spec:
33-
backoffLimit: 0
34-
{{- if $.Values.global.extraConfig }}
35-
{{ toYaml $.Values.global.extraConfig | indent 6 }}
36-
{{- end }}
3733
template:
3834
{{- if or $.Values.postgres_backup.labels $.Values.postgres_backup.annotations }}
3935
metadata:
@@ -102,13 +98,18 @@ spec:
10298
- /bin/bash
10399
- -c
104100
{{- if $.Values.global.AZURE.encryption.enabled }}
105-
- set -ex; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.AZURE.encryption.passphrase }} /postgres/backup.tar; rm -rvf /postgres/backup.tar; mv /postgres/backup.tar.gpg /postgres/backup-$date1.tar.gpg; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /postgres/backup-$date1.tar.gpg --account-key $AZURE_ACCOUNT_KEY;
101+
- set -ex; date1=$(date +%Y%m%d-%H%M); gpg -c --batch --passphrase {{ .Values.global.AZURE.encryption.passphrase }} /postgres/backup.tar; rm -rvf /postgres/backup.tar; mv /postgres/backup.tar.gpg /postgres/backup-$date1.tar.gpg; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /postgres/backup-$date1.tar.gpg --account-key $AZURE_ACCOUNT_KEY; rm -rvf /postgres/backup-$date1.tar;
106102
{{- else }}
107-
- set -ex; date1=$(date +%Y%m%d-%H%M); mv /postgres/backup.tar /postgres/backup-$date1.tar; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /postgres/backup-$date1.tar --account-key $AZURE_ACCOUNT_KEY;
103+
- set -ex; date1=$(date +%Y%m%d-%H%M); mv /postgres/backup.tar /postgres/backup-$date1.tar; az storage blob upload --account-name $AZURE_BLOB_ACCOUNT_NAME --container-name $AZURE_BLOB_CONTAINER_FOR_POSTGRES --file /postgres/backup-$date1.tar --account-key $AZURE_ACCOUNT_KEY; rm -rvf /postgres/backup-$date1.tar;
108104
{{- end }}
109105
volumes:
110-
- name: psql-volume
111-
emptyDir: {}
106+
- name: psql-volume
107+
persistentVolumeClaim:
108+
{{- if and .Values.global.AZURE.PERSISTENCE.enabled .Values.global.AZURE.PERSISTENCE.existingClaim }}
109+
claimName: {{ .Values.global.AZURE.PERSISTENCE.existingClaim }}
110+
{{- else }}
111+
claimName: devtron-backup-pvc
112+
{{- end }}
112113
{{- if $.Values.global.nodeSelector }}
113114
nodeselector:
114115
{{ toYaml .Values.global.nodeSelector | indent 12 }}
@@ -117,7 +118,7 @@ spec:
117118
tolerations:
118119
{{ toYaml .Values.global.tolerations | indent 12 }}
119120
{{- end }}
120-
restartPolicy: Never
121+
restartPolicy: OnFailure
121122
{{- end }}
122123
---
123124
{{- if .Values.argocd_backup.enabled }}
@@ -135,10 +136,6 @@ spec:
135136
schedule: {{ .Values.global.schedule }}
136137
jobTemplate:
137138
spec:
138-
backoffLimit: 0
139-
{{- if $.Values.global.extraConfig }}
140-
{{ toYaml $.Values.global.extraConfig | indent 6 }}
141-
{{- end }}
142139
template:
143140
{{- if or $.Values.postgres_backup.labels $.Values.postgres_backup.annotations }}
144141
metadata:
@@ -215,7 +212,26 @@ spec:
215212
tolerations:
216213
{{ toYaml .Values.global.tolerations | indent 12 }}
217214
{{- end }}
218-
restartPolicy: Never
215+
restartPolicy: OnFailure
219216
serviceAccountName: {{ .Values.argocd_backup.serviceAccountName }}
220217
{{- end }}
221218
{{- end }}
219+
220+
221+
{{- if and (.Values.global.AZURE.enabled) (.Values.global.AZURE.PERSISTENCE.enabled) (not .Values.global.AZURE.PERSISTENCE.existingClaim) }}
222+
---
223+
apiVersion: v1
224+
kind: PersistentVolumeClaim
225+
metadata:
226+
name: devtron-backup-pvc
227+
namespace: devtroncd
228+
spec:
229+
{{- if .Values.global.AZURE.PERSISTENCE.storageClass }}
230+
storageClassName: {{ .Values.global.AZURE.PERSISTENCE.storageClass }}
231+
{{- end }}
232+
accessModes:
233+
- ReadWriteOnce
234+
resources:
235+
requests:
236+
storage: {{ .Values.global.AZURE.PERSISTENCE.size }}
237+
{{- end }}

0 commit comments

Comments
 (0)