SuperDuper! is a superb backup program for the Mac.
It does one (major) thing: It duplicates your hard drive to another hard drive.
mount-or-unmount-for-superduper.sh is a shell script which automates the process of mounting and un-mounting a hard drive to use with SuperDuper.
“What? Why? I don’t get it.”
Imagine this: you have a desktop Mac (or a laptop Mac that you keep the external drive plugged into all the time, I suppose).
You want to automate your backups because you know that you won’t really run them if they aren’t automated, because you’re lazy.
Nothing personal, everyone is lazy when it comes to backups. That’s why almost no one has them, even if they know they should.
SuperDuper is super easy (I promise I’ll stop with the super super bit) and works great, and even has a scheduler so you can set it to backup your machine at 3 a.m. or whenever you won’t be using it.
The only problem is that the drive has to be mounted (obviously) to do that, and having it mounted all the time can be annoying:
Spotlight finds 2x the number of actual results: once for your main hard drive, once for your backup. [This is enough of an annoyance that there really needs to be no #2, but…]
Having the drive mounted means that it will spin up and down all day long as it goes to ‘sleep’ and then thinks that it may be needed. If you’re only using it for SuperDuper, why not only have it spin up once per day?
Installers will often check to see if maybe you want to install on a different hard drive than the main one. Having unmounted the drive means that you don’t have to worry about the Installer checking it.
Imagine something horribly unexpected happens and you delete a bunch of files by accident. Do you want that list of “Files I May Have Accidentally Deleted” to include your backups? If not, having the backup drive unmounted prevents accidental deletions too.
How does it work?
The script is very simple. All you have to do is edit one line.
# Where Finder shows the drive when it is mounted
DRIVE_NAME_SHORT="iMac_Backup"
(Note that this must not include the /Volumes/ part of the path, but JUST the part which appears when the drive appears on the desktop or in Finder.)
I would encourage you not to get ‘creative’ with the name: Use letters only, no spaces or other punctuation except _ or - if you must
Names are important
Make sure to save the file with a name that begins with either ‘mount-’ or ‘unmount-‘
I recommend this that you:
Download mount-or-unmount-for-superduper.sh
Save it to ~/bin/ or somewhere else in your $PATH.
Rename it:
mv mount-or-unmount-for-superduper.sh mount-drive-for-superduper.sh
Link it (so that any changes in one will be reflected in the other)
ln mount-drive-for-superduper.sh unmount-drive-for-superduper.sh
Launch SuperDuper, click the ‘Options’ button and then the ‘Advanced’
Add the ‘mount-drive-for-superduper.sh’ to ‘Before Copy: Run shell script before copy starts’
Add the ‘unmount-drive-for-superduper.sh’ to ‘After Copy: Run shell script after copy completes’
You ought to have a window that looks something like this:

Click ‘OK’ and it should look like this:

And then click ‘Schedule’ to tell SuperDuper when to run.
Feedback?
I welcome feedback on the script, especially if anything is unclear or you can see an easier way to do something.
Please leave a valid email address in comments. No one else but me will ever see it.