Difference between revisions of "Rsnapshot"
m |
m |
||
Line 18: | Line 18: | ||
__TOC__ | __TOC__ | ||
− | =Quick rsnapshot Recipe= | + | === Preparing an External USB Drive === |
+ | |||
+ | Off-the-shelf external USB drives normally are setup to work with computers that utilize CIFS type filesystems. rsnapshot uses a "hard links" feature that is unique to Linux/Unix filesystems (ext3). "Hard Links" are not supported on filesystems such as: '''"smbfs"''', '''"Samba (SMB)"''', '''"FAT"''', '''"FAT32"''', '''"NTFS"''', '''"CIFS"''', '''"vfat"'''. "Amahi Greyhole" mounts Amahi shares that look like "local disk drives" '''''but''''' these are Samba (SMB) mounted shares. The external disk drive will have to be prepared for a Linux/Unix filesystem, in particular ext3. Why? ext3 has been around for sometime, is stable, and "Windows" computers have Open Source drivers that can be installed to gain access to an ext3 drive. | ||
+ | |||
+ | The external drive can be setup for ext3 as follows: | ||
+ | |||
+ | You need to format (ext3, ext4) an external USB disk drive for rsnapshot to work. | ||
+ | |||
+ | :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/ | ||
+ | |||
+ | ===Quick rsnapshot Recipe=== | ||
Here is a quick recipe to configure rsnapshot. | Here is a quick recipe to configure rsnapshot. | ||
Line 32: | Line 55: | ||
weekly.0 to weekly.3 ... etc. | weekly.0 to weekly.3 ... etc. | ||
− | =Another example of rsnapshot configuration on amahi 5.1= | + | ===Another example of rsnapshot configuration on amahi 5.1=== |
− | |||
In this example automated backups are made to an external usb drive. | 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 | Plug in the USB drive, it will probably mount automatically under /media/yourdisklabel | ||
Line 44: | Line 66: | ||
in the output, find which device is your usbdrive, possibly /dev/sdb1 | in the output, find which device is your usbdrive, possibly /dev/sdb1 | ||
− | = | + | ===Mount your usbdisk permanently=== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | =Mount your usbdisk permanently= | ||
To Mount your usbdisk permanently (so the backup will work after a reboot) do the following: | To Mount your usbdisk permanently (so the backup will work after a reboot) do the following: | ||
Line 75: | Line 79: | ||
Save the file. | Save the file. | ||
− | =Modify rsnapshot configuration= | + | ===Modify rsnapshot configuration=== |
:nano /etc/rsnapshot.conf | :nano /etc/rsnapshot.conf | ||
Line 111: | Line 115: | ||
this should return: syntax OK | this should return: syntax OK | ||
− | =Email reporting= | + | ===Email reporting=== |
for email reporting on your backups: | for email reporting on your backups: | ||
Line 119: | Line 123: | ||
:chmod 744 rsnapreport.pl | :chmod 744 rsnapreport.pl | ||
− | =Automate backup with cronjob= | + | ===Automate backup with cronjob=== |
:crontab -l > cronjobs | :crontab -l > cronjobs |
Revision as of 02:10, 27 February 2013
rnapshot is an excellent backup application and has been around for a long time and is extremely stable.
Why are backups important? Well, hardware failures, accidental file deletion(s), files become corrupted, etc.. Backups can help recover data where applications are being updated/upgraded. Enough reasons?
Where should backups be stored? Due to the inevitable failure of hardware it is desirable to store backups on a separate system from where the production data is stored. Or possibly to an external medium such as an external USB disk drive. This article discusses backing up to an external USB drive.
Please Note:
rnapshot depends on 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 (i.e. rdiff-backup).
Here is a good book that discusses backups, recoveries, rsnapshot and rdiff-backup: "Backup & Recovery: Inexpensive Backup Solutions for Open Systems, by W. Curtis Preston". |
Contents
- 1 Preparing an External USB Drive
- 2 Install rsnapshot
- 3 Quick rsnapshot Recipe
- 4 Another example of rsnapshot configuration on amahi 5.1
- 5 Mount your usbdisk permanently
- 6 Modify rsnapshot configuration
- 7 Email reporting
- 8 Automate backup with cronjob
- 9 Make your backups available on clients (READ ONLY)
Preparing an External USB Drive
Off-the-shelf external USB drives normally are setup to work with computers that utilize CIFS type filesystems. rsnapshot uses a "hard links" feature that is unique to Linux/Unix filesystems (ext3). "Hard Links" are not supported on filesystems such as: "smbfs", "Samba (SMB)", "FAT", "FAT32", "NTFS", "CIFS", "vfat". "Amahi Greyhole" mounts Amahi shares that look like "local disk drives" but these are Samba (SMB) mounted shares. The external disk drive will have to be prepared for a Linux/Unix filesystem, in particular ext3. Why? ext3 has been around for sometime, is stable, and "Windows" computers have Open Source drivers that can be installed to gain access to an ext3 drive.
The external drive can be setup for ext3 as follows:
You need to format (ext3, ext4) an external USB disk drive for rsnapshot to work.
- 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/
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.
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
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.
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