diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-10-01 23:29:08 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-10-01 23:29:08 -0700 |
commit | 9125171789b3e3fb60ad27f405aed3a6a910726d (patch) | |
tree | 4ad82ad52c7dd28ea074057466257e40f056af31 | |
parent | 68090f7ada71f57f83d78f798148411f05721e7a (diff) | |
download | dotfiles-9125171789b3e3fb60ad27f405aed3a6a910726d.tar.gz |
workstation-duplicity sends notifications on failure
-rwxr-xr-x | bin/workstation-duplicity | 28 |
1 files 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 </dev/null; then + msg="Looks like SSH to backup host is possible." + else + msg="We're online, but couldn't SSH to the backup host." + fi + notify-send --urgency=critical --icon=dialog-warning \ + "duplicity could not connect" "$msg" ||: +fi |