Rsync backup CentOS server with email report

Running various business critical CentOS based Linux servers means good backups are a must. The ability to restore completely from backup to a DR site is a must.

To do this I keep a copy of the server backed up at root level on a locally hosted NAS.

A nightly rsync runs, with appropriate exlucsions that keeps a local copy of the system in sync. Data usage on the various Web/DNS/email servers I run works out to be around 50-200mb a night.

rm -f /var/log/sync/*

rsync -avzh –delete –stats server1.com:/  /store/backup/server1/ >/var/log/sync/server1 –exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/home/*/.gvfs,usage/*}

tail /var/log/sync/* | mail -s “Server sync report”logs@myemail.com

add a rsync line for each server.

the rsync logs are kept in /var/log/sync. To know if it was a success I can monitor the email. As I’m really only interested in success/fail i use tail to only show me the last few lines of each log.

To restore, do a minimal install of the same CentOS version, install rsync, and rsync directly over root from the backup. Reboot to bring the new system back online as per the last backup.

Leave a Reply

Your email address will not be published. Required fields are marked *