Structure and Interpretation of Computer Programmers

I make it easier and faster for you to write high-quality software.

Saturday, May 12, 2007

A bit of backup script

Good news – there’s a handy tool in OS X called wait4path which can help when writing timed scripts to backup to removable media.

Bad news – it [at least in Tiger….] works slightly esoterically – if a path is already present, it will still wait for another mount kevent before exiting. It should therefore be used in a script like this:


#!/bin/sh

if [ ! -d /Volumes/Backups ]; then
echo "waiting for backup volume..."
/bin/wait4path /Volumes/Backups
fi

# do some backups

Note, however, that if you do this in a crontab job it could potentially wait for a very long time, so you should wrap all that with a /var/run style semaphore.

posted by Graham Lee at 12:48  

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress