diff --git a/backup-android.sh b/backup-android.sh index 1f13941..b480515 100755 --- a/backup-android.sh +++ b/backup-android.sh @@ -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..."