PDA

View Full Version : Idiot Proof Backup System


rednerd
12-29-2006, 12:39 PM
UPDATE: All problems fixed with Growl see the posts below!


First let me start off by saying sysadmin for a fairly large windows network with a handfull of Mac users. I'm also a Mac and Apple Script n00b. I had a user recently upgrade her system from 10.3 -> 10.4. I told the user repeatedly to make sure she ran SuperDuper! before hand so that we could back out of the upgrade if the need arose. I even offered to do the backup and upgrade for her... Needless to say she ended up with a completely hosed system that I was restoring at 2am on a Friday night / Saturday morning. I've now decided that I need to make sure SuperDuper runs without any user intervention. But I also need a way for the user to know if a backup fails so that she can inform me. The problem is that the computer in question is a complete stand alone system. It doesn't connect to the internet or have any sort of internal email access.

I seem to have the system 90% comlete but I'm having problems notifing the user that the job has completed while still closing SuperDuper!. Here is what I've done so far:

1. Installed a second hard drive into the machine. Partitioned and formated the drive as one big volume labelled SuperDuper_Backup_Clone
2a. Used 'disktool -l' and 'diskutil info' to get the UUID of the new drive.
2b. Created an /etc/fstab file with the following entry to keep the drive from being automagically mounted on boot (so that the user won't store data on it): UUID=uuid_from_step_2a none hfs rw,noauto 0 0
3. Created a script called /usr/local/bin/umount_clone to look like this:
#!/bin/bash
rm /Volumes/SuperDuper_Backup_Clone/etc/fstab
theDisk=`diskutil list | awk '/SuperDuper/ {print $NF}'`
diskutil unmount $theDisk
4. Mounted the drive using 'diskutil mount' command (Disk Utility will also work)
5a. Setup SuperDuper! to run a Smart Update backup from the internal drive to the "Clone" drive.
5b. Use the advanced option to run the /usr/local/bin/umount_clone script to when after the backup job completes.
5c. Schedule the backup Job
6a. Created a little QT app called sdInformer (program w/ source (http://www.tangentrix.com/~jon/code/sdInformer.zip)) to bring up a dialog box telling the user that the job completed successfully. I tried using Apple Script to do this but the dialog box wouldn't go away and stated "User Intervention Not Allowed."
6b. Edited the Copy Job.applescript file to include:
on afterRunningCopy()
set datestamp to (do shell script "date '+%m/%d/%y'")
do shell script "/usr/local/bin/sdInformer.app/Contents/MacOS/sdInformer 'Backup for " & datestamp & " Completed Successfully!' &"
end afterRunningCopy

And a similar entry for errorRunningCopy.
6c. Edited the scheduled job so that the apple script gets recompiled.

As I said before this works except for two small problems.
a. SuperDuper! stays running until the user aknowledges the sdInformer dialog box. I don't know if this will have any consiquences if another SD job tries to start before dialog box is acknowledged.
b. I think the SD! scheduled job has to be run as user who is currently logged onto the machine. This means that if another user is logged in the SD! job doesn't get run and even if it did, I don't think the sdInformer dialog will work since the cron user running the job won't have access to the Aqua session. I haven't really tested this since there is only one user on the machine in question.

Any idea how I might be able to run my sdInformer program and still have SD! exit properly? Or some other way of going about informing the user the backup succedded or failed without hanging SD! until the user acknowledges the backup's status? Is there a way to make Growl pop up dialog that will stay up until the user acknowledges it, maybe? Dashboard widget? Apple Script tweak?

Cheers ~jon

dnanian
12-29-2006, 12:41 PM
It's much easier to just install Growl, Jon, and use our support of that to send you mail...

dnanian
12-29-2006, 12:41 PM
Note, too, that our standard scheduling will mount, copy and unmount automatically...

rednerd
12-29-2006, 12:53 PM
Wow Dave you reply fast! I was still editing the post when you replied twice!!!

The machines isn't connected to _any_ network that could send me an email, page, etc. Also the main reason for the umount_clone script was to delete the fstab file so that if I need to boot off the drive I wouldn't have to find another Mac w/ SATA to mount the partition and delete the file. It keeps the volume from being mounted on boot... Of course this is hypothetical as I haven't tried booting from that volume with the fstab file in place. Granted OS X is a lot smarter than other *nixes in many ways.

I'll give Growl a shot.

dnanian
12-29-2006, 12:59 PM
Growl will definitely tell the user that the backup worked (or didn't). If you make the notification "Sticky" it'll stay up post-backup, too.

rednerd
12-29-2006, 01:28 PM
Yes, Growl does indeed rock. I'm such a n00b. :) I'll rack up all my previous work to an acedemic endevour.

So for those keeping score at home the final Idiot Proof SD! system is as follows:

0. Install SD! and Growl.
1. Install a second hard drive into the machine. Partition and formated the drive as one big volume labelled SuperDuper_Backup_Clone
2a. Used 'disktool -l' and 'diskutil info' to get the UUID of the new drive.
2b. Created an /etc/fstab file with the following entry to keep the drive from being automagically mounted on boot (so that the user won't store data on it): UUID=uuid_from_step_2a none hfs rw,noauto 0 0
3. Created a script called /usr/local/bin/umount_clone. This script will remove the /etc/fstab file and then unmount the drive so that if you mount the drive in another machine it will show up and to make sure you can boot from the SD volume if needed.
#!/bin/bash
rm /Volumes/SuperDuper_Backup_Clone/etc/fstab
theDisk=`diskutil list | awk '/SuperDuper/ {print $NF}'`
diskutil unmount $theDisk
4. Mount the drive using 'diskutil mount' command (Disk Utility will also work)
5a. Setup SuperDuper! to run a Smart Update backup from the internal drive to the "Clone" drive.
5b. Use the advanced option to run the /usr/local/bin/umount_clone script to when after the backup job completes.
5c. Schedule the backup Job
6a. Run a backup job so that SD! registers itself with Growl.
6b. Open the Growl Preferences pane, select the Application tab. Select the SuperDuper! application in the first box and mar the Scheduled Copy notifications as sticky.
7. Get yourself a cold beverage and use the change to register SD! . :)