Wednesday 17 April 2013

Backing up QNAP Server with CentOS Rsnapshot Server

To do a full backup of our QNAP server I built a CentOS 6.3 machine with plenty of SATA storage. This CentOS server has Rsnapshot installed so that it will not only backup the QNAP, but will also provide incremental backups for accidentally erased or overwritten files on the QNAP.

Webmin
The CentOS server has Webmin installed for easy configuration. Access to webmin is trough port 10000.

QNAP shares work around
For backup up the QNAP the internal Rsync server is enabled and a username and password is set. To prevent the necessity of having to add all shares of the QNAP manually, and updating them for each new future share, we added a special share. This trick is simple, create a new share and manually add the path. This path should simply be "/", this way this share will hold all shares on the QNAP, including the Time Machine shares and others.

Rsnapshot Configuration
Next up was configuring the rsnapshot.conf on the CentOS machine. Contents of config file: (used cat /etc/rsnapshot.conf | grep -v -e ^# to get this output btw)
(ALL SPACES MUST BE TABS!!)
config_version    1.2
snapshot_root    /backups/
cmd_cp        /bin/cp
cmd_rm        /bin/rm
cmd_rsync    /usr/bin/rsync
cmd_ssh    /usr/bin/ssh
cmd_logger    /usr/bin/logger
cmd_du        /usr/bin/du
interval    hourly    6
interval    daily    7
interval    weekly    4
verbose        2
loglevel    3
logfile    /var/log/rsnapshot
lockfile    /var/run/rsnapshot.pid
backup    /        europe/        +rsync_long_args=--exclude=proc/ --exclude=sys/ --exclude=dev/ --exclude=.dbus/ --exclude=media/ --exclude=mnt/

backup    rsync://rsnapshot@192.168.0.2/all/    jupiter/    +rsync_long_args=--password-file=/etc/rsnapshot.password --exclude=.timemachine/ --exclude=Jupiter/


Anacron scheduling
To schedule all backups automatically the following was added to the /etc/crontab file:
0 8,12,16,20 * * * root /usr/bin/rsnapshot hourly
50 23 * * * root /usr/bin/rsnapshot daily
30 23 1,8,15,22 * * root /usr/bin/rsnapshot weekly
10 23 1 * * root /usr/bin/rsnapshot monthly