Skip to content

Commit 97f9875

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

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

charts/nextcloud/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,9 @@ Check out the [official Nextcloud backup docs](https://docs.nextcloud.com/server
528528
529529
Configure `.nextcloud.backupCronjobs` to install Kubernetes Cronjobs
530530
to backup the Nextcloud data volume. The Helm chart automatically
531-
adds `volumes` and `volumeMounts` to the Cronjobs to make the
532-
Nextcloud data folder accessible at the same paths as the Nextcloud
533-
containers.
531+
shares the Nextcloud data folder to (`volumes`, `volumeMounts`) on the
532+
same path. Additionally, it provides the environment variable
533+
`NEXTCLOUD_DATA_DIR`.
534534
535535
Example:
536536
@@ -556,7 +556,7 @@ Example:
556556
command:
557557
- /bin/sh
558558
- -c
559-
- "restic --quiet --json --host nextcloud-data --tag cron backup /var/www/html/data"
559+
- "restic --quiet --json --host nextcloud-data --tag cron backup ${NEXTCLOUD_DATA_DIR}"
560560
env:
561561
- name: RESTIC_CACHE_DIR
562562
value: /run/restic/cache

charts/nextcloud/templates/_helpers.tpl

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

295+
{{- define "nextcloud.backupCronJobEnv" -}}
296+
- name: NEXTCLOUD_DATA_DIR
297+
value: {{ .Values.nextcloud.datadir | quote }}
298+
{{- end -}}
299+
295300
{{- define "nextcloud.backupCronJobVolumes" -}}
296301
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
297302
- 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
@@ -216,7 +216,7 @@ nextcloud:
216216
# command:
217217
# - /bin/sh
218218
# - -c
219-
# - "restic --quiet --json --host nextcloud-data --tag cron backup /var/www/html/data"
219+
# - "restic --quiet --json --host nextcloud-data --tag cron backup ${NEXTCLOUD_DATA_DIR}"
220220
# env:
221221
# - name: TZ
222222
# value: "Europe/Berlin"

0 commit comments

Comments
 (0)