oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Automated Backups on Tiger Using rsync
Pages: 1, 2

If you want to record shell command errors, perhaps for debugging the script, change the command to:

do shell script 
"rsync -aE --delete ~ /Volumes/FW200/Backups 2>>~/rsyncErr.txt || echo -n"

This will append the error message to the file rsyncErr.txt in your home folder. This change is only of use if you need to see the shell error message.

As noted in the Tiger Terminal article, several characters such as spaces, quotes, apostrophes are command-line metacharacters. That is, if you type them in the command line they are interpreted as commands and not part of the name. If your backup target folder contains any of these characters, you will need to escape or quote the characters appropriately. Fortunately, AppleScript includes a quoted form command that escapes a text string appropriately for the command line. You would use it like so:

do shell script 
"rsync -aE --delete ~ " & quoted form of "/Volumes/FireWire 200/My Backup ƒ"

Note the space between the tilde and quote in the above command. You need the space, in unquoted form, to separate the source and target file names. Remember, you only need to do this if the target folder name has a command-line metacharacter.

Try running the script you just made; it should back up your entire home folder to the target folder of your external drive.

Running Commands Automatically

We need a way of running the backup command automatically, without a person doing it. The easiest way of doing this in Tiger is to create a repeating alarm in iCal.

Launch iCal and create a new event. Set the event's "from" field to the time you want your backup to take place, probably early morning or some such time when you are not using your Mac. You will make the event repeat and trigger at the start, so the dates and "to" fields are not important.

Set the "repeat" field to "every day" and the "alarm" fields to "Run script," your script file, and "0 minutes before." Note that you will have to select "Other..." from the alarm file popup menu to select the script file.

tab 2

Now iCal will run your backup script automatically at your event "from" time (for example, 2 a.m.). You must leave your external drive mounted and iCal running to trigger the backup script.

You can add other commands you wish to be run daily to your backup script. For example, you could add more rsync commands to back up other mounted volumes.

Richard Hough is a web developer for a Vancouver, Canada educational software company.

Return to the Mac DevCenter