[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Rsync question



Sunny Dubey wrote:
> 
> hi
> 
> does anyone have an example script or something in which a client will
> connect to a rsync server, and update whatever changes have occured?
> I tried to create my own, however that didn't do too well hehe
> 
> thanks
> 
> Sunny Dubey
> 
> --
> To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



shouldn't be too hard to find out how to do this; "rsync --help" should
give you a good start, use the '-n' flag and try a bit.  Anyway, the
included script bellow is our "default template" for seting up new
scripts.  It is probably quite overkill for you, but might still be used
for inspiration...  Of course you'll have to adjust the paths to your
system.


----script start----
#!/usr/local/bin/bash

#
#-- fill in host and dirs
#
RHOST=
RDIR=
LDIR=
#-- unwanted stuff, entered as ' " [ --exclude XXXXX ] ..." '
EXCLUDES=""
CONTACT=""


#
#-- normally there's no need to change anything except '--exclude XXXXX'
bellow
#-- this line
#

RSYNC=/home/mirror/bin/rsync
LHOST=`uname -n`
SCRNAME=$0
DATE=`date +%Y%m%d_%H:%M`
LOGNAME=`echo $SCRNAME |sed 's/\(.*\)\/\([^/]*\).rsync/\2/'`
LOGDIR=/home/mirror/logs/${LOGNAME}.rsync
LOGFILE=${LOGDIR}/${LOGNAME}_${DATE}
LOCKFILE=/home/mirror/locks/${LOGNAME}.lock


if [ -f $LOCKFILE ]; then
  echo "$LHOST is unable to start $SCRNAME since $LOCKFILE exists" \
  |tee /dev/stderr \
  |tee $LOGFILE \
  |mailx -s "$SCRNAME failed" archive-log@ftp.sunet.se
  exit 1
fi


if [ ! -d $LOGDIR ]; then mkdir -p ${LOGDIR}; fi
touch $LOCKFILE
echo "you may pass three extra arguments to the script, e.g.  -n or
extra --exclude"
echo "now running $0"
echo "logging to $LOGFILE"

$RSYNC $1 $2 $3 -auv --stats --delete \
  $EXCLUDES \
  $RHOST::$RDIR  $LDIR  2>&1 \
  |tee /dev/stderr \
  |tee $LOGFILE \
  |mailx -s $SCRNAME archive-log@ftp.sunet.se
rm -f $LOCKFILE


EXITLINES=`tail -2 $LOGFILE \
  |/usr/local/bin/grep \
     -e "io timeout after" \
     -e "read error: Connection timed out" \
     -e "unexpected EOF in read_timeout"`
if [ "$EXITLINES" != "" ]; then
  sleep 15
  exec $0 $1 $2 $3
fi

----script end-----



Reply to: