Use / on end of mountpoint test in do-backup.

This commit is contained in:
Darren 'Tadgy' Austin 2023-11-06 20:38:43 +00:00
commit 70443978b6

View file

@ -9,7 +9,8 @@
# Base configuration. # Base configuration.
RSYNC_OPTIONS=( '-a' '-H' '-A' '--timeout=300' '--partial' '--partial-dir=.rsync-tmp' '--delete-delay' '--delay-updates' ) RSYNC_OPTIONS=( '-a' '-H' '-A' '--timeout=300' '--partial' '--partial-dir=.rsync-tmp' '--delete-delay' '--delay-updates' )
RSYNC_OPTIONS_VERBOSE=( '--verbose' '--stats' '--human-readable' ) 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. # Sanity checks.
(( $# != 1 )) || [[ -z "$1" ]] || [[ "$1" =~ ^(-h|-help|--help)$ ]] && { (( $# != 1 )) || [[ -z "$1" ]] || [[ "$1" =~ ^(-h|-help|--help)$ ]] && {
@ -17,6 +18,9 @@ RSYNC_LOG="/tmp/${0##*/}-$$.log"
exit 1 exit 1
} }
# Remove temporary files upon exit.
trap 'rm -f "$RSYNC_LOG"; rm -f "$LOCK_FILE"' EXIT
# Get backup definition specific configuration. # Get backup definition specific configuration.
case "$1" in case "$1" in
'gv0') 'gv0')
@ -93,7 +97,8 @@ source /etc/mail.conf "backups" 2>/dev/null || {
} }
# Make sure BACKUP_MOUNTPOINT is a mountpoint. # 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}" [[ -x /opt/bin/pushover-client ]] && /opt/bin/pushover-client "backups" -p -1 -m "Backup failure: ${ERRORS_SOURCE:-$RSYNC_SOURCE}"
if [[ -n "${EMAIL_TO[*]}" ]]; then 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 || \ 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: Output:
$(< "$RSYNC_LOG") $(< "$RSYNC_LOG")
EOF EOF
RET=1 exit 1
else else
printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2 printf "%s: %s\\n" "${0##*/}" "no recipient configured for mail delivery" >&2
RET=1 exit 1
fi fi
} }
rm -f "$RSYNC_LOG" exit 0
exit "${RET:-0}"