diff --git a/library/ix-dev/charts/nextcloud/Chart.yaml b/library/ix-dev/charts/nextcloud/Chart.yaml index 25c400f7ea..5e48831960 100644 --- a/library/ix-dev/charts/nextcloud/Chart.yaml +++ b/library/ix-dev/charts/nextcloud/Chart.yaml @@ -4,7 +4,7 @@ description: A file sharing server that puts the control and security of your ow annotations: title: Nextcloud type: application -version: 1.6.46 +version: 1.6.47 apiVersion: v2 appVersion: 27.0.2 kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/nextcloud/templates/backup-postgres-config.yaml b/library/ix-dev/charts/nextcloud/templates/backup-postgres-config.yaml index c9ccf66dba..9b6e719201 100644 --- a/library/ix-dev/charts/nextcloud/templates/backup-postgres-config.yaml +++ b/library/ix-dev/charts/nextcloud/templates/backup-postgres-config.yaml @@ -6,10 +6,19 @@ metadata: rollme: {{ randAlphaNum 5 | quote }} data: entrypoint.sh: |- - #!/bin/sh - cmd="/docker-entrypoint.sh postgres" - eval "${cmd}" & disown; - until pg_isready; do - sleep 5; - done; - pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName" . }} > /postgres_backups/$BACKUP_NAME; + #!/bin/bash + echo "Fetching password from config.php" + + # sed removes ' , => spaces and db* from the string + DBUSER=$(cat /nc-config/config.php | grep "dbuser" | sed "s/dbuser\| \|'\|,\|=>//g") + DBPASS=$(cat /nc-config/config.php | grep "dbpassword" | sed "s/dbpassword\| \|'\|,\|=>//g") + DBNAME=$(cat /nc-config/config.php | grep "dbname" | sed "s/dbname\| \|'\|,\|=>//g") + [ -n "$DBUSER" ] && [ -n "$DBPASS" ] && [ -n "$DBNAME" ] && echo "User, Database and password fetched from config.php" + + until pg_isready -U ${POSTGRES_USER} -h ${POSTGRES_HOST}; do sleep 2; done + + # pg_dump will automatically use the password from the PGPASSWORD environment variable + echo "Creating backup of ${DBNAME} database as ${DBUSER}" + PGPASSWORD=${DBPASS} pg_dump -U $DBUSER -d $DBNAME --host=${POSTGRES_HOST} > /postgres_backups/$BACKUP_NAME \ + && echo "Backup created successfully" \ + || echo "Backup failed" diff --git a/library/ix-dev/charts/nextcloud/templates/backup-postgres-hook.yaml b/library/ix-dev/charts/nextcloud/templates/backup-postgres-hook.yaml index 175b0f2617..f7b13fda69 100644 --- a/library/ix-dev/charts/nextcloud/templates/backup-postgres-hook.yaml +++ b/library/ix-dev/charts/nextcloud/templates/backup-postgres-hook.yaml @@ -1,6 +1,7 @@ {{- if .Values.ixChartContext.isUpgrade -}} {{ $values := (. | mustDeepCopy) }} {{ $_ := set $values "common" (dict "nameSuffix" "postgres") }} +{{ $dbHost := .Values.nextcloudDbHost }} apiVersion: batch/v1 kind: Job metadata: @@ -24,11 +25,16 @@ spec: env: {{ include "postgres.envVariableConfiguration" $values | nindent 10 }} - name: BACKUP_NAME value: {{ template "postgres.backupName" . }} + - name: POSTGRES_HOST + value: {{ $dbHost }} volumeMounts: {{ include "postgres.volumeMountsConfiguration" $values | nindent 10 }} - name: backup-script-configmap mountPath: /bin/backup_entrypoint.sh readOnly: true subPath: entrypoint.sh + - name: nextcloud-data + mountPath: /nc-config + subPath: "config" command: - "/bin/backup_entrypoint.sh" volumes: {{ include "postgres.volumeConfiguration" $values | nindent 8 }} @@ -36,4 +42,7 @@ spec: configMap: defaultMode: 0700 name: "postgres-backup-hook-config-map" + {{ if .Values.appVolumeMounts }} + {{- include "common.storage.configureAppVolumes" .Values | nindent 8 }} + {{ end }} {{- end -}} diff --git a/library/ix-dev/charts/nextcloud/templates/nuke-deployments-hook.yaml b/library/ix-dev/charts/nextcloud/templates/nuke-deployments-hook.yaml deleted file mode 100644 index 218ea00220..0000000000 --- a/library/ix-dev/charts/nextcloud/templates/nuke-deployments-hook.yaml +++ /dev/null @@ -1,24 +0,0 @@ -{{- if .Values.ixChartContext.isUpgrade -}} -{{ $values := (. | mustDeepCopy) }} -{{ $_ := set $values "common" (dict "nameSuffix" "postgres") }} -apiVersion: batch/v1 -kind: Job -metadata: - name: "pre-upgrade-hook1" - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "-1" - "helm.sh/hook-delete-policy": hook-succeeded - rollme: {{ randAlphaNum 5 | quote }} -spec: - template: - metadata: - name: "pre-upgrade-hook1" - spec: - restartPolicy: Never - serviceAccountName: "{{ template "common.names.serviceAccountName" . }}" - containers: - - name: kubectl - image: "bitnami/kubectl:1.19" - command: ["kubectl", "delete" , "deployment", "{{ template "common.names.fullname" . }}", "{{ template "common.names.fullname" $values }}"] -{{- end -}}