diff options
author | Tharre <tharre3@gmail.com> | 2018-08-07 03:01:38 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2018-08-07 04:31:00 +0200 |
commit | f90a5be438306e5f92948199b2365c7d1f2f54f7 (patch) | |
tree | f8f4e8a4c328c5df427589777e6fc4cc4bdebf23 /arch-system/borgbackup | |
parent | 5223a9537c69621a5b77644c4d78c989439bb682 (diff) | |
download | pkgbuilds-f90a5be438306e5f92948199b2365c7d1f2f54f7.tar.gz pkgbuilds-f90a5be438306e5f92948199b2365c7d1f2f54f7.tar.xz pkgbuilds-f90a5be438306e5f92948199b2365c7d1f2f54f7.zip |
arch-system: borgbackup: better connectivity check
Instead of trying to execute borg, which would give us a false positive
if borg itself isn't working on the remote, just connect to the server
without executing a command.
We check for 255 because `man 1 ssh` states the following:
ssh exits with the exit status of the remote command or with 255 if
an error occured.
Diffstat (limited to 'arch-system/borgbackup')
-rwxr-xr-x | arch-system/borgbackup | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/arch-system/borgbackup b/arch-system/borgbackup index 66d1a36..fdd410d 100755 --- a/arch-system/borgbackup +++ b/arch-system/borgbackup @@ -5,11 +5,11 @@ set -o errexit -o errtrace BORG_HOST="borg@borg1.th73.ovh" export BORG_REPO="$BORG_HOST:." export BORG_PASSPHRASE="$(< ~/.borg_secret)" -export BORG_RSH="ssh -o IdentitiesOnly=yes -o ConnectionAttempts=20 -i ~/.ssh/borg_key" +export BORG_RSH="ssh -o IdentitiesOnly=yes -o ConnectionAttempts=20 \ + -o ConnectTimeout=30 -i ~/.ssh/borg_key" export LC_COLLATE=C SNAPSHOT_TARGET="/.snapshots/home-$(date "+%Y-%m-%dT%H:%M:%S")" -NETWORK_TIMEOUT=30 cleanup() { cd / @@ -66,12 +66,13 @@ if [ ! -d "$SNAPSHOT_TARGET" ]; then sudo -n backup-sudo snapshot "$SNAPSHOT_TARGET" 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 +$BORG_RSH "$BORG_HOST" -f -N || rc=$? +if [ ${rc-0} -eq 255 ]; then notify_user "Backup: upload skipped" echo "SSH server not reachable, skipping upload" >&2 exit 0 +elif [ ${rc-0} -ne 0 ]; then + handle_failure fi # break locks in case the previous run was interrupted |