![]() |
|||||||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
![]() |
|
Thread Tools |
Rating: ![]() |
Display Modes |
|
#1
|
|||
|
|||
An (Applescript) hack to automate mounting and unmounting external volumes
My problem (see the other thread of mine) is that when you launch SuperDuper!, it 'remembers' the drives it last backed up to. So if you last backed up to an external drive that is currently not plugged in or mounted, you have to click 'Cancel' when SuperDuper reports that it can't find external drive 'XYZ'.
This has caused me some problems when trying to automate our backups as the backup scripts don't get past the 'Cancel' button and so they just sit there and wait. Another problem I have is that I use an external firewire drive which contains two disk images (created as sparse images so that I can run Smart Update). SuperDuper can automatically mount these disk images but only if the external drive itself is first mounted. There are reasons why I think it is not always good to keep an external drive mounted when it is not in use. Also I've noticed that SuperDuper does not unmount the mounted disk images when it has finished backing up. So on Friday I tried learning some Applescript to amend the basic Daily Backup script. My daily backup script now has the following at the start of the script: Property diskname : "External HD" tell application "Finder" if not (exists the disk diskname) then do shell script "diskutil mount `disktool -l | grep 'External HD' | sed 's/.*\\(disk[0-9s]*\\).*/\\1/'`" delay 1 end if end tell delay 2 This uses the UNIX 'disktool' command to find out (with some sed and grep hacks) which device our firewire drive is connected to (will usually be disk2 or disk3 depending on how many other drives are connected). It then passes this disk name to the diskutil command to mount that volume. I then include the rest of the SuperDuper script which is then followed by the next piece of code: delay 2 tell application "Finder" if (exists the disk "local_home_backup") then eject "local_home_backup" delay 2 end if eject "External HD" end tell This ejects the disk image that was mounted for the backup and then ejects the volume as well. If you have multiple disk images on a volume, you may need to add extra lines in this section to first eject all of the disk images that may be mounted (SuperDuper can mount all images on an external volume...or at least all of those that you have ever backed up to). You won't be able to eject the firewire disk without first ejecting *all* mounted volumes on it. This hack now means that I can automate our nightly backups without worrying about SuperDuper asking for a particular disk image to be mounted. It also means that when the backup finishes the external disk is unmounted. Hope this might be useful to someone else. Keith P.S. This is my first ever attempt at using AppleScript, I'm sure there are better/neater ways of doing this.[FONT=Century Gothic] |
#2
|
||||
|
||||
Great tips, Keith -- and one of the reasons we decided to write the backup "engine" in AppleScript! This makes it easy for users with specific requirements to modify and adjust it to their own particular requirements.
Thanks for contributing!
__________________
--Dave Nanian |
#3
|
|||
|
|||
One question. I've created the scripts in the original post, but what is the "daily backup script" referenced in the original post? The problem is that SuperDuper gets stuck when it launches and the external drive is not already mounted and the only option is "cancel." I need to automatically mount the external drive before SuperDuper even launches. How do I do that?
|
#4
|
||||
|
||||
If you plug the drive in at that point, it should be recognized and the copy should continue.
__________________
--Dave Nanian |
#5
|
|||
|
|||
I understand that, but I'm trying to get things set up so that the drive is automatically mounted, superduper runs, and the drive is automatically unmounted. That's what the scripts provided above do. My problem is how to get the external drive mounted before SuperDuper tries to do its thing. I've fiddled with the crontab file, and I've managed to get the drive mounted before SuperDuper runs. But when SuperDuper attempts to run the "unmount drive" script, it reports that "permission is denied". So, I've found a half-solution, so far.
|
#6
|
||||
|
||||
You'll need to use the general framework we provide in our own copy template, and you'll want to run with "without user interaction", too.
__________________
--Dave Nanian |
#7
|
|||
|
|||
Quote:
My mount script is: (compiled & saved as an application in Script Editor, and set to run as an alarm in iCal) set diskName to "Backup" set deviceName to do shell script "diskutil list | grep \"" & diskName & "\" | awk '{print $6}'" do shell script "diskutil mountDisk /dev/" & deviceName |
#8
|
||||
|
||||
Thanks for the AppleScript code, Keith.
Here's a shell command example of the method I use to obtain the device node for a volume (e.g. Backup) with diskutil: % diskutil list | awk '/ Backup / {print $6}' disk1s5 There's a space before and after the Backup string so it's recognized as a single word to differentiate it from my BackupBoot volume. And to mount it: % diskutil mount `diskutil list | awk '/ Backup / {print $6}'` Volume disk1s5 mounted |
#9
|
|||
|
|||
Quote:
|
#10
|
||||
|
||||
Tom -- this functionality is now integrated into SD! itself, so you shouldn't have to do this at all. Just unmount the drives after you're created the schedule(s) with 2.1.1, and we'll take care of the rest.
__________________
--Dave Nanian |
#11
|
|||
|
|||
Quote:
|
#12
|
||||
|
||||
That's right, though, Tom -- the automount only happens when the schedule fires.
__________________
--Dave Nanian |
#13
|
|||
|
|||
Quote:
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|