There are many ways to clone a file system, but only few are as efficient as
rsync. Part of every possible *nix derivate
rsync is a the file based cloning tool for live file systems. One of the most popular use cases is parts of a server to a standby machine or a slave system.
rsync is optimized to transfer as little data between the systems as possible to minimize bandwidth usage.
The efficiency comes from comparing the filesystems prior to syncing them. There are different ways of calculating the differences. The simplest one is comparing timestamps. More sophisticated (but slower) methods include calculating hash sums.
Below I will use concrete examples to show you what you can do with
Okay here you are with your invaluable collection of digital photos of your family and journeys and you most certainly do not want to lose the to a harddisk crash. You want to back them up as often as possible, but this takes an aweful lot of time because of the sheer amount of Megabytes that you hoarded over all those years. Don't worry,
rsync is here to save the day.
rsyncto backup the data by hand once
cronto automate your backup
Since most people use applications to manager their photo collections, first step is to find out where your photos reside. I use Apples Aperture and put my photo library on an external firewire harddisk.
So the path to my library is:
For the moment I assume a filesystem that is already mounted. In my case its a remote directory on an NAS. The path were I want to store my backup is:
You don't want to syncronize all of the files from the server, especially not the pseudo filesystems like
Create a file that contains a blacklist of files and directories that are excluded from the backup with the following contents:
/proc /sys /mnt /tmp *.bak *~
I suggest naming this file
In our scenario
rsync will use
ssh to connect to the remote server. Do run
rsync in non-interactive mode you need to put a public
ssh key on the server that does not use a password. For details on how to do this see the ssh wiki page.
We'll do the initial backup by hand, so that we see if everything is set up correctly.
rsync -e 'ssh -l <user>@<host>' -avHz --stats --exclude-from=<path to exclude file> <user>@<host>:<source dir> <target dir>
Be patient, the initial backup will be slow.