Retry RSync on Connection Errors

This script allows RSync job to retry if it fails, the delay between each try doubles on each retry to a max of 10 trys (about 17 hours).

Copy the text into a .bat file, ie RSync to External Server.bat, and rsync command line with your own.

@echo off
set trys=0
set waitmin=1
set waitsecs=60
:loop
cls
color 47
echo ##CHANGE TO RSYNC JOB NAME##
set /a trys+=1
set /a waitmin=%waitmin%*2
set /a waitsecs=%waitmin%*60
echo Try %trys%:
rsync\rsync.exe "-rltv" "--progress" "--hard-links" "--delete" "--ignore-errors" "--force" "--no-whole-file" "-z" "--link-dest=." "--exclude=/cygdrive" "--exclude=/proc" "/cygdrive/Z/ServerFolders/Music/" "rsync://rsyncserver.org/Music"
if %ERRORLEVEL% NEQ 0 (
 echo Retrying in %waitmin% minutes - %waitsecs% seconds
 TIMEOUT /t %waitsecs%
 if %trys% LSS 10 goto loop
 echo Could not finish sync in 10 trys, inform Adminstrator
 )
pause

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s