Retry rsync up to 10 times

This commit is contained in:
Austen Adler 2018-09-23 13:58:41 -04:00
parent 93f9ba9198
commit 1c9186aa1c

View File

@ -28,7 +28,19 @@ function time_diff {
function backup() {
# First, we need to rsync our changes to the host
echo "Running rsync..."
$RSYNC_COMMAND "$SOURCE_LOCATION" "$REMOTE_HOST:$DESTINATION_LOCATION" || return 1
local RETRIES=10
while (( RETRIES > 0 )); do
# Try to rsync
$RSYNC_COMMAND "$SOURCE_LOCATION" "$REMOTE_HOST:$DESTINATION_LOCATION" && break
(( RETRIES-- ))
echo "rsync failed. Retrying $RETRIES more times. Sleeping 10s"
sleep 10s
done
if (( RETRIES == 0 )); then
# We exceeded the retry limit. Fail
return 1
fi
# Next, instruct the host to create a borg
echo "Running borg..."