From 7b4e4b209bc7ac5624b4acc394a93698b59bdc73 Mon Sep 17 00:00:00 2001
From: Vineet Reddy Rajula <rajula.vineet.reddy@cern.ch>
Date: Tue, 11 Oct 2022 14:40:01 +0200
Subject: [PATCH] Add backup storage location to velero backup

---
 chart/drupal-operations/templates/drupalsite-backup.yaml | 1 +
 chart/drupal-operations/values.yaml                      | 1 +
 tekton-task-templates/backup_resource.yaml               | 1 +
 3 files changed, 3 insertions(+)

diff --git a/chart/drupal-operations/templates/drupalsite-backup.yaml b/chart/drupal-operations/templates/drupalsite-backup.yaml
index 855da4a..69df235 100644
--- a/chart/drupal-operations/templates/drupalsite-backup.yaml
+++ b/chart/drupal-operations/templates/drupalsite-backup.yaml
@@ -37,6 +37,7 @@ spec:
         export RESOURCE_NAME=$NAMESPACE-$BACKUP_NAME-$TIMESTAMP_HASH
         export PROJECT_HASH=$(printf '%s' "$NAMESPACE" | md5sum | awk '{print $1}')
         export VELERO_NAMESPACE={{ .Values.veleroNamespace }}
+        export VELERO_BACKUP_STORAGE_LOCATION={{ .Values.veleroBackupStorageLocation }}
         envsubst < /tekton-task-templates/backup_resource.yaml | oc create -f -
         timeout 120s sh -c -- 'while [[ $(oc get "backup/$RESOURCE_NAME" -n "$VELERO_NAMESPACE" -o jsonpath='{.status.phase}') != "Completed" ]]; do printf "Backup in progress\n"; sleep 2s; done'
         backupStatus=$(oc get backup/$RESOURCE_NAME -n $VELERO_NAMESPACE -o=jsonpath='{.status.phase}' | grep -i -E 'failed|completed|partiallyfailed' || echo "Failed")
diff --git a/chart/drupal-operations/values.yaml b/chart/drupal-operations/values.yaml
index 990f94c..d18c126 100644
--- a/chart/drupal-operations/values.yaml
+++ b/chart/drupal-operations/values.yaml
@@ -1,3 +1,4 @@
 image: gitlab-registry.cern.ch/drupal/paas/drupal-operations/openshift-cli:velero-restore
 restoreServiceAccount: ""
 veleroNamespace: ""
+veleroBackupStorageLocation: "default"
diff --git a/tekton-task-templates/backup_resource.yaml b/tekton-task-templates/backup_resource.yaml
index f6d193c..09da9d7 100644
--- a/tekton-task-templates/backup_resource.yaml
+++ b/tekton-task-templates/backup_resource.yaml
@@ -25,5 +25,6 @@ spec:
     matchLabels:
       app: drupal
       drupalSite: $DRUPALSITE
+  storageLocation: $VELERO_BACKUP_STORAGE_LOCATION
   ttl: 87600h0m0s    # 10 years (prevent cleanup of on-demand backups)
 status: {}
-- 
GitLab