| Need a Backup?|
Posted: 30 Mar 2005
I recently became concerned with the increasing number of important files I
store on my computer. I rarely back anything up, and with the number of aspects
of my life I'm converting to be stored on my computer constantly growing, a
hard-drive failure would certainly be disastrous.
I considered trying the
normal "cp" command to copy the contents of my drive to a separate drive, but
that only worked once. In order to back up the drive again after adding content,
I had to copy the *entire* drive again - cp wasn't smart enough to know what was
all ready backed up and what needed backing up.
To remedy this situation,
I found a nifty little program called rsync. It was a perfect
*note* rsync is a program that is quite flexible, and
can do *much* more than is presented in this article. If you're interested in
learning more of rsync's capabilities, please open a console and type "man
rsync". The manual page is kind of technically written, so be
Now, what rsync does is really quite cool. It intelligently
backs up information from a source to a destination. In my case, it backs up the
entire contents of one local hard drive to another hard drive.
I said intelligently, I meant it only backs up what is needed. If I have
30 gigs of stuff I backed up a month ago, and 5 gigs of new stuff that needs to
be backed up from the same drive, mingled throughout the same directories - it
knows not to backup the old stuff, and successfully backs up the 5 gigs of new
You may be asking "What's the catch here? This is
too good to be true!" Well, unless you're very comfortable with the Linux
console, there is a catch. There's currently no GUI for this process, which
means you'll have to do a bunch of typing, instead of clicking to get the job
how to get set upThis article assumes you've all ready got your 2nd
hard drive bought, installed, and mounted.
Once you've readied your 2nd
hard drive - continue reading.
*note* You don't necessarily need a
2nd hard drive for this to work. You can use many different things, but this
article will assume you're working with a 2nd hard drive.
how to back up your hard drive using rsyncIn order to make this more
user-friendly, many examples will be used. The examples will have directories
that pertain only to my personal situation. You'll have to change the
directories for your particular setup.
The process is as
Open a console window and type in the following, but don't press
rsync -avnu --progress --stats
think it'd help a bit if I explained what all that means, so....
And that's the first part.
- "rsync" means "run the rsync program"
- "-a" means "Backup all sub-directories maintaining all permissions,
groups, users, times, and devices."
- the "v" after the "a" means "Be more verbose. Tell me more about what's
- the "n" after the "v" means "Don't actually do anything, just tell me what
you're going to do."
- the "u" after the "n" means "Only update stuff. Don't re-copy things with
more recent timestamps."
- the "--progress" means "Give me progress updates while you're backing
- the "--stats" means "Let me know exactly what you did after it's all
I'm kind of paranoid about my
stuff being copied correctly, so I probably go beyond what most people would
want to do, but better to be safe than sorry, right?
Now, to continue,
you want to input the directory of the mounted drive you want backed up. In my
case it's "/stuff/music/" so my command line would look like this:
rsync -avnu --progress --stats /stuff/music/
last step is to put in the mounted directory of the hard drive you're backing up
to. In my case it's "/backup/music/" so the next section would look like
rsync -avnu --progress --stats /stuff/music/ /backup/music/
that should do it for the test run.
*note* If you are backing up
anything with sub-directories, it is necessary to include the trailing "/"
characters on the end of the directory, e.g. "...music/"
When the program
finishes, you'll notice a lot of information on your screen. It'll probably look
something like this:
receiving file list ...
6290 files to consider
flacs/EnZign/EnZign - Such Is Life.flac
flacs/EnZign/EnZign - That We Might Live.flac
flacs/EnZign/EnZign - When Hope Is Lost.flac
flacs/Original EnZign/The River Of LIfe.flac
flacs/Original EnZign/With All My Might.flac
flacs/Original EnZign/On My Way.flac
flacs/Original EnZign/What Lies Beyond.flac
flacs/Original EnZign/Im Cryin.flac
flacs/Original EnZign/Eternal Love.flac
flacs/Original EnZign/Good Things Come From Above.flac
Number of files: 6290
Number of files transferred: 16
Total file size: 111688283491 bytes
Total transferred file size: 398411470 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 296298
Total bytes written: 80
Total bytes read: 296378
wrote 80 bytes read 296378 bytes 20445.38 bytes/sec
total size is 111688283491 speedup is 376742.35
you notice, rsync found 6290 files to back up, but it only set 16 to actually be
backed up. Those 16 files are ones I updated this morning, and happened to be
the only ones that were needing to be backed up.
Now, if the output looks right, go ahead and run the real thing
by taking out the "n" option and pressing enter.
rsync -avu --progress --stats /stuff/music/ /backup/music/
will start the process and you'll see the progress as it happens. When it's
done, you should have a shiny new back-up, ready to come to the rescue!