From 70443978b675d8cb6f10681f176a342476c65297 Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Mon, 6 Nov 2023 20:38:43 +0000 Subject: [PATCH] Use / on end of mountpoint test in do-backup. --- do-backup | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/do-backup b/do-backup index 5db1835..dd3f0d4 100755 --- a/do-backup +++ b/do-backup @@ -9,7 +9,8 @@ # Base configuration. RSYNC_OPTIONS=( '-a' '-H' '-A' '--timeout=300' '--partial' '--partial-dir=.rsync-tmp' '--delete-delay' '--delay-updates' ) RSYNC_OPTIONS_VERBOSE=( '--verbose' '--stats' '--human-readable' ) -RSYNC_LOG="/tmp/${0##*/}-$$.log" +RSYNC_LOG="/tmp/${0##*/}-$$-$RANDOM.log" +LOCK_FILE="/tmp/${0##*/}-$$-$RANDOM.lock" # Sanity checks. (( $# != 1 )) || [[ -z "$1" ]] || [[ "$1" =~ ^(-h|-help|--help)$ ]] && { @@ -17,6 +18,9 @@ RSYNC_LOG="/tmp/${0##*/}-$$.log" exit 1 } +# Remove temporary files upon exit. +trap 'rm -f "$RSYNC_LOG"; rm -f "$LOCK_FILE"' EXIT + # Get backup definition specific configuration. case "$1" in 'gv0') @@ -93,7 +97,8 @@ source /etc/mail.conf "backups" 2>/dev/null || { } # Make sure BACKUP_MOUNTPOINT is a mountpoint. -mountpoint "$BACKUP_MOUNTPOINT" >/dev/null 2>&1 || { +# Note: The / on the end if required for automount mountpoints. +mountpoint "$BACKUP_MOUNTPOINT/" >/dev/null 2>&1 || { [[ -x /opt/bin/pushover-client ]] && /opt/bin/pushover-client "backups" -p -1 -m "Backup failure: ${ERRORS_SOURCE:-$RSYNC_SOURCE}" if [[ -n "${EMAIL_TO[*]}" ]]; then mailx "${MAILX_ARGS[@]}" -S "from=$EMAIL_FROM" -s "Backup failure: ${ERRORS_SOURCE:-$RSYNC_SOURCE}" "${EMAIL_TO[@]}" <<-EOF 2>/dev/null || \ @@ -138,13 +143,11 @@ ERR="$?" Output: $(< "$RSYNC_LOG") EOF - RET=1 + exit 1 else printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2 - RET=1 + exit 1 fi } -rm -f "$RSYNC_LOG" - -exit "${RET:-0}" +exit 0