Since we (slow bit dudes) are in the mood of contributing rsync enhancer scripts, here is mine. It will run another simple script containing the rsync command, and monitor if it dies, stalls, or your ppp reconnects. I first wrote it because I was tired of leaving rsync running in the morning, and when I came back discover the it had only downloaded for an hour or so and the stalled, etc. Attached are the rsyncmonitor and a sample rsync script. it is supposed top be run like this; rsyncmonitor <fullpathtorsyncscript> If you put both scripts in the same directory and your rsync script is called "update-cooker" it would be something like this: ./rsyncmonitor ./update-cooker Disclaimer: It is quick and dirty!!! A known problem I haven't fixed is that if you encounter a big file while using the "delete" option on your rsync script, if your ISP keeps disconecting (BTW for it to work you need to set your PPP connection to autoreconnect, I have also included a simple script to minimize disconnections, "keeppppup"; you can run it on your "/etc/ppp/ip-up.local") you before the file is finished, then you go in a loop of download-delete (since rsync is killed with -9, it does not renames the ".filename.xxxx" rsync creates, and it is deleted next time rsync is run). We should combine this script with Allen's. -- Eugenio Diaz, BSEE/BSCE Linux Engineer [EMAIL PROTECTED]
#!/bin/bash # This script will monitor an rsync session, and restart it if it is interrupted # in any way. # # By Eugenio Diaz - mailto:[EMAIL PROTECTED] # Released under the GNU GPL copyleft License, http://www.fsf.org # # # Parameters # IDELAY='2m' WDELAY='5m' RDELAY='5m' DIR='/home/ftp/pub/linux' ISTATUS=`netstat -i|grep ppp0` RSTATUS=`ps ax|grep rsync` echo echo "Initial delay before starting monitoring cycle: $IDELAY" echo "Monitoring cycle period: $WDELAY" echo "Restart delay: $RDELAY" echo echo "Spawninig: $1" echo $1 & sleep $IDELAY echo echo "Starting monitor." echo while true do if [ "$ISTATUS" = "" ]; then echo "Not connected, exiting ..." exit 1 elif [ "$RSTATUS" = "" ]; then echo "Rsync no longer running. Mirror complete? Exiting ..." exit 0 else T1=`du -sk $DIR|gawk '{print $1}'` sleep $WDELAY T2=`du -sk $DIR|gawk '{print $1}'` T=$(($T2-$T1)) if [ "$T" != "0" ]; then echo echo "Rsync wrote $T k in the last $WDELAY; monitoring status OK." echo else echo echo "Rsync connection dead, killing rsync ..." killall -9 $1 rsync &> /dev/null echo echo "Waiting $RDELAY for interfaces to reconnect ... " sleep $RDELAY echo echo "Restarting rsync by spawning: $1" echo "And waiting, $IDELAY, before restarting monitoring." echo $1 & sleep $IDELAY echo echo "Starting monitor." echo fi fi done exit 0
#!/bin/sh # Sync main cooker distro dir rsync -av --exclude-from=filelist --partial --delete --force rpmfind.net::linux/MandrakeCooker/cooker/cooker/Mandrake/RPMS /home/ftp/pub/linux/mandrake-devel/cooker/Mandrake
#!/bin/bash while true; do ping -c 1 $1 > /dev/null; sleep 30; done
