Great article on using rsync in linux:

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 .

Technorati Tags: , , , , , ,