On Aug 3, 2007, at 7:59 AM, T&B wrote: > Hi all, > > I want to backup particular directories to an external hard disk > each night. I want it to run without the need for anyone to login. > It's a simple task to do in a shell script via ditto, and simple to > initiate each night via cron or launchd. > > Questions: > > 1. How can I check whether the external volume "Backup" is mounted, > and conditionally execute the script (else mail to say there was an > error). Simply checking whether /Volumes/Backup exists isn't > reliable since there may be a directory created there (as I've seen > created when the script runs with no disk attached). > > 2. How can I unmount the external Backup drive when the script is > done, so it can be safely unpugged (FireWire)? > > I currently have a rough script like this: > > ditto -rsrcFork "/Shared Items/Web" /Volumes/Backup/Web > ditto -rsrcFork "/Shared Items/Mail" /Volumes/Backup/Mail > ditto -rsrcFork "/Shared Items/File Server" "/Volumes/Backup/File > Server" > ditto -rsrcFork "/Shared Items/Databases/Databases Backup" "/ > Volumes/Backup/Databases" > > echo "Backup finished" | mail -s "Backup finished" > [log in to unmask] > > Thanks, > Tom > /usr/sbin/diskutil eject '/Volumes/The DriveName'