diff options
author | Tharre <tharre3@gmail.com> | 2018-07-31 21:46:28 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2018-07-31 21:48:10 +0200 |
commit | 43219efeeb0357e8c4a671f4784cacbf2decfd81 (patch) | |
tree | 5b2552a845eddfc3467d4994c35310cf2909fb19 | |
parent | 91fa8c46fb87503cc083f12fea1ed2792992ad64 (diff) | |
download | pkgbuilds-43219efeeb0357e8c4a671f4784cacbf2decfd81.tar.gz pkgbuilds-43219efeeb0357e8c4a671f4784cacbf2decfd81.tar.xz pkgbuilds-43219efeeb0357e8c4a671f4784cacbf2decfd81.zip |
arch-system: borgbackup: treat rc 1 as a warning
-rw-r--r-- | arch-system/PKGBUILD | 2 | ||||
-rwxr-xr-x | arch-system/borgbackup | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/arch-system/PKGBUILD b/arch-system/PKGBUILD index 9aaaed1..917e2b8 100644 --- a/arch-system/PKGBUILD +++ b/arch-system/PKGBUILD @@ -31,7 +31,7 @@ sha256sums=('bb00c42f2802c12536c46700b948d41a43153d97a6986827b7c61203880e1ad1' '99cd268de0e9b847d65f802e7bcbbf7318398a04db61523545d4002ebdfb4d9c' '42050ba722df1cd606288e82054e131dac99bf10506f4c8d52eb9bfc0a078d89' 'e1bf3dc5978a7641f86975b7ee770a6914b30a8e4b7e3be2f1b07eaa7098591d' - 'be7680a72e5b5d4188be8f24e6ceb890c6acd6a281f8a1b992d6e8304902d4bf' + 'ba4e0a45cd428678ccb3b9981131333c2afa450107ca4a4bda475748ef915628' 'b9f38ad0731a5b65d49eaacd0fb8cfe051b6ca7ea68496d89919701842183d89') package_base-system() { diff --git a/arch-system/borgbackup b/arch-system/borgbackup index 5d6c8b4..66d1a36 100755 --- a/arch-system/borgbackup +++ b/arch-system/borgbackup @@ -16,10 +16,14 @@ cleanup() { sudo -n /usr/bin/backup-sudo cleanup } -handle_failure() { +notify_user() { if ! [ -t 1 ]; then - notify-send -u critical "Backup failed!" + notify-send "$@" fi +} + +handle_failure() { + notify_user -u critical "Backup failed!" echo "Backup failed!" >&2 cleanup @@ -46,7 +50,13 @@ backup() { borg create --stats $borg_progress \ --exclude-from ~/.borg_exclude \ --show-rc \ - ::"$(basename "$1")" . + ::"$(basename "$1")" . && rc=$? || rc=$? + if [ $rc -eq 1 ]; then + # borg defines return code 1 as warning, usually permission stuff + notify_user "Warning: borgbackup returned 1. Check logs" + elif [ $rc -gt 1 ]; then + handle_failure + fi cleanup sudo -n backup-sudo delete_snapshot "$1" @@ -59,9 +69,7 @@ fi if ! ssh -To BatchMode=yes -o ConnectTimeout=$NETWORK_TIMEOUT \ -o IdentitiesOnly=yes -o ConnectionAttempts=20 -i ~/.ssh/borg_key \ "$BORG_HOST" "borg --version" > /dev/null; then - if ! [ -t 1 ]; then - notify-send "Backups: upload skipped" - fi + notify_user "Backup: upload skipped" echo "SSH server not reachable, skipping upload" >&2 exit 0 fi |