Take postgres backup on upgrade
This commit is contained in:
parent
dbde74851d
commit
1f15d72cf0
|
@ -120,3 +120,10 @@ Nextcloud service account
|
|||
{{- define "nextcloud.serviceAccountName" -}}
|
||||
{{- printf "%s-service-account" .Release.Name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get Nextloud Postgres Database Name
|
||||
*/}}
|
||||
{{- define "postgres.DatabaseName" -}}
|
||||
{{- print "nextcloud" -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: "pre-upgrade-hook2"
|
||||
annotations:
|
||||
"helm.sh/hook": pre-upgrade
|
||||
"helm.sh/hook-weight": "1"
|
||||
"helm.sh/hook-delete-policy": hook-succeeded
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
name: "pre-upgrade-hook2"
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
serviceAccountName: {{ template "nextcloud.serviceAccountName" }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}-postgres-backup
|
||||
image: "postgres:13.1"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-details
|
||||
key: db-user
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-details
|
||||
key: db-password
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: postgres-backup
|
||||
mountPath: /postgres_backups
|
||||
command: ['sh', '-c', "/docker-entrypoint.sh; pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName"}} > /postgres_backups/update_dump;"]
|
|
@ -49,7 +49,7 @@ spec:
|
|||
- name: POSTGRES_HOST
|
||||
value: {{ template "nextcloud.fullname" . }}-postgres:5432
|
||||
- name: POSTGRES_DB
|
||||
value: "nextcloud"
|
||||
value: {{ template "postgres.DatabaseName" }}
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
|
Loading…
Reference in New Issue