diff --git a/releng.control/promote.sh b/releng.control/promote.sh
index dc4fa7f02c81b7ee599d597f817a0970e2890023..2fdb28742fbb9c7111ce5daf859d8a7b795d4a4d 100755
--- a/releng.control/promote.sh
+++ b/releng.control/promote.sh
@@ -8,6 +8,8 @@ function usage() {
     printf "\n\t\t%s\n\n" "where <projectname> is wtp-R2.0-M, wtp-R3.0-I, wtp-R3.0-N, etc." >&2	
 }
 
+source rsync-retry.sh
+
 verboseFlag=
 deleteOld=
 doCopy=
@@ -150,34 +152,12 @@ printf  "\t\t%s\n\n"   "using the build from ${FROMDIR}"
 
 if [ $doCopy ] 
 then
-	rsyncArgs="aru"
-    if [ $verboseFlag ] 
-    then
-    	rsyncArgs="${rsyncArgs}v"
-    fi
-     
-    maxTrys=5
-    exitCode=-1
-    nTrys=0
-    nPauseTime=120s
-    
-    until [ $exitCode == 0 ]
-    do 	
-     ${REMOTE_SSH_COMMAND} rsync -${rsyncArgs} ${FROMDIR} ${TODIR}
-     exitCode=$?
-     if [ $exitCode != 0 ]
-     then
-	     nTrys=$(($nTrys + 1))
-	     if [ $verboseFlag ] ; then
-             echo "rsync failed with $exitCode. Retrying $nTrys times after $nPauseTime."
-		     if [ $nTrys -gt $maxTrys ] ; then
-		     	 echo "Number of re-trys exceeded. rsync exit code: $exitCode"
-		     	 exit $exitCode
-		     fi
-	     sleep $nPauseTime
-         fi
-     fi 
-    done
+	rsync-retry ${FROMDIR} ${TODIR} $verboseFlag
+	exitCode=$?
+	if [ $exitCode -ne 0 ] 
+	then 
+		exit $exitCode
+	fi
 
     fromString="webtools/committers"
     toString="webtools/downloads"
diff --git a/releng.control/rsync-retry.sh b/releng.control/rsync-retry.sh
new file mode 100644
index 0000000000000000000000000000000000000000..aaedb84f145ea5616e1db8714aa82b72b9d4d7e2
--- /dev/null
+++ b/releng.control/rsync-retry.sh
@@ -0,0 +1,58 @@
+function rsync-retry () {
+    if [ -z $1 -o -z $2 ] 
+    then
+        echo "Invalid arguments. Usage is rsync-retry FROMDIR TODIR [verbose] [maxtrys] [pausetime]"
+        return 1
+    fi
+    local FROMDIR=$1
+    local TODIR=$2
+    if [ -z $3 ]
+    then
+       local verboseFlag=false
+    else
+       local verboseFlag=$3
+    fi
+    
+    if [ -z $4 ]
+    then
+       local maxTrys=5
+    else
+       local maxTrys=$4
+    fi
+
+    if [ -z $5 ]
+    then
+       local nPauseTime=120s
+    else
+       local nPauseTime=$5
+    fi
+
+    local rsyncArgs="aru"
+    if [ $verboseFlag ] 
+    then
+        rsyncArgs="${rsyncArgs}v"
+    fi
+     
+    exitCode=-1
+    nTrys=0
+    
+    until [ $exitCode == 0 ]
+    do  
+     ${REMOTE_SSH_COMMAND} rsync -${rsyncArgs} ${FROMDIR} ${TODIR}
+     exitCode=$?
+     if [ $exitCode != 0 ]
+     then
+         nTrys=$(($nTrys + 1))
+         if [ $verboseFlag ] ; then
+             echo "rsync failed with $exitCode. Retrying $nTrys times after $nPauseTime."
+             if [ $nTrys -gt $maxTrys ] ; then
+                 echo "Number of re-trys exceeded. rsync exit code: $exitCode"
+                 return $exitCode
+             fi
+         sleep $nPauseTime
+         fi
+     fi 
+    done
+    
+    return $exitCode
+}