Difference between revisions of "Rsnapshot"

From Amahi Wiki
Jump to: navigation, search
Line 10: Line 10:
 
This will create a series of directories called daily.0 through daily.13
 
This will create a series of directories called daily.0 through daily.13
 
weekly.0 to weekly.3 ... etc.
 
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 wil 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 the disk for rsnapshot to be able to use hard links. FAT formatting does not support this unfortunately.
 +
 +
: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.
 +
 +
=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
  
 
[[Category: Apps]]
 
[[Category: Apps]]

Revision as of 20:03, 17 February 2010

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 wil 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 the disk for rsnapshot to be able to use hard links. FAT formatting does not support this unfortunately.

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.

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