Monday, May 9, 2011

Using rsync to make a backup

The rsync utility is a very well-known piece of GPL'd software, written originally by Andrew Tridgell and Paul Mackerras. If you have a common Linux or UNIX variant, then you probably already have it installed; if not, you can download the source code from rsync.samba.org. Rsync's specialty is efficiently synchronizing file trees across a network, but it works fine on a single machine too.

Basics
Suppose you have a directory called source, and you want to back it up into the directory destination. To accomplish that, you'd use:
rsync -a source/ destination/
(Note: I usually also add the -v (verbose) flag too so that rsync tells me what it's doing). This command is equivalent to:
cp -a source/. destination/
except that it's much more efficient if there are only a few differences.
Just to whet your appetite, here's a way to do the same thing as in the example above, but with destination on a remote machine, over a secure shell:
rsync -a -e ssh source/ username@remotemachine.com:/path/to/destination/


source : http://www.mikerubel.org
thanks dude!

No comments:

Post a Comment