Skip to content

Commit 9b25f26

Browse files
committed
fix: Make more robust way to backup/restore
1 parent 5564dd2 commit 9b25f26

11 files changed

+18
-9
lines changed

charts/dependencies/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ apiVersion: v2
22
name: opencrvs-dependencies-chart
33
description: Dependencies required by OpenCRVS
44
type: application
5-
version: 0.2.3
5+
version: 0.2.4
66
appVersion: 1.9.0

charts/dependencies/templates/_helpers.tpl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ Parameters:
99
- .ServiceName: The name of the microservice, which is used to access service-specific values.
1010
- .Values: The top-level Values object for the Helm chart.
1111
*/}}
12+
1213
{{- define "render-env-vars" -}}
13-
{{- $service_name := .service_name -}}
14+
{{- $service_key_name := ( .service_name | replace "-" "_" ) }}
15+
1416
{{/* Loop through and generate global environment variables */}}
1517
{{- range $k, $v := .Values.env }}
1618
- name: {{ $k }}
1719
value: {{ $v | quote }}
18-
{{- end -}}
20+
{{- end }}
1921
{{/* Access the service-specific values using the service name */}}
20-
{{- with index .Values $service_name -}}
22+
{{- with index .Values $service_key_name }}
2123
{{/* Loop through and generate service-specific environment variables */}}
2224
{{- range $k, $v := .env }}
2325
- name: {{ $k }}
2426
value: {{ $v | quote }}
25-
{{- end -}}
27+
{{- end }}
2628
{{/* Loop through and generate secret references for service-specific secrets */}}
27-
{{- range $secret_name, $secret_values := .secrets -}}
29+
{{- range $secret_name, $secret_values := .secrets }}
2830
{{- range $secret_value := $secret_values }}
2931
{{- $secret := split ":" $secret_value }}
3032
- name: {{ $secret._1 | default $secret._0 }}

charts/dependencies/templates/influxdb-backup-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spec:
4949
key: host
5050
- name: BACKUP_REMOTE_DIR
5151
value: "{{ .Values.influxdb.backup_server_dir | default .Values.backup.backup_server_dir }}"
52+
{{- include "render-env-vars" (dict "service_name" "backup" "Values" .Values) | nindent 4 }}
5253
command: ["/scripts/backup.sh"]
5354
volumeMounts:
5455
- name: backup-ssh-key

charts/dependencies/templates/influxdb-restore-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spec:
4949
key: host
5050
- name: BACKUP_REMOTE_DIR
5151
value: "{{ .Values.influxdb.restore_server_dir | default .Values.restore.backup_server_dir }}"
52+
{{- include "render-env-vars" (dict "service_name" "restore" "Values" .Values) | nindent 4 }}
5253
command: ["/scripts/restore.sh"]
5354
volumeMounts:
5455
- name: backup-ssh-key

charts/dependencies/templates/minio-backup-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ spec:
6060
key: host
6161
- name: BACKUP_REMOTE_DIR
6262
value: "{{ .Values.minio.backup_server_dir | default .Values.backup.backup_server_dir }}"
63+
{{- include "render-env-vars" (dict "service_name" "backup" "Values" .Values) | nindent 4 }}
6364
volumeMounts:
6465
- name: backup-ssh-key
6566
mountPath: /ssh

charts/dependencies/templates/minio-restore-cronjob.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ spec:
3131
env:
3232
- name: RESTORE_MODE
3333
value: "mirror"
34-
- name: RESTORE_DATE
35-
value: {{ .Values.restore.date }}
3634
{{- if not .Values.minio.use_default_credentials }}
3735
- name: MINIO_ROOT_USER
3836
valueFrom:
@@ -62,6 +60,7 @@ spec:
6260
key: host
6361
- name: BACKUP_REMOTE_DIR
6462
value: "{{ .Values.minio.backup_server_dir | default .Values.restore.backup_server_dir }}"
63+
{{- include "render-env-vars" (dict "service_name" "restore" "Values" .Values) | nindent 4 }}
6564
volumeMounts:
6665
- name: backup-ssh-key
6766
mountPath: /ssh

charts/dependencies/templates/mongo-backup-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ spec:
5959
key: host
6060
- name: BACKUP_REMOTE_DIR
6161
value: "{{ .Values.mongodb.backup_server_dir | default .Values.backup.backup_server_dir }}"
62+
{{- include "render-env-vars" (dict "service_name" "restore" "Values" .Values) | nindent 4 }}
6263
command: ["/scripts/backup.sh"]
6364
volumeMounts:
6465
- name: backup-ssh-key

charts/dependencies/templates/mongo-restore-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ spec:
5959
key: host
6060
- name: BACKUP_REMOTE_DIR
6161
value: "{{ .Values.mongodb.restore_server_dir | default .Values.restore.backup_server_dir }}"
62+
{{- include "render-env-vars" (dict "service_name" "restore" "Values" .Values) | nindent 4 }}
6263
command: ["/scripts/restore.sh"]
6364
volumeMounts:
6465
- name: backup-ssh-key

charts/dependencies/templates/postgres-backup-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ spec:
6666
key: host
6767
- name: BACKUP_REMOTE_DIR
6868
value: "{{ .Values.postgres.backup_server_dir | default .Values.backup.backup_server_dir }}"
69+
{{- include "render-env-vars" (dict "service_name" "backup" "Values" .Values) | nindent 4 }}
6970
command: ["/scripts/backup.sh"]
7071
volumeMounts:
7172
- name: backup-ssh-key

charts/dependencies/templates/postgres-restore-cronjob.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ spec:
6666
key: host
6767
- name: BACKUP_REMOTE_DIR
6868
value: "{{ .Values.postgres.restore_server_dir | default .Values.restore.backup_server_dir }}"
69+
{{- include "render-env-vars" (dict "service_name" "restore" "Values" .Values) | nindent 4 }}
6970
command: ["/scripts/restore.sh"]
7071
volumeMounts:
7172
- name: backup-ssh-key

0 commit comments

Comments
 (0)