diff --git a/image/tools/lib/component/resources.sh b/image/tools/lib/component/resources.sh index 0e68f9d..a6dc14e 100644 --- a/image/tools/lib/component/resources.sh +++ b/image/tools/lib/component/resources.sh @@ -26,11 +26,16 @@ function backup_resource { local type=$1 local ns=$2 local dest=$3 - local loop=$4 + local loop=${4-default} + + # Disable extended error checks. The check_resource function relies on a non-zero + # return code, which is interpreted as a failed command and causes the script to be + # terminated with the '-e' option + set +eo pipefail check_resource ${type} ${ns} if [ "$?" -eq "0" ]; then echo "==> backing up $type in $ns" - if [[ "$loop" ]]; then + if [ "$loop" == "y" ]; then echo '---' > /tmp/${type}.yaml for obj in $(oc get ${type} -n ${ns} | tr -s ' ' | cut -d ' ' -f 1 | tail -n +2); do echo '-' >> /tmp/${type}.yaml @@ -42,6 +47,8 @@ function backup_resource { oc get ${type} -n ${ns} -o yaml --export | gzip > ${dest}/archives/${ns}-${type}.yaml.gz fi fi + # Re-enable extended error checks + set -eo pipefail } # Backs up a namespace