#!/bin/sh #---x----1----x----2----x----3----x----4----x----5----x----6----x----7----x # # File : syncdir.sh # Version : 1.1 # Date : 2001-Jan-22 # # Description : Uses rsync to sync a directory tree while ignoring # stuff in env var EXCLIST # # Usage : syncdir # # Revision History: # 2007-Jan-22 1.1 Default RSYNC_RSH set to ssh, override default # rsync behaviour of "if not set, use rsh" # 2004-Jul-08 1.0 Created # # Input : src, source dir in rsync format # dest, destination " " # EXCLIST, env var contains files/dirs to exclude (optional) # # Output : Generates a log file set with LOGFILE below # # Requires : # # Notes : rsync can use whatever method you like to connect. # ssh with keys is very transparent. setting the env var # RSYNC_RSH=ssh tells rsync to use ssh as its transport # mechanism # # ........................................................................ PROG=`basename ${0}` USAGE="${PROG}: usage: ${PROG} src dest \n \ e.g. ${PROG} /home/user/ destsys:/home/user \n \ note trailing /" ########## # Configuration variables ########## LOGDIR="/tmp" export RSYNC_RSH=${RSYNC_RSH:=ssh} # if unset, rsync transport set to SSH ########## # Main ########## if [ $# -ne 2 ]; then /bin/echo -e ${USAGE} exit 1 fi # We've made it this far, now set the logfile NOW=`/bin/date '+%Y%m%d-%H%M%S'` LOGFILE=${LOGDIR}/Sync.${NOW}.log # CLA's used by rsync # a - archive # c - checksum # v - verbose # z - compress # u - update, don't overwrite newer # n - dry run # --delete - delete files that don't exist on the sending side # --exclude - Don't sync # e.g. the Desktop # firefox cache dir # mozilla cache dir # #rsync -acvzu #rsync -acvz --delete # Set CLA for what rsync should exclude EXCLUDE="" if [ -n "$EXCLIST" ]; then for I in $EXCLIST; do EXCLUDE="$EXCLUDE --exclude $I" done fi rsync --archive --checksum --verbose --delete $EXCLUDE $1 $2 > $LOGFILE &