aboutsummaryrefslogtreecommitdiffstats
path: root/arch-system/borgbackup
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-07-31 21:46:28 +0200
committerTharre <tharre3@gmail.com>2018-07-31 21:48:10 +0200
commit43219efeeb0357e8c4a671f4784cacbf2decfd81 (patch)
tree5b2552a845eddfc3467d4994c35310cf2909fb19 /arch-system/borgbackup
parent91fa8c46fb87503cc083f12fea1ed2792992ad64 (diff)
downloadpkgbuilds-43219efeeb0357e8c4a671f4784cacbf2decfd81.tar.gz
pkgbuilds-43219efeeb0357e8c4a671f4784cacbf2decfd81.tar.xz
pkgbuilds-43219efeeb0357e8c4a671f4784cacbf2decfd81.zip
arch-system: borgbackup: treat rc 1 as a warning
Diffstat (limited to 'arch-system/borgbackup')
-rwxr-xr-xarch-system/borgbackup20
1 files changed, 14 insertions, 6 deletions
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