Merge pull request #3 from jpmens/monitor

add nolock to snapshots and protect curl existance
This commit is contained in:
Alexander Rust 2017-09-05 12:42:16 +02:00 committed by GitHub
commit 6dec919e09

View file

@ -17,6 +17,7 @@ fi
TARGET=$1
ACTION=$2
RESTIC=$(which restic)
CURL=$(which curl)
check_config() {
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
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
}
@ -74,7 +77,7 @@ do_monitor () {
CRIT=$5
# 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
exit 1;
fi