Friday, April 17, 2009

Remote backups made easy (2)

A little variation, or enhancement if you will, on my previous rsnapshot supplement script


#!/bin/sh

## rsync.sh

USER='some.username'
HOST='my.backup.server'
WORK_DIR='/var/backups/hourly.0/localhost/my.server.01/'
REMOTE_DIR='/home/some.username/backups/xxxx/XXXX/my.server.01/'
PRIORITY='/bin/nice -n +19'
RSYNC='/usr/bin/rsync'
RSYNC_OPTS='-e ssh -avzr --delete --bwlimit=20'
EXCLUDE_LIST='/the/path/to/exc.rsync.list'
ECHO='/bin/echo'
CAT='/bin/cat'
MAIL='/bin/mail'
DATE='/bin/date'
LOGFILE='/tmp/_rsync.my.server.01.log'
DEST='someemailaddress@somedomain'


${ECHO} `${DATE}`: Start rsync ${HOSTNAME} to ${HOST} > ${LOGFILE}

cd ${WORK_DIR}

${PRIORITY} ${RSYNC} ${RSYNC_OPTS} --exclude-from=${EXCLUDE_LIST} * ${USER}@${HOST}:${REMOTE_DIR} >> ${LOGFILE}

${ECHO} `${DATE}`: Finish rsync >> ${LOGFILE}
${CAT} ${LOGFILE} | ${MAIL} -s "Rsync ${HOSTNAME} to ${HOST}" ${DEST}

# EoF #

Labels: , , ,

0 Comments:

Post a Comment

<< Home