Move backup cleaning procedure into a per-bucket loop
@@ -156,12 +156,6 @@ for _dest_bkp_storage_name in ${CP_BKP_STORAGE_ARRAY[@]}; do
failure keep_running "[ERROR] An error occured while transferring backups from $CP_BKP_SERVICE_WD to $TARGET_STORAGE_LOCATION_DATE"
_has_copy_errors=true
fi
-done
-if [ "$_has_copy_errors" == true ]; then
- echo "Some of the data transfer operations has failed, see output above. Exiting"
- exit 1
-fi
-rm -rf $CP_BKP_SERVICE_WD/cp-bkp-*
# Remove the outdated backup (keep last CP_BKP_FILES_COUNT)
export CP_BKP_FILES_COUNT="${CP_BKP_FILES_COUNT:-10}"
@@ -174,3 +168,9 @@ while (( TARGET_STORAGE_BKP_FILES_COUNT > CP_BKP_FILES_COUNT )); do
TARGET_STORAGE_BKP_FILES_COUNT=${#TARGET_STORAGE_BKP_FILES[@]}
/pipe storage rm -r -y "${TARGET_STORAGE_LOCATION}${TARGET_STORAGE_BKP_OUTDATED}"
done
+done
+if [ "$_has_copy_errors" == true ]; then
+ echo "Some of the data transfer operations has failed, see output above. Exiting"
+ exit 1
+fi
+rm -rf $CP_BKP_SERVICE_WD/cp-bkp-*
