- First off, enable passwordless login to the remote server. We generate a public/private rsa key pair using
ssh-keygen -t rsa. Do not enter a passphrase so that it won't ask for one later :) Now copy the contents of the generated .pub file (your public key) to your server in the file
~/.ssh/authorized_keys. You should be able to login to your server using
- Create a script that rsyncs your libraries that contains
rsync -a -e ssh "/Users/local_username/Music/iTunes" username@server:remote_path --updateand name it, for instance,
rsync -a -e ssh "/Users/local_username/Pictures/iPhoto Library" username@server:remote_path --update
~folder. You can test it from the command line, now, if you so desire:
- The easiest way to make sure that your script is executed daily, automatically, is by using an iCal event (pffff...). First, we'll create the AppleScript that will be executed by iCal. Open Script Editor (Applications:AppleScript:Script Editor) and create a script that contains
do shell script "/bin/bash /Users/local_username/backupLibraries.command > ~/rSyncErr.txt || echo -n"
You can try this by pressing 'Run' from Script Editor. Store the script as
backup.scpt, for instance.
- Now create an iCal event that executes the script daily, by setting Repeat: every day, Alarm: Run script, backup (select Other... and select the file that you just created from Script Editor), and 1 minutes after.
- There, you should be all set now! If something goes wrong, you will be able to find out by taking a closer look at
~/rSyncErr.txt. If you're the optimistic type, just remove "
> ~/rSyncErr.txt" from the AppleScript.
22 February 2007
Automatic backup on Mac OS X using rsync
I want to backup my iTunes music library and my iPhoto library to our local backup server that I'm able to SSH login to ...