add nolock to snapshots and protect curl existance

- also remove trailing white space
This commit is contained in:
Jan-Piet Mens 2017-09-05 12:39:33 +02:00
parent f5410c38e2
commit 70883ec6ee

View file

@ -17,6 +17,7 @@ fi
TARGET=$1 TARGET=$1
ACTION=$2 ACTION=$2
RESTIC=$(which restic) RESTIC=$(which restic)
CURL=$(which curl)
check_config() { check_config() {
CONFIG=/etc/backup/$1.repo CONFIG=/etc/backup/$1.repo
@ -61,7 +62,9 @@ do_local_backup () {
$RESTIC --exclude-file /etc/backup/local.exclude backup --hostname $BACKUP_HOSTNAME $BACKUP_DIR $RESTIC --exclude-file /etc/backup/local.exclude backup --hostname $BACKUP_HOSTNAME $BACKUP_DIR
if [ -n "$HEALTHCHECK_URL" ]; then if [ -n "$HEALTHCHECK_URL" ]; then
curl -fsS --retry 4 "$HEALTHCHECK_URL" > /dev/null if [[ ! -e $CURL ]]; then
$CURL -fsS --retry 4 "$HEALTHCHECK_URL" > /dev/null
fi
fi fi
} }
@ -74,7 +77,7 @@ do_monitor () {
CRIT=$5 CRIT=$5
# Get last line and parse into variables. Removes header and is empty when no snapshot exists for host # Get last line and parse into variables. Removes header and is empty when no snapshot exists for host
LAST=`$RESTIC snapshots -H $3 | sed 1,2d | tail -n 1` LAST=`$RESTIC snapshots --no-lock -H $3 | sed 1,2d | tail -n 1`
if [ ! $? -eq 0 ]; then if [ ! $? -eq 0 ]; then
exit 1; exit 1;
fi fi