Simple Rsync Tutorial
May 23, 2006
Manually backing up your files through FTP can be very time consuming and a very big waste of resources. This is why rsync was written. Rsync allows you to transfer just the differences between two sets of files across the network, using an efficient checksum-search algorithm. In this tutorial, I will show you how to mirror a remote filesystem over an SSH tunnel.
Let's start off by setting up SSH:
ssh-keygen rsa cat ~/.ssh/id_rsa.pub
Copy the output of id_rda.pub
to ~/.ssh/authorized_keys
on your remote host. You should now be able to SSH into the remote host without having to type in a password.
We are ready to start backing up our files. This is accomplished in just one step. Make sure you've created a directory to store the data that only you have access to. When you've done so, execute the following command:
rsync -azPe ssh user@remote.host:/remote/path /local/path
Rsync will crawl through and download all of the data in the remote path to your local path. It may take some time to download all of the files the first time you run this, depending on what you are mirroring. However, the next time you run rsync, it will only download the files that have been modified or added to the directory structure.