Roshan Book

My Tech Notebook

Backing Up in Ubuntu


Source: http://www.psychocats.net/ubuntu/backup

One of the most frequent questions on the forums is “How do I back up in Ubuntu?”

Before I started using Ubuntu, I thought the best method was just to copy and paste files using the file manager (that’s one way, of course, but it has its limitations). I’m going to recommend a few popular methods. This list isn’t comprehensive—it just gives you some places to start. You can always investigate further once you’re more comfortable with Ubuntu.

Backing Up Personal Files
rsync is what I use for backing up personal files. I used to copy and paste files using the file manager, but that would involve taking about an hour to back up all my music and erase all the old copies. rsync gives me the ability to copy over only the files that have been modified or added since the last time I backed up. Now, backups take me only about fifteen seconds a week.

The most basic way to use rsync is like this (command goes into the terminal):

rsync -av /path/to/source/directory /path/to/target/directory

For example, let’s say your username is aliceand you wanted to back up your home directory to your external hard drive that mounts at /media/usbdrive, you would use the command

rsync -av /home/alice /media/usbdrive

If rsync doesn’t seem sophisticated enough for you, you can type

man rsync

to find more options than just -av. You can also explore rdiff-backup, which allows you to store (and restore) different date-stamped versions of the same file without taking up too much extra space. And, if you hate the command-line, try installing grsync, which is the graphical frontend to rsync. Here are some screenshots of grsync in action.

Backing Up Whole Installations
Not that System Restore is foolproof in Windows, but it’s still a nice feature… at least in theory. Right now, Ubuntu doesn’t have anything like System Restore. So if you’re worried an update (especially if you have unsupported or pre-release updates set to install) might break your perfect setup, it’s best to back up your system first.

tar is an archiving command, but it can also be used to archive your entire system into one little zipped up bundle. Someone on the Ubuntu Forums wrote a nice little HowTo on backing up and restoring your entire installation using tar.

ddrescue allows you to copy a partition byte for byte to another partition or to a .img file. It’s mainly designed for recovery of a crashed drive, but you can also use it as a way to back up (a non-graphical PartImage of sorts). The trick is that the name of the package is ddrescue in the repositories, but the command to use it is dd_rescue. So if you wanted to copy /dev/hda1 to /dev/sda1, you would type in the terminal:

dd_rescue /dev/hda1 /dev/sda1

Keep in mind that /dev/hda1 cannot be in use or mounted. If that requires you using a live CD, then so be it. You can also, if you don’t want to erase /dev/sda1 completely, ddrescueto an image file and then mount the image to get the files off it:

dd_rescue /dev/hda1 /dev/sda1/hda1backup.img
sudo mkdir /recovery sudo mount /dev/sda1/hda1backup.img /recovery

I don’t have a good tutorial on it, but Clonezilla also works well for backing up single partitions or entire drives.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: