Rsnapshot
Please Note:
rnapshot is an excellent backup application and has been around for a long time and is extremely stable. This article discusses doing backups to an external USB drive that is formatted for the "ext3" filesystem type. It depends on the attributes that are unique to Linux/Unix (i.e. ext3, ext4) filesystems only. If backups to CIFS (Samba a.k.a. smb, fat, fat32, vfat, ntfs) filesystems are required a different backup application must be used (rdiff-backup).
Contents
Another example of rsnapshot configuration on amahi 5.1
In this example automated backups are made to an external usb drive. Plug in the USB drive, it will probably mount automatically under /media/yourdisklabel
First login as root in a terminal (putty or ssh root@hda) and type
- mount
in the output, find which device is your usbdrive, possibly /dev/sdb1
Format usb disk
You need to format (ext3, ext4) an external USB disk drive for rsnapshot to work. rsnapshot uses a "hard links" feature that is unique to Linux/Unix filesystems. "Hard Links" are not supported on filesystems such as: "smbfs", "Samba (SMB)", "FAT", "FAT32", "NTFS", "CIFS", "vfat". Also "Amahi Greyhole" can "mount" Amahi shares that look like "local disk drives" these are Samba (SMB) mounted shares.
- umount /media/yourdisklabel
- mkfs -t ext3 -v -L usbdisk /dev/sdb1
THIS WILL ERASE ALL DATA ON /dev/sdb1, MAKE SURE THIS IS YOUR USB DRIVE AND NOT ANOTHER DRIVE
Install rsnapshot
- yum install rsnapshot
- mkdir -p /media/usbdisk/.private/.snapshots
- chmod 0700 /media/usbdisk/.private/
- chmod 0755 /media/usbdisk/.private/.snapshots/
Mount your usbdisk permanently
To Mount your usbdisk permanently (so the backup will work after a reboot) do the following:
- cp /etc/fstab /etc/fstab_bak
- nano /etc/fstab
Add to this file
- LABEL=usbdisk /media/usbdisk ext3 defaults 0 0
Save the file.
Quick rsnapshot Recipe
Here is a quick recipe to configure rsnapshot.
These are the critical settings in /etc/rsnapshot.conf:
snapshot_root /mnt/1tb-external/snapshots/ interval daily 14 interval weekly 4 interval monthly 4
This will create a series of directories called daily.0 through daily.13 weekly.0 to weekly.3 ... etc.
Modify rsnapshot configuration
- nano /etc/rsnapshot.conf
make the following modifications to the file rsnapshot.conf for blank spaces use TABS!
- snapshot_root /media/usbdisk/.private/.snapshots/
- no_create_root 1
- interval hourly 6
- interval daily 7
- interval weekly 4
- interval monthly 12
- verbose 3
- backup /var/hda/files/docs/ localhost/
- backup /var/hda/files/pictures/ localhost/
- backup /var/hda/files/movies/ localhost/
- backup /var/hda/files/music/ localhost/
- backup /var/hda/files/othersharesyoumade localhost/
Save the file
- rsnapshot configtest
this should return: syntax OK
Email reporting
for email reporting on your backups:
- cp /usr/share/doc/rsnapshot*/utils/rsnapreport.pl /root
- chmod 744 rsnapreport.pl
Automate backup with cronjob
- crontab -l > cronjobs
- nano cronjobs
add to this file for running rsnapshot and a weekly email report on rsnapshot:
- 0 */4 * * * /usr/bin/rsnapshot hourly 2>&1 | /root/rsnapreport.pl > /root/rsnapreport
- 30 23 * * * /usr/bin/rsnapshot daily
- 00 23 * * 1 /usr/bin/rsnapshot weekly
- 30 22 1 * * /usr/bin/rsnapshot monthly
- 00 22 * * 6 /usr/bin/rsnapshot du >> /root/rsnapreport | nail –r "somereturnadress@provider.com" -s"HDA backup report" -S smtp=smtp.yourprovider.com youremail@provider.com < /root/rsnapreport
Save the file
- crontab cronjobs
Rsnapshot should now be operational.
Make your backups available on clients (READ ONLY)
If you want to make the backups accesible from your clients:
Create a //hda/backup share in the HDA webinterface
- chkconfig nfs --level 2345 on
add a read only NFS export:
- nano /etc/exports
add
- /media/usbdisk/.private/.snapshots/ 127.0.0.1(ro,no_root_squash)
Save file
Unfortunately mounting an NFS share in fstab did not work on my machine after a reboot, so I chose an alternative configuration that mounts the share later in the booting process:
- nano /etc/rc.local
Add
- mount -r -t nfs localhost:/media/usbdisk/.private/.snapshots/ /var/hda/files/backup/
save file