diff --git a/chart/drupal-operations/templates/drupalsite-backup.yaml b/chart/drupal-operations/templates/drupalsite-backup.yaml index 855da4a660e8a4a8f8dabcfd1d500784392f2a03..26c5350a163754f12ee9a3ac117259d3029c56c7 100644 --- a/chart/drupal-operations/templates/drupalsite-backup.yaml +++ b/chart/drupal-operations/templates/drupalsite-backup.yaml @@ -38,6 +38,10 @@ spec: export PROJECT_HASH=$(printf '%s' "$NAMESPACE" | md5sum | awk '{print $1}') export VELERO_NAMESPACE={{ .Values.veleroNamespace }} 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") - echo "DrupalSite backup status: $backupStatus" + BACKUP_STATE=$(oc get "backup/$RESOURCE_NAME" -n "$VELERO_NAMESPACE" -o jsonpath='{.status.phase}'); + # While the backup is pending OR inProgress, we wait + while [[ ${BACKUP_STATE,,} == "inprogress" || ${BACKUP_STATE,,} == "pending" ]] ; do printf "Backup in state $STATE"; sleep 3s; BACKUP_STATE=$(oc get "backup/$RESOURCE_NAME" -n "$VELERO_NAMESPACE" -o jsonpath='{.status.phase}') ; done + echo "DrupalSite backup status: $BACKUP_STATE" + if [[ ${BACKUP_STATE,,} != "completed" ]]; then + exit 1 + fi