PDA

View Full Version : modifying copyjob.scpt to automount/unmount drive??


m021478
04-05-2008, 07:52 AM
I know this question has been asked and discussed repeatedly throughout these forums, and believe me, I have searched for the answers and I've tried my best to get the job done without posting my own question about it, however due to the fact that my Apple Scripting expertise is completely nonexistent, my best attempts have failed in every respect...

Perhaps somebody can help me figure out how to accomplish the task of automounting my chosen backup hard drive prior to running SuperDuper to create a backup, and automatically on mounting the same drive after SuperDuper has finished backing up.

This is about as far as I've gotten in the process:

-- SuperDuper! scheduled copy script template (c) 2005-2008 by Bruce Lacey. Published by Shirt Pocket.
-- Script by Dave Nanian and Bruce Lacey

beforeRunningCopy()
tell application "Finder"
if not (exists the disk "Macintosh HD Clone") then
try
do shell script "diskutil mount `disktool -l | grep 'Macintosh HD Clone' | sed 's/.*\\(disk[0-9s]*\\).*/\\1/'`"
end try

repeat while not (exists the disk "Macintosh HD Clone")
delay 1
end repeat
end if
end tell
end beforeRunningCopy

on afterRunningCopy()

tell application "Finder"
if (exists the disk "Macintosh HD Clone") then
eject "Macintosh HD Clone"
delay 2
end if
delay 2

end afterRunningCopy

For some reason, when I press the compile button in the script editor to check for errors in the way the script has been written, I am consistently getting the following error message:

'Syntax Error' - Expected end of line, etc. but found identifier"

It then highlights the word "beforeRunningCopy" in the "end beforeRunningCopy" line of text in the script above (and it does the same thing for "end afterRunningCopy")

For the life of me I cannot figure out how to fix the script so that it doesn't result in this error message!

Any assistance that anyone can offer to help me accomplish the task of Mounting my chosen backup (clone) hard drive before SuperDuper performs its cloning procedure, and un-mounting it after it has done so, would be greatly appreciated!

Thanks, and I look forward to your responses!

m021478
04-05-2008, 08:25 AM
I think I got it figured out....can someone confirm that the following code will mount my external hard drive ("Macintosh HD Clone") prior to running SuperDuper, and will also unmount the drive after the cloning process has completed...

-- SuperDuper! scheduled copy script template (c) 2005-2008 by Bruce Lacey. Published by Shirt Pocket.
-- Script by Dave Nanian and Bruce Lacey

on beforeRunningCopy()
tell application "Finder"
if not (exists the disk "Macintosh HD Clone") then
try
do shell script "diskutil mount `disktool -l | grep 'Macintosh HD Clone' | sed 's/.*\\(disk[0-9s]*\\).*/\\1/'`"
end try

repeat while not (exists the disk "Macintosh HD Clone")
delay 1
end repeat
end if
end tell
end beforeRunningCopy

on afterRunningCopy()
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
end afterRunningCopy

Thanks!

dnanian
04-05-2008, 10:12 AM
You're referencing three entirely different disks there - one is called "local_home_backup", one is called "External HD", and one is called "Macintosh HD Clone".

m021478
04-05-2008, 04:25 PM
Forgive the incorrect references...I'd obviously copied and pasted the code above from a previous thread I'd come across (and didn't replace the drive references in that code with the actual drive names I'll be using)...I tried using the code from the second post of this thread (replacing the 'External HD' portion with the correct hard drive references (which is Macintosh HD Clone), and it appears to have worked...

Can you confirm that this is the correct addition to the copy script I should apply (for an external drive named 'Macintosh HD Clone'):

-- SuperDuper! scheduled copy script template (c) 2005-2008 by Bruce Lacey. Published by Shirt Pocket.
-- Script by Dave Nanian and Bruce Lacey

beforeRunningCopy()
tell application "Finder"
if not (exists the disk "Macintosh HD Clone") then
try
do shell script "diskutil mount `disktool -l | grep 'Macintosh HD Clone' | sed 's/.*\\(disk[0-9s]*\\).*/\\1/'`"
end try

repeat while not (exists the disk "Macintosh HD Clone")
delay 1
end repeat
end if
end tell
end beforeRunningCopy

on afterRunningCopy()

tell application "Finder"
if (exists the disk "Macintosh HD Clone") then
eject "Macintosh HD Clone"
delay 2
end if
delay 2

end afterRunningCopy

dnanian
04-05-2008, 11:46 PM
Looks about right.

m021478
04-07-2008, 02:02 AM
Thanks...It ran, and it did appear to work, but I still appreciate the admin confirmation that things look setup correctly...

Thanks again!