#!/bin/ksh # This script performs an rsync between one directory and another, assuming # it's going to be used for making an "alt" backup of your / partition. # The destination must be a mounted drive (not a subdirectory). #### Configuration: Edit the next few lines to set this script up. # BUILDEXCLUDE: Full path the the build.exclude script that creates the # exclude list for rsync. BUILDEXCLUDE=/YOURSCRIPTDIR/build.exclude #### End of configuration # Check number of arguments. if [[ $# != 2 ]] then echo " Usage: $0 fileSys1 fileSys2 Example: $0 / /alt " exit 1 fi # Parse command line. fileSys1=$1 fileSys2=$2 # Check that the alternate filesystem is mounted. mount ${fileSys2} > /dev/null 2>&1 output=`df -P ${fileSys2} | grep -v Filesystem | awk '{print $NF}'` if [[ ${output} != "${fileSys2}" ]] then echo "Destination file system is not mounted" exit 1 fi # Build exclude list. $BUILDEXCLUDE /tmp/exclude.list # Do the actual rsync. /usr/bin/rsync -avHS --delete --exclude-from=/tmp/exclude.list ${fileSys1}/ ${fileSys2} # fsck the filesystem for partion fileSys2 cd / dev=`df -k |egrep "% ${fileSys2}$"|awk '{print $1}'` umount ${fileSys2} /sbin/fsck -a -f ${dev} mount ${fileSys2}