remove obsolete comment and trim unnecessary whitespace and lines

Signed-off-by: Felix Bartels <felix@host-consultants.de>
This commit is contained in:
Felix Bartels 2018-01-21 11:28:14 +01:00
parent 998687fdbe
commit 450165ed99

View file

@ -1,19 +1,15 @@
#! /bin/bash #! /bin/bash
set -uo pipefail set -uo pipefail
#backup li run display_usage() {
#backup li
display_usage() {
echo "Usage: $0 <repo> (local|monitor <host> <warning> <critical>|restic arguments)" >&2 echo "Usage: $0 <repo> (local|monitor <host> <warning> <critical>|restic arguments)" >&2
} }
if [ "$#" -lt 2 ]; then if [ "$#" -lt 2 ]; then
display_usage display_usage
exit 1 exit 1
fi fi
TARGET=$1 TARGET=$1
ACTION=$2 ACTION=$2
RESTIC=$(which restic) RESTIC=$(which restic)
@ -26,7 +22,7 @@ check_config() {
exit 1 exit 1
else else
set -a set -a
source $CONFIG source $CONFIG
set +a set +a
fi fi
@ -35,8 +31,6 @@ check_config() {
echo "Restic binary not found" echo "Restic binary not found"
exit 1 exit 1
fi fi
} }
handle_params () { handle_params () {
@ -64,7 +58,7 @@ do_local_backup () {
/etc/backup/local.pre $TARGET /etc/backup/local.pre $TARGET
fi fi
$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 [[ -x /etc/backup/local.post ]]; then if [[ -x /etc/backup/local.post ]]; then
/etc/backup/local.post $TARGET /etc/backup/local.post $TARGET
@ -94,7 +88,7 @@ do_monitor () {
IFS=' ' read HASH DATE TIME HOST DIR <<< "$LAST" IFS=' ' read HASH DATE TIME HOST DIR <<< "$LAST"
if [ -z "$HASH" ]; then if [ -z "$HASH" ]; then
echo "UNKNOWN - No snapshot found for $3" echo "UNKNOWN - No snapshot found for $3"
exit 4; exit 4;
fi fi
@ -109,6 +103,7 @@ do_monitor () {
BACKUP_TST=$(date -d "$DATE $TIME" +"%s" ) BACKUP_TST=$(date -d "$DATE $TIME" +"%s" )
;; ;;
esac esac
NOW_TST=$(date +%s) NOW_TST=$(date +%s)
DIFF_S=`expr $NOW_TST - $BACKUP_TST` DIFF_S=`expr $NOW_TST - $BACKUP_TST`
@ -124,7 +119,7 @@ do_monitor () {
elif [ $DIFF_H -lt $CRIT ]; then elif [ $DIFF_H -lt $CRIT ]; then
RET=1 RET=1
RET_H="WARNING" RET_H="WARNING"
else else
RET=2 RET=2
RET_H="CRITICAL" RET_H="CRITICAL"
@ -133,9 +128,5 @@ do_monitor () {
return $RET return $RET
} }
check_config $@ check_config $@
handle_params $@ handle_params $@