Shirt Pocket Discussions  
    Home netTunes launchTunes SuperDuper! Buy Now Support Discussions About Shirt Pocket    

Go Back   Shirt Pocket Discussions > SuperDuper! > General

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 4.67 average. Display Modes
  #1  
Old 02-20-2005, 03:22 PM
kbradnam kbradnam is offline
Registered User
 
Join Date: Feb 2005
Location: Davis, CA
Posts: 25
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]
Reply With Quote
  #2  
Old 02-20-2005, 03:45 PM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,923
Send a message via AIM to dnanian
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
Reply With Quote
  #3  
Old 07-28-2007, 01:03 PM
AVT AVT is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
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?

Quote:
Originally Posted by dnanian View Post
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!
Reply With Quote
  #4  
Old 07-28-2007, 01:08 PM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,923
Send a message via AIM to dnanian
If you plug the drive in at that point, it should be recognized and the copy should continue.
__________________
--Dave Nanian
Reply With Quote
  #5  
Old 07-28-2007, 02:22 PM
AVT AVT is offline
Registered User
 
Join Date: Jul 2007
Posts: 2
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.

Quote:
Originally Posted by dnanian View Post
If you plug the drive in at that point, it should be recognized and the copy should continue.
Reply With Quote
  #6  
Old 07-28-2007, 03:54 PM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,923
Send a message via AIM to dnanian
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
Reply With Quote
  #7  
Old 07-30-2007, 07:12 AM
Wings Wings is offline
Registered User
 
Join Date: Mar 2007
Posts: 10
Quote:
Originally Posted by AVT View Post
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?
AVT: What I do is to set iCal to run a mount script about a minute or 2 before SD is scheduled to run.

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
Reply With Quote
  #8  
Old 02-22-2005, 04:22 AM
sjk's Avatar
sjk sjk is offline
Registered User
 
Join Date: May 2004
Location: Eugene
Posts: 252
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
Reply With Quote
  #9  
Old 05-30-2006, 08:53 AM
tom.coady tom.coady is offline
Registered User
 
Join Date: May 2006
Posts: 3
Quote:
Originally Posted by kbradnam

eject "External HD"
end tell
The mount script works if I enter Backup instead where my firewire drives are called Backup A and Backup B, but is there a way to eject Backup * or all mounted external drives so I don't have to name the drive specifically?
Reply With Quote
  #10  
Old 05-30-2006, 09:22 AM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,923
Send a message via AIM to dnanian
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
Reply With Quote
  #11  
Old 05-30-2006, 11:25 AM
tom.coady tom.coady is offline
Registered User
 
Join Date: May 2006
Posts: 3
Quote:
Originally Posted by dnanian
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.
Thanks Dave. I just tried this and it did nothing and when I opened SD it popped up a messages saying "Please attach or mount the volume named "Backup B". If you can't find this volume, or it was erased outside SuperDuper!, click Cancel." - but the FW vol was mountable using a script modded to find its name.
Reply With Quote
  #12  
Old 05-30-2006, 11:29 AM
dnanian's Avatar
dnanian dnanian is offline
Administrator
 
Join Date: Apr 2001
Location: Weston, MA
Posts: 14,923
Send a message via AIM to dnanian
That's right, though, Tom -- the automount only happens when the schedule fires.
__________________
--Dave Nanian
Reply With Quote
  #13  
Old 05-30-2006, 12:26 PM
tom.coady tom.coady is offline
Registered User
 
Join Date: May 2006
Posts: 3
Quote:
Originally Posted by dnanian
That's right, though, Tom -- the automount only happens when the schedule fires.
Sorry, Dave, you are right. It worked. I was looking at the wrong logs.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 6 (0 members and 6 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:07 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.