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.
This commit is contained in:
parent
1f5cbd6061
commit
5b450cda67
1 changed files with 10 additions and 0 deletions
10
backup.sh
10
backup.sh
|
@ -1,6 +1,16 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
exec &>>/var/log/restic.log
|
exec &>>/var/log/restic.log
|
||||||
source /etc/restic/restic_env.sh
|
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}
|
cd ${BACKUP_ROOT}
|
||||||
date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Starting backup"
|
date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Starting backup"
|
||||||
restic backup --exclude-file /etc/restic/excludes.txt .
|
restic backup --exclude-file /etc/restic/excludes.txt .
|
||||||
|
|
Loading…
Add table
Reference in a new issue