Saturday, September 27, 2008

Best backup tools for ubuntu?

Quote:
What's the best tool to perform backups? I'm between two: rdiff-backup or rsync.

Answer:
rsync just mirrors, so if you backup nightly, make a change on tuesday, make another change on wednesday and on thursday you want to revert to tuesdays backup because wednesdays changes were borked, you can't. With rdiff-backup you can.

However, it ultimately depends on what you are backing up though. If you are backing up files which do not change much e.g. photos, music and video, then rsync may be better.

I use a combination of both, rdiff-backup for nightlys of /home and rsync for media (photos, movies, mp3 etc).
Another view:
I use rdiff-backup for incremental backups every day and once a month I make a whole backup by using partimage or mondo



Complete system backup is zinloos onder linux, het enige wat je volgens mij grofweg nodig hebt is:
  • database dumps
  • /home/*
  • /etc/*
  • dpkg --get-selections > packageslisting.txt
  • /usr/local/*
Binaries e.d. zijn totaal niet interessant omdat je die via dat apt-get commando in een mooie lijst kan krijgen die je met apt-get set-selection weer terugzet.

Complete Backup useless

Complete backup system is useless under linux, the only thing I think you need is roughly:


  • database dumps
  • /home/*
  • /etc/*
  • dpkg --get-selections > packageslisting.txt
  • /usr/local/*

Binaries etc. are not interesting at all because you get that through that apt-get command in a nice list. With apt-get set-selection you will be able to put that back again.


Third opinion:

There are two types of backups that I do. The first is a backup of several key folders, not my entire system. This is in case I blow something away, or lose some data that I’d want to get back quickly.

I use the rsync command for this. Rsync is a simple and fast way to make an exact copy of something. That something can be a single file or a whole file system.

Now my external hard drive is a firewire drive, which Ubuntu thoughfully mounts in /media for me with the wonderful name of ‘ieee1394disk’. That’s where I want to keep this backup copy. Let’s open up a terminal session and go backup some stuff.

cd /media/ieee*

Now I’m in my external drive. If you have a USB disk, chances are it’s under /media/usbdisk or /media/whatevertheheckyoucalledit. I’m going to make a folder to store this backup in because I’m something of a filesystem neat freak.

mkdir arsgeek_backup

cd arsgeek_backup

Now there are four directories that I back up on a regular basis. These are my /home directory, my /etc directory my /opt directory and my mp3 collection. :) My mp3’s are located on a FAT32 partition mounted in /media/sda5 in a folder called music. So here’s the command I use to copy all of these.

rsync -arvu /home /etc /opt /media/sda5/music .

Here’s what the switches after the rsync command mean. a= archive, r= recursive, v= verbose, u= update and z= compress.

What I like about this is that while the first rsync does take some time to copy all of these files and folders the first time it’s run, the next time it’s run it only adds new stuff. So if I run this once a week and the only changes that were made was that I added several new mp3s to my music directory, it will only copy those new files.

If I accidentally deleted an mp3 that I wanted, I could easily (and through the GUI) go to my external drive and copy it back. Or if I accidentally deleted my /home directory (yikes!) I could rsync it back by reversing the command:

cd /home

rsync -arvu /media/iee*/arsgeek_backup/home .

I also plan on upgrading my laptop, which is my primary work computer, to Edgy Eft when it comes out on October 26th. (PLUG!) I’ve put a lot of work into getting my laptop just the way I like it, so I’m going to take a complete backup of the system before I do the upgrade. In fact, I’m doing a new backup while I type this howto. To do that, I use the tar command.

I’m going to back up all of the most important folders to me, however I’m not going to back up certain parts of my install, like the /tmp directory, or the /sys directory or anything mounted in /media like DVD’s or the external disk that I’m backing up too! That would be messy. So we’ll use the tar command with some excludes built into it. It’s a bit long and ungainly looking but it works like a charm.

First, I move into my external drive.

cd /media/iee*

Then I make another directory for my complete backup

mkdir arsgeek_wholeshebang

cd argeek_w*

Now I’m ready to back my machine up. This is going to take a while, so it’s a good idea to do it when you won’t need to power off your computer.

sudo tar cvpzf arsgeek.backup.tgz –exclude=”/proc/*” \

–exclude=”/lost+found/*” –exclude=”/dev/*” \

–exclude=”/mnt/*” –exclude=”/media/*” –exclude=”/sys/*” \
–exclude=”/tmp/*” –exclude “/var/cache/apt/*” /

As you can see, that’s quite the command. Here’s how it breaks down. Tar is the program we’re using to make a backup copy.

The switches work out as follows: c= create, v= verbose, p= preserve permissions, j= bzip2, f= file.

arsgeek.backup.tgz is the file we’ll end up with, a complete and compressed archive of my entire ext3 filesystem.

- -exclude=”/something” is a directory or file that you’re explicity telling tar not to back up. If we were doing this in the same filesystem we were backing up, it would be important to exclude the arsgeek.backup.tgz file. Since we’re doing it to an external drive however, we don’t have to worry about that.

the / at the end tells it to start from the top level (or root) directory of my filesystem. It will start taring at / and get everything that lives beneath it except for those directories and files we told it not to get.

This will chug along for quite some time until eventually we’re left with a massive file called arsgeek.backup.tgz. So if things go horribly, horribly wrong how do I restore my computer?

Here’s how I would do it. I’d first reinstall my laptop with a fresh Dapper install. No updates, same hard drive partitions as before. Then, I’d log in, attach my external drive and go to the backup file.

cd /media/iee*/arsgeek_w*

sudo tar xvpfz backup.tgz -C /

Be warned however that this will overwrite anything and everything in any of the directories you’ve tared up. So /home will get completely over written with whatever’s in your tar file and the same for everything else. Again, this will take some time.

Once that’s done (and note that you’re doing it from within a running OS! Neat!) simply log off and log back in again. Phew! Glad you had a backup plan!

source: http://www.arsgeek.com/2006/10/18/how-to-back-up-and-restore-your-ubuntu-machine/


Partimage

but what if you need a full system restore. Check out partimage, I know it is in the repositories (Universe or Multiverse). Only problem is it can't back-up mounted file systems. Just boot into the live CD. Install it from the repositories, and run the command "sudo partimage"


Backup using rsync and crontab
Here is the way I do my backups. First you will need to understand crontab. Here is a good link:

http://www.adminschoice.com/docs/crontab.htm

You can edit your crontab file like so:
Code:
crontab -e
my crontab file consists of the following:
Quote:
30 22 * * * /home/nick/backup-scripts/backup-home
30 22 * * * /home/nick/backup-scripts/backup-win
30 22 15 * * /home/nick/backup-scripts/backup-media
30 22 * * * /home/nick/backup-scripts/backup-school
So according to the crontab I run 3 backups every night a 22:30 (10:30 pm), and 1 backup every 15th of the month also at 22:30 (10:30 pm). I basically run a script at the specified times. The scripts you probably would be interested in are backup-home and backup-school.

Here is backup-home:
Quote:
#!/bin/sh
/usr/bin/rsync -avx --exclude=.aptitude --exclude=.rnd --exclude=.qt /home/nick /media/backup

/usr/bin/rsync -avx --exclude=.aptitude --exclude=.rnd --exclude=.qt /home/nick /media/ext-backup
One note about crontab files is to only use absolute paths. Also always place an extra newline at the end of the crontab. The first command says to backup my home directory on /media/backup. The second command says to backup my home directory on /media/ext-backup.

Here is backup-school:
Quote:
#!/bin/sh
/bin/rm -f /media/backup/school-backup-*
/bin/rm -f /media/ext-backup/school-backup-*
/bin/tar cvpzf /media/backup/school-backup-`/bin/date +'%m-%d-%y'`.tar.gz /home/nick/school
/bin/cp /media/backup/school-backup-* /media/ext-backup
This script removes the previous nights backups and then tar and gzips my directory with my school work. The date is appended to the end of the file name so I know when the backup was created.

You don't have to use rsync for your home directories. You can choose to tar those up as well. I just did that because I wanted an uncompressed backup of my home directory at all times. But you may not care. Remember the nice thing about this is it is completely automatic once you get it setup. I hope this helps.
__________________


No comments:

Blog Archive

About Me

Exclusion of liability Regarding StillStupid: The use you make of the guides, tips and downloads that you listed on this web site or on another website to which I refer is entirely at your own risk. In no way can I be held liable for damage or consequential damages of any kind, which occurs as a result of that use.