Stop trapping errors und unset enviromant vars
On error just print error, but do not reset env vars, if this is done on verify error the init afterwards will store all settings in the wrong path
This commit is contained in:
@@ -7,14 +7,19 @@ fi;
|
||||
|
||||
set -ETu #-e -o pipefail
|
||||
trap cleanup SIGINT SIGTERM ERR
|
||||
trap error_trap ERR
|
||||
|
||||
cleanup() {
|
||||
# script cleanup here
|
||||
echo "Some part of the script failed with an error: $? @LINE: $(caller)";
|
||||
echo "Script abort: $? @LINE: $(caller)";
|
||||
# unset exported vars
|
||||
unset BORG_BASE_DIR BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK BORG_RELOCATED_REPO_ACCESS_IS_OK;
|
||||
# end trap
|
||||
trap - SIGINT SIGTERM ERR
|
||||
trap - SIGINT SIGTERM
|
||||
}
|
||||
error_trap() {
|
||||
echo "Some part of the script failed with an error: $? @LINE: $(caller)";
|
||||
trap - ERR
|
||||
}
|
||||
# on exit unset any exported var
|
||||
trap "unset BORG_BASE_DIR BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK BORG_RELOCATED_REPO_ACCESS_IS_OK" EXIT;
|
||||
@@ -348,7 +353,7 @@ if [ -n "${ONE_TIME_TAG}" ] && ! [[ "${ONE_TIME_TAG}" =~ ^[A-Za-z0-9_-]+$ ]]; th
|
||||
echo "One time tag '${ONE_TIME_TAG}' must be alphanumeric with dashes and underscore only.";
|
||||
exit 1;
|
||||
elif [ -n "${ONE_TIME_TAG}" ]; then
|
||||
# all ok, attach . at the end
|
||||
# all ok, attach '.' at the end
|
||||
ONE_TIME_TAG=${ONE_TIME_TAG}".";
|
||||
fi;
|
||||
# if -D, cannot be with -T, -i, -C, -I, -P
|
||||
@@ -359,7 +364,7 @@ fi;
|
||||
# -D also must be in valid backup set format
|
||||
# ! [[ "${DELETE_ONE_TIME_TAG}" =~ ^[A-Za-z0-9_-]+\.${MODULE},(\*-)?[0-9]{4}-[0-9]{2}-[0-9]{2}T\*$ ]]
|
||||
if [ -n "${DELETE_ONE_TIME_TAG}" ] && ! [[ "${DELETE_ONE_TIME_TAG}" =~ ^[A-Za-z0-9_-]+\.${MODULE},([A-Za-z0-9_-]+-)?[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$ ]] && ! [[ "${DELETE_ONE_TIME_TAG}" =~ ^[A-Za-z0-9_-]+\.${MODULE},(\*-)?[0-9]{4}-[0-9]{2}-[0-9]{2}T\*$ ]]; then
|
||||
echo "Delete one time tag '${DELETE_ONE_TIME_TAG}' is in an invalid format. "
|
||||
echo "Delete one time tag '${DELETE_ONE_TIME_TAG}' is in an invalid format."
|
||||
echo "Please verify existing tags with -P option."
|
||||
echo "For a globing be sure it is in the format of: TAG.MODULE,*-YYYY-MM-DDT*";
|
||||
echo "Note the dash (-) after the first *, also time (T) is a globa (*) must."
|
||||
|
||||
@@ -299,7 +299,14 @@ if [ "${VERIFY}" -eq 1 ] || [ "${INIT}" -eq 1 ]; then
|
||||
echo "${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY} 2>&1|grep \"Repository ID:\"";
|
||||
fi;
|
||||
# use borg info and verify if it returns "Repository ID:" in the first line
|
||||
REPO_VERIFY=$(${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}" 2>&1|grep "Repository ID:");
|
||||
REPO_VERIFY=$(${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}" 2>&1);
|
||||
if ! $?; then
|
||||
echo "[!] Repository verify error: ${REPO_VERIFY}";
|
||||
REPO_VERIFY="";
|
||||
else
|
||||
REPO_VERIFY=$(echo "${REPO_VERIFY}" | grep "Repository ID:");
|
||||
fi;
|
||||
# | grep "Repository ID:"
|
||||
# this is currently a hack to work round the error code in borg info
|
||||
# this checks if REPO_VERIFY holds this error message and then starts init
|
||||
if [[ -z "${REPO_VERIFY}" ]] || [[ "${REPO_VERIFY}" =~ ${REGEX_ERROR} ]]; then
|
||||
|
||||
Reference in New Issue
Block a user