From 9125171789b3e3fb60ad27f405aed3a6a910726d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 1 Oct 2020 23:29:08 -0700 Subject: workstation-duplicity sends notifications on failure --- bin/workstation-duplicity | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/workstation-duplicity b/bin/workstation-duplicity index d40681c3..c227f6ea 100755 --- a/bin/workstation-duplicity +++ b/bin/workstation-duplicity @@ -46,6 +46,7 @@ if ! [ -t 1 ]; then fi fi +set +e if [ -e "$FLAG_FILE" ]; then # attempt an incremental backup -- always incremental since we # might be running from a cronjob on weak coffee shop WiFi @@ -58,10 +59,25 @@ else # case files need to be restored duply $DUPLY_PROFILE full fi +exit=$? +set -e -# if it was successful, update flag file so cronjob doesn't do this -# again for four hours -touch $FLAG_FILE - -notify-send --urgency=low --icon=package_network \ - "duplicity incremental backup @ $(date '+%-l:%M%#p %Z')" ||: +if [ $exit = 0 ]; then + if [ -e "$FLAG_FILE" ]; then + type="incremental" + else + type="full" + fi + notify-send --urgency=low --icon=package_network \ + "duplicity $type backup @ $(date '+%-l:%M%#p %Z')" ||: + # update flag file so cronjob doesn't do this again for four hours + touch $FLAG_FILE +else + if nc -w1 -q0 ch-s012.rsync.net 22