Duply: notify backup exit status to Zabbix

I’ve started using duplicity with duply since some time, and I’m quite happy with it.

I also use Zabbix, and I’m very happy of it! How to combine the two? Pretty easy: duply has the ability to run a command after the execution of a backup.

Change PROFILE according to your setup, create ~/.duply/PROFILE/post with the following content:

#!/bin/sh

if [ ! -f /etc/zabbix/zabbix_agentd.conf ] ; then
	# No zabbix installed
	exit 0;
fi
/usr/bin/zabbix_sender -z $(grep ^Server= /etc/zabbix/zabbix_agentd.conf |cut -d= -f2|cut -d, -f1) \
                 -s $(grep ^Hostname= /etc/zabbix/zabbix_agentd.conf |cut -d= -f2|cut -d, -f1) \
                 -k duply.backup -o $CMD_ERR > /dev/null

exit $?

Make it executable with

chmod +x ~/.duply/PROFILE/post

And make sure you have zabbix-sender package installed!

apt install zabbix-sender

Now that we have prepared Duply let’s move on Zabbix frontend and create the check item like the one in the image (bonus: there’s a template exported below):

Duply status Zabbix item

This will be the receiver of the zabbix-sender command we will launch in the post. The type Zabbix trapper is just a way to make it kind of passive item. Now you can create the triggers you want, for example if the last value is not 0 it means the backup didn’t complete successful. Or, since it’s a passive item, if there’s no data in the last x hours the backup didn’t run:

If you’re fit with the examples above you can download and import my template for Zabbix 3.0, and apply it to any host running duply.

Header photo by Daniel von Appen on Unsplash

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Solve : *
5 + 17 =


Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.