Script now waits for network connectivity before attempting backup. Useful when ran on a laptop, systemd may trigger before network is back up.
19 lines
564 B
Bash
Executable file
19 lines
564 B
Bash
Executable file
#!/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 .
|
|
date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Pruning old files"
|
|
restic prune
|
|
date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Backup complete"
|