#!/bin/bashLOG='/var/log/backup.log'TARGET='/backup'CLIENTS='/client'EXCLUDES='/client/excludes'log() { touch "${LOG}" || exit 1 DATA="$(date +"%b %d %H:%M:%S") localhost backup-sync[$$]: ${1}" echo "${DATA}" >> "${LOG}"}die() { log "${1}" || exit 1 exit 1}# Back up client machines by mounting NFS volumesfor CLIENT in prescott do SRC="${CLIENTS}/${CLIENT}" DST="${TARGET}/${CLIENT}" mount "${SRC}" || die "Could not mount client ${CLIENT}" RSYNC_OPT="-av ${SRC}/. ${DST}/." log "No exclude file for client ${CLIENT}" log "Starting sync of client ${CLIENT}" rsync -a --exclude-from=/client/excludes/${CLIENT}.excl ${SRC}/. ${DST}/. 1> /dev/null 2>&1 if [[ $? -gt 0 ]] then die "Could not sync client ${CLIENT}" fi log "Finished sync of client ${CLIENT}" umount "${SRC}" || die "Could not unmount ${CLIENT}" done