Retry rsync up to 10 times
This commit is contained in:
parent
93f9ba9198
commit
1c9186aa1c
@ -28,7 +28,19 @@ function time_diff {
|
|||||||
function backup() {
|
function backup() {
|
||||||
# First, we need to rsync our changes to the host
|
# First, we need to rsync our changes to the host
|
||||||
echo "Running rsync..."
|
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
|
# Next, instruct the host to create a borg
|
||||||
echo "Running borg..."
|
echo "Running borg..."
|
||||||
|
Loading…
Reference in New Issue
Block a user