Skip to content

Commit bfb0e14

Browse files
committed
Share env variable NEXTCLOUD_DATA_DIR
Signed-off-by: Stephan Austermühle <au@hcsd.de>
1 parent 293c536 commit bfb0e14

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

charts/nextcloud/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,9 @@ Check out the [official Nextcloud backup docs](https://docs.nextcloud.com/server
627627
628628
Configure `.nextcloud.backupCronjobs` to install Kubernetes Cronjobs
629629
to backup the Nextcloud data volume. The Helm chart automatically
630-
adds `volumes` and `volumeMounts` to the Cronjobs to make the
631-
Nextcloud data folder accessible at the same paths as the Nextcloud
632-
containers.
630+
shares the Nextcloud data folder to (`volumes`, `volumeMounts`) on the
631+
same path. Additionally, it provides the environment variable
632+
`NEXTCLOUD_DATA_DIR`.
633633
634634
Example:
635635
@@ -655,7 +655,7 @@ Example:
655655
command:
656656
- /bin/sh
657657
- -c
658-
- "restic --quiet --json --host nextcloud-data --tag cron backup /var/www/html/data"
658+
- "restic --quiet --json --host nextcloud-data --tag cron backup ${NEXTCLOUD_DATA_DIR}"
659659
env:
660660
- name: RESTIC_CACHE_DIR
661661
value: /run/restic/cache

charts/nextcloud/templates/_helpers.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ Create volume mounts for the nextcloud container as well as the cron sidecar con
399399
{{- end }}
400400
{{- end -}}
401401

402+
{{- define "nextcloud.backupCronJobEnv" -}}
403+
- name: NEXTCLOUD_DATA_DIR
404+
value: {{ .Values.nextcloud.datadir | quote }}
405+
{{- end -}}
406+
402407
{{- define "nextcloud.backupCronJobVolumes" -}}
403408
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
404409
- name: nextcloud-data

charts/nextcloud/templates/cronjobs.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ spec:
1616
{{- $volumes := dict "spec" (dict "template" (dict "spec" (dict "volumes" $volumeList))) -}}
1717
{{- $jobTemplate := merge $volumes .jobTemplate -}}
1818

19-
{{/* Add the volumeMounts to every container */}}
19+
{{/* Add the volumeMounts and environment variables to every container */}}
2020
{{- $containers := list -}}
2121
{{- range .jobTemplate.spec.template.spec.containers -}}
22-
{{- $vm := concat (default list .volumeMounts) (include "nextcloud.backupCronJobVolumeMounts" $ | fromYamlArray) -}}
23-
{{- $this := dict "volumeMounts" $vm -}}
24-
{{- $containers = append $containers (merge $this .) -}}
22+
{{- $vm := dict "volumeMounts" (concat (default list .volumeMounts) (include "nextcloud.backupCronJobVolumeMounts" $ | fromYamlArray)) -}}
23+
{{- $containers = append $containers (merge $vm .) -}}
24+
{{- $env := concat (default list .env) (include "nextcloud.backupCronJobEnv" $ | fromYamlArray) -}}
25+
{{- $containers = append $containers (merge (dict "env" $env) .) -}}
2526
{{- end -}}
2627

2728
{{- $newContainers := dict "spec" (dict "template" (dict "spec" (dict "containers" $containers))) -}}

charts/nextcloud/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ nextcloud:
299299
# command:
300300
# - /bin/sh
301301
# - -c
302-
# - "restic --quiet --json --host nextcloud-data --tag cron backup /var/www/html/data"
302+
# - "restic --quiet --json --host nextcloud-data --tag cron backup ${NEXTCLOUD_DATA_DIR}"
303303
# env:
304304
# - name: TZ
305305
# value: "Europe/Berlin"

0 commit comments

Comments
 (0)