Rsync is a great command line program for copying and sync’ing data. It can use standard SSH protocol (default port 22) to copy files from computer to computer, or locally from one path to another. It frequently comes on linux/unix systems, but if you’re using Windoze, I suggest installing Cygwin.
The first step in this tutorial is to setup passwordless SSH. Open a terminal on the computer you want to copy files from, referred to in this article as “local”.
SCP the public key file (id_dsa.pub) to the computer that will receive the files, referred to as “remote”.
SSH to the remote system and execute a few commands to enable passwordless SSH
To verify that the public/private keys are working, SSH to the remote system. You should not be prompted for a password this time.
The second step of this tutorial is creating an executable shell script that will transfer the files. I chose to put my scripts in the folder “~/scripts/”, but you could put them anywhere you want.
Open up your favorite text editor (emacs, vi, nano, etc) and enter your rsync command.
Please note, the “–delete” flag is optional, and will remove files on the remote computer that do not exist on the local computer. Please use caution.
For my real life example, I setup a script to rsync my iTunes library from my iMac to my MacBookPro.
After saving the script, set it to be executable using chmod.
Test your script on the command line, and then SSH to the remote computer to verify the copied files.
If all is working well, you can setup a cron job to run at your desired time interval. Remember, both computers must be running for this to be automated, so choose a time you know they’ll both be on. For example, to run this script daily..