monitors:xymon-duplicity

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

xymon-duplicity

Author Damien
Compatibility Xymon 4.2 / 4.3
Requirements Basic unix tools
Download Part of https://github.com/doktoil-makresh/xymon-plugins/
Last Update 2020-05-17

This script will connect to your duplicity server to check the status of backups (see xymon-duplicity.cfg)

Client side

Add this entry in /etc/sudoers.d/xymon Adapt the name (root) to the user launching the backups Adapt the path to duplicity xymon ALL=(root) NOPASSWD: /usr/local/bin/duplicity

Server side

Nothing

Show Code ⇲

Hide Code ⇱

#!/bin/bash                                                                                                                                                                      
#Verifying if the backup plan is working or not                                                                                                                                  
#Heavily inspired by https://camille.wordpress.com/2017/09/20/incremental-backups-with-duplicity-plus-nagios-monitoring/
TEST=duplicity
INTERVAL=12h
export LANG=en_US
CONFIG_FILE=${XYMONCLIENTHOME}/etc/xymon/xymon-duplicity.cfg
BACKUP_BASE_DIR=${DUPLICITY_PROTOCOL}://${DUPLICITY_USER}@${DUPLICITY_SERVER}

#Debug
if [ "$1" == "debug" ] ; then
        echo "Debug ON"
        XYMON=echo
        XYMONCLIENTHOME="/usr/lib/xymon/client"
        XYMONTMP="$PWD"
        XYMONDISP=your_xymon_server
        MACHINE=$(hostname)
fi

STATUS_FILE=${XYMONTMP}/xymon-duplicity.tmp
#Load configuration file
source $CONFIG_FILE

#Check each folders defined in Xymon_duplicity_config_file
TODAY=$(LANG=en_US date +%c | awk '{print $1,$2,$3}')
YESTERDAY=$(LANG=en_US date +"%c" -d yesterday | awk '{print $1,$2,$3}')

for FOLDER in $FOLDERS ; do
	COLLECTION_STATUS=$(sudo duplicity collection-status $BACKUP_BASE_DIR/$HOST/$FOLDER 2 > /dev/null)
	exitcode=$?
	LATEST=$(echo $COLLECTION_STATUS | egrep "^Chain end time:" | tail -n 1 | awk '{print $4,$5,$6}' | sed  s/\ \/\ /)
	
#Check backup status
	echo "Checks for $FOLDER backup:" >> $STATUS_FILE
	if [[ $exitcode != 0 ]] ; then
		red=1
		echo "&red Critical - Unable to perform the check command"
	fi
	if [[ $LATEST == "" ]] ; then
		red=1
		echo "&red Critical - No backup found at $BACKUP_BASE_DIR/$HOST/$FOLDER" >> $STATUS_FILE
	fi
	if [[ $LATEST == *$TODAY* ]] ; then
		echo "&green OK - $LATEST" >> $STATUS_FILE
	elif [[ $LATEST == *$YESTERDAY* ]] ; then
		yellow=1
		echo "&yellow Warning - $LATEST" >> $STATUS_FILE
	else
		red=1
		echo "&red Critical - $LATEST" >> $STATUS_FILE
	fi
done

#Define global status
if [ "$red" == 1 ] ; then
	global_color=red
elif [ "$yellow" == 1 ] ; then
	global_color=yellow
else
	global_color=green
fi

#Send Xymon the results
"$XYMON" "$XYMSRV" "status+"$INTERVAL" "$MACHINE"."$TEST" "$global_color" $(date)

$(cat $STATUS_FILE)
"

None

Monitor backups on several duplicity servers

  • 2020-05-17
    • Initial release
  • monitors/xymon-duplicity.txt
  • Last modified: 2020/05/17 09:02
  • by doktoil_makresh