From 5b450cda673408e5dfe1c20cb9a82e9468063692 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 24 Mar 2025 12:38:39 +0000 Subject: [PATCH] Add network connection test Script now waits for network connectivity before attempting backup. Useful when ran on a laptop, systemd may trigger before network is back up. --- backup.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backup.sh b/backup.sh index d03b9a7..f7d6a2d 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,16 @@ #!/bin/bash exec &>>/var/log/restic.log source /etc/restic/restic_env.sh + +# Check network connectivity +if [[ -x /usr/bin/nmcli ]]; then + while [[ $(nmcli n connectivity check) != "full" ]]; do + echo "No network connection... " + sleep 10 + echo "Checking network" + done +fi + cd ${BACKUP_ROOT} date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Starting backup" restic backup --exclude-file /etc/restic/excludes.txt .