Log in or sign up


USER:
PASS:

 
 
Forums
BluFudge :: Forums :: Tutorials and Guides :: Linux Tutorials and Guides
 
<< Previous thread | Next thread >>
System - Backup: Automated backup for Linux / Unix with rsnapshot
Moderators: SETone, Fudge, Demented
Author Post
bubulein
Wed Feb 10 2010, 04:03pm
Registered Member #114
Joined: Tue Feb 09 2010, 03:34am
Your location: Germany
Posts: 9
Automated backup for Linux / Unix with rsnapshot

Category:

System, Backup

Difficulty: medium

Tested on/for:
Ubuntu 9.10 Karmic Koala
should work on other Linux/Unices, too


This document is about adding automated backups for your Linux / Unix System.
Once configured u don't have to care about.

Quote from the developers homepage at http://rsnapshot.org:

rsnapshot is a filesystem backup utility based on rsync. Using rsnapshot, it is possible to take snapshots of your filesystems at different points in time. Using hard links, rsnapshot creates the illusion of multiple full backups, while only taking up the space of one full backup plus differences. When coupled with ssh, it is possible to take snapshots of remote filesystems as well.
quote end

With rsnapshot u can make backups from multiple computers in your Network. e.g your Laptop

I refer to the original HowTo:
This is only an short extraction.

Commands are marked with a leading #

Step 1

Installing rsnapshot

On Debian based distributions like Ubuntu and Knoppix

# sudo apt-get install rsnapshot


This will install rsnapshot and rsync, a remote synchronisation tool.

Step2

Configure rsnapshot

To configure rsnapshot you have to modify the rsnapshot.conf
Open the file with

# sudo nano /etc/rsnapshot.conf


PLEASE BE AWARE OF THE FOLLOWING RULES:

This file requires tabs between elements

Directories require a trailing slash:
right: /home/
wrong: /home

This file is well documented it should be no problem to read and edit the necessary setting.

Change

snapshot_root   /.snapshots/


This line define the directory for your snapshots.
If you have a separate backupdrive is suggest to use it. In this case the backups prevent you from deleting files accidentally. If the harddrive fail your files are lost. Assuming you have mounted an additional harddrive to /backup the line should look like

snapshot_root /backup/


If rsnapshot is installed with your systems packagemanger all other settings should be ok.

Next we have to set the backup intervals


interval        hourly  6

interval        daily   7


With these settings you create a backup
6 times a day every 4 hours, stored one day
7 times a week one backup per day, stored one week


The backups rotate, and after 4 weeks you have
6 daily backups
7 weekly backups


In case u need to restore a backup you have a all your data from the complete last week.

To disable a entry just add a leading #, to comment it out

Now we have to tell rsnapshot the location of the files we want to backup.
In this case we backup the home-directory of every user, and all configuration files under /etc. You can add as much directories as you want.

The directories or files you want to backup are marked with a leading
backup
followed by a <TAB> and the name of the backupset
a default entry looks like

backup  /home/          localhost/

backup  /etc/           localhost/


This two entries store a recursive backup of
/home/ and /etc/

Assuming that you store your backups under /backup/

this results in
/backup/hourly.0/localhost/home/
to
/backup/hourly.5/localhost/home/


In some cases it is helpful to exclude some files or directories.
for example:
I do not want to backup /home/bubulein/data
cause i mirror this folder to an other backupserver

To exclude add

exclude_file /home/tmcc/data/*


or if u want to exclude only a single files type

exclude_file *.txt.bak


Now safe your file by pressing ctrl+x and Y

Step 3

Testing the configuration
Enter the command promt and type

# rsnapshot configtest


rsnapshot should answer with Syntax OK. On errors rsnapshot outputs a good description about whats wrong with your configuration file.

like


ERROR: /usr/local/etc/rsnapshot.conf on line 199:

ERROR: backup /var/ - no destination path specified for backup point 

ERROR: Errors were found in /usr/local/etc/rsnapshot.conf,

ERROR: rsnapshot can not continue. If you think an entry looks right, make

ERROR: sure you don't have spaces where only tabs should be.


Now we do a final test

with

# rsnapshot -t hourly


rsnapshot start a testrun without storing any backups. rsnapshot just show you what would happen if you do a real backup.

If you use a screenreader its very complicated to read the output.

The output just say that the backups are rotating from hourly.0 to hourly.1 and from hourly.1 to hourly.2 ...
Then rsnapshot shows the rsync command which is used to safe the files.

Feel free to skip this test and check the file structure after your first backup. Backups are very helpful so feel free to ask at the irc-channel to be shure everything work as expected.

root@teufelchen /storage/backup/snapshots]# rsnapshot -t hourly
echo 72247 > /var/run/rsnapshot.pid
/bin/rm -rf /storage/backup/snapshots/hourly.5/
mv /storage/backup/snapshots/hourly.4/ /storage/backup/snapshots/hourly.5/
mv /storage/backup/snapshots/hourly.3/ /storage/backup/snapshots/hourly.4/
mv /storage/backup/snapshots/hourly.2/ /storage/backup/snapshots/hourly.3/
mv /storage/backup/snapshots/hourly.1/ /storage/backup/snapshots/hourly.2/
native_cp_al("/storage/backup/snapshots/hourly.0", \
"/storage/backup/snapshots/hourly.1")
/usr/local/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
/etc /storage/backup/snapshots/hourly.0/teufelchen/
/usr/local/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
/usr/local/etc /storage/backup/snapshots/hourly.0/teufelchen/
/usr/local/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \
/var /storage/backup/snapshots/hourly.0/teufelchen/
touch /storage/backup/snapshots/hourly.0/

Step 4

Starting the backups

Now we have to add a cronjob to make sure the backups are runing automated.

As root just copy and paste the following lines to your /etc/crontab

start the crontab editor with

#crontab -e


and paste

0 */4 * * *       /usr/local/bin/rsnapshot hourly

30 23 * * *       /usr/local/bin/rsnapshot daily


This will run the hourly backup every 4 hours starting at 0:00
and the daily at 23:30

Step 5
Verifiyng the backup

After the first run browse yout backup directory to see if everthing works fine.

Links
www.rsnapshot.org The Developers Homepage


Thx to
Fudge www.blufudge.net for checking the text
To the rsnapshot and rsync Team
google inc. for his unselfish help *G*

If you need help feel free to join #holodeck on irc.bluefudge.net
or write a mail

yours bubulein


[ Edited Mon Feb 22 2010, 06:12am ]
Back to top
jamiewan
Wed Feb 17 2010, 05:51am
Registered Member #117
Joined: Wed Feb 17 2010, 05:42am
Your location: tasmania
Posts: 1
thanks heaps that walk thru worked great bubulein ;-)
Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System