#!/bin/sh # sync local server to remote Server etc based on $0 name # repeatedly calls rsync as required # # EBITS="--delete " prog=`basename $0 ` EXTRA_FLAGS="$*" # define stuff we dont want to copy EXCLUDE=' --exclude=This_is* --exclude=Exclude ' EXCLUDE_DOT=' --exclude=.bash_history --exclude=.screen* --exclude=.xauth --exclude=.Xauth* ' EXCLUDE_STATS=' --exclude=stats ' BW_LIMIT=64 DEST="" SOURCE="" ################################################ # Phil's homes # from there to here [ "${prog:-XXX}" = "me2local" ] && \ { DEST="$DEST /home-local/myname/" ; SOURCE="$SOURCE me@www.barnowls.net:~myname/" ;\ DEST="$DEST /home-local/fred/" ; SOURCE="$SOURCE me@wwwbarnowls.net:~fred/" ;\ EXCLUDE=" $EXCLUDE $EXCLUDE_DOT " ;\ } # from here to there [ "${prog:-XXX}" = "local2me" ] && \ { SOURCE="$SOURCE /home-local/myname/" ; DEST="$DEST me@www.barnowls.net:~myname/" ;\ SOURCE="$SOURCE /home-local/fred/" ; DEST="$DEST me@uk.barnowls.net:~fred/" ;\ EXCLUDE=" $EXCLUDE $EXCLUDE_DOT $EXCLUDE_STATS" ;\ } #### add more defs here as required ################################################ NUM_src=`echo $SOURCE | gawk ' {print NF ; exit } ' /dev/stdin` echo "There are $NUM_src passes" #EBITS=" --dry-run--delete --verbose --progress" EBITS=" --verbose --progress $EXTRA_FLAGS " export SOURCE DEST NUM_src EBITS EXCLUDE BW_LIMIT # # Note the ' in this ssh-agent bash -c ' echo $EBITS | gawk "/delete/ { print THIS DOES DELETE } " /dev/stdin echo $EBITS | grep "delete" && sleep 5 ssh-add ~pvd/.ssh/id_dsa count=1 until [ $count -gt $NUM_src ] do source=`echo $SOURCE | cut -d" " -f $count` dest=`echo $DEST | cut -d" " -f $count` echo " Session $count of $NUM_src Source $source Destination $dest " loop=1 echo " -e ssh -auz $EBITS $EXCLUDE --stats --bwlimit=$BW_LIMIT $source $dest" until rsync -e ssh -auz $EBITS $EXCLUDE --stats --bwlimit=$BW_LIMIT $source $dest do loop=`expr $loop + 1 ` [ $loop -gt 5 ] && break echo -n "restarting ...." sleep 5 # sleep 90 # give it 15 mins between restarts just in case its locked up echo try $loop done count=`expr $count + 1 ` done ' ## and the 's ends echo "The End"