Perpetual rsync


Automatically resume rsync over SSH after broken connection
Create a file in /bin/prsync


#!/bin/bash
### COPY IN /bin/prsync - chmod 777 ###
# GitHub https://gist.github.com/pwenzel/4182838
# Extended by Gulshan Beejan - Persistent RSYNC# Make sure remote system has ssh key pairsif [[ -z $1 ]] ; then
echo "Persistent RSYNC Usage: prsync SOURCE DESTINATION"
exit
fi
if [[ -z $2 ]] ; then
echo "Persistent RSYNC Usage: prsync SOURCE DESTINATION"
exit
fiwhile [ 1 ]
do
rsync -avz --partial $1 $2
if [ "$?" = "0" ] ; then
echo "prsync completed normally"
exit
else
echo "==== prsync failure. ==== Backing off and retrying in 30 seconds..."
sleep 30
fi
done


chmod +x /bin/prsync

then you can run it as:

prsync mysource_file.tar user@destination_ip:/path/to/file

Gulshan Yashveer Beejan

Gulshan holds a BSc(Hons) Computer Science with Distributed systems from the City University of London. He is currently working at DSOGroup(Mauritius) as a Linux Administrator on SaaS Solutions. More about Gulshan

Leave a Reply

Your email address will not be published. Required fields are marked *