I was playing around with rsync the other night. Now I have a scripted command so I can backup folders from my laptop back to the external harddrive on my iMac at home. You can find the command below.
We need to assume you have done several a couple of things to improve the security of your SSH at home.
- Moved from the standard tcp 22 port to a new port: example 5346
- Turned off password authentication in favor of public-private key authentication.
- Have your ssh private key saved somewhere on your laptop simple like the default ~/.ssh folder. The default keyname is id_rsa if you generated your key with a command like
ssh-keygen -t rsa
- The folder we want to backup is called Documents just in our home folder on our Apple Powerbook.
- We will assume you registered a Dyndns name for you home machine.: example home.homedns.org
- The username on your home iMac or *nix box is: username
- The external drive is called: ExternalDrive
Here is the command you would issue on your Mac or *nix laptop. It should all be on one line. The best part is that it will take a while depending on how much stuff you have in your Documents folder. After that it will only sync over the changes. Perfect when away from home and you want a backup safely off your laptop.
rsync -avrz -e “ssh -p 5346 -i .ssh/id_rsa” Documents email@example.com:/Volumes/ExternalDrive/Backups/Powerbook