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

Go Back   Shirt Pocket Discussions > SuperDuper! > General
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-25-2007, 01:48 PM
minckster minckster is offline
Registered User
 
Join Date: Apr 2006
Posts: 18
Pause/Restart VisualHub & Transmission for SD! backup

I'd like to see if anyone has any comments or suggestions for the way that I went about pausing and restarting VisualHub and Transmission during SuperDuper's backups. It works, but seems a bit messy and convoluted. (If left running, VisualHub and Transmission muck up SD's backups because they create large files and run for a long time.)

The general idea is that I created an AppleScript using Script Editor to pause the two apps and another to restart them. Since SuperDuper! won't let me run an AppleScript before and after backups (and since I couldn't figure out how to translate them into shell scripts ), I saved the AppleScripts as applications (File -> Save As -> application from dropdown menu). Lo and behold! SD would let me run my newly created applications as scripts before and after my backup.

The AppleScripts follow. The shortcuts to pause the apps are cmd-. for ViusualHub and opt-cmd-. for Transmission.
Code:
-- Pause VisualHub or Transmission, if running 
tell application "System Events"
	if ((count (every process whose name is "VisualHub")) > 0) then
		tell application "VisualHub" to activate
		tell application "System Events"
			tell process "Visualhub"
				-- Pause Conversion in VisualHub
				keystroke "." using {command down}
			end tell
		end tell
	end if
	
	if ((count (every process whose name is "Transmission")) > 0) then
		tell application "Transmission" to activate
		tell application "System Events"
			tell process "Transmission"
				-- Pause all downloads in Transmission
				keystroke "." using {option down, command down}
			end tell
		end tell
	end if
end tell
Code:
-- Resume VisualHub or Transmission, if running 
tell application "System Events"
	if ((count (every process whose name is "VisualHub")) > 0) then
		tell application "VisualHub" to activate
		tell application "System Events"
			tell process "Visualhub"
				-- Resume Conversion in VisualHub
				keystroke "/" using {command down}
			end tell
		end tell
	end if
	
	if ((count (every process whose name is "Transmission")) > 0) then
		tell application "Transmission" to activate
		tell application "System Events"
			tell process "Transmission"
				-- Resume all downloads in Transmission
				keystroke "/" using {option down, command down}
			end tell
		end tell
	end if
end tell
I should mention that I tried
Code:
#!/bin/sh
exec osascript <<END
. . . (insert AppleScript here) 
END
but that caused the VirtualHub and Transmission to open before the script evaluated "count (every process ...", so the if-clause was always true.

Please be gentle! They're only my second and third AppleScripts, and are the result of much Googling, copying, pasting, trial and error.
Reply With Quote
  #2  
Old 07-05-2007, 07:00 AM
minckster minckster is offline
Registered User
 
Join Date: Apr 2006
Posts: 18
I simplified the scripts (below), so now I don't have to schedule my bittorrent downloading or video conversion around my SuperDuper backup schedule.
Code:
-- Pauses VisualHub and Transmission, if running
--    So they won't muck up SuperDuper's scheduled backups

tell application "System Events"
	if (exists process "VisualHub") then
		tell process "VisualHub"
			set frontmost to true
			tell me to do shell script "/bin/sleep 5"
			keystroke "." using command down
		end tell
	end if
	
	if (exists process "Transmission") then
		tell process "Transmission"
			set frontmost to true
			keystroke "." using {option down, command down}
		end tell
	end if
end tell
The "sleep" line helps with those instances where I'd awake in the morning to find VisualHub as my frontmost app, but not paused, and SD! most distinctly unhappy with that situation.
Reply With Quote
  #3  
Old 07-05-2007, 09:20 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
Working well for you?
__________________
--Dave Nanian
Reply With Quote
  #4  
Old 07-05-2007, 10:05 AM
minckster minckster is offline
Registered User
 
Join Date: Apr 2006
Posts: 18
The last three nights the script above worked fine.

The problem was (is?) that the "keystroke" for pausing VisualHub didn't seem to catch always. vh124ffmeg, which is the process that does the actual video conversion, takes 100% of my CPUs (nice'd), so there can be a delay getting VH to come to the foreground. That delay is what made me insert the sleep before the "keystroke". Could "delay" be a better choice for me than "/bin/sleep" in this instance?

I wish I could find a way of sending a pause command directly to either VisualHub or vh124ffmpeg instead of flailing around with "System Events" and "keystroke", but that seems more like a question for the VH forums than SD's.

Thanks for the great comments in your scripts! I guess you can recognize the sleep snippet above. I think I picked up "if exists process" from you too.

Last edited by minckster; 07-05-2007 at 10:14 AM.
Reply With Quote
  #5  
Old 07-05-2007, 10:11 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
Yeah, I tried to document the script as completely as is practical, and I'm glad it proved useful to you...
__________________
--Dave Nanian
Reply With Quote
  #6  
Old 08-05-2009, 01:50 PM
gcoghill gcoghill is offline
Registered User
 
Join Date: Nov 2007
Posts: 33
How does one run these from the Super Duper options? Using the shell script option and choosing the AppleScripts saved as applications?
Reply With Quote
  #7  
Old 08-05-2009, 02:07 PM
gcoghill gcoghill is offline
Registered User
 
Join Date: Nov 2007
Posts: 33
Also, this hint at MacOSXHints.com suggests saving scripts as Application Bundles if you are on an Intel Mac.
Reply With Quote
  #8  
Old 08-05-2009, 02:26 PM
minckster minckster is offline
Registered User
 
Join Date: Apr 2006
Posts: 18
Quote:
Originally Posted by gcoghill View Post
How does one run these from the Super Duper options? Using the shell script option and choosing the AppleScripts saved as applications?
Yes.

Now a long answer, to avoid problems or gotchas.

From the main SuperDuper! screen, select Options > Advanced > check "Run shell script before copy starts" and enter the path to the script. See attached image.

Note that my newest Pause script makes SD! wait until Turbo.264 is done, because T.264 doesn't have a pause feature. The script then pauses VisualHub, Handbrake, and Transmission. The Resume script restarts VisualHub, Handbrake, and Transmission. Both scripts have worked great for many months without fail.

I saved both AppleScripts as "Applications" in Script Editor (File > Save As). Watch out for the options, in particular "Startup Screen" which should be off.

A silly gotcha: Once you've saved the script as an application, you have to open Script Editor and then go to File > Open to edit the application.

Also, my scripts use "GUI Scripting", so you'll need to enable that in the "AppleScript Utility" if your scripts use 'tell application "System Events"' and something that's -- well, GUI (keystroke,...).
Attached Images
File Type: png Picture 1.png (53.7 KB, 906 views)

Last edited by minckster; 08-05-2009 at 02:55 PM.
Reply With Quote
  #9  
Old 08-05-2009, 02:31 PM
minckster minckster is offline
Registered User
 
Join Date: Apr 2006
Posts: 18
Quote:
Originally Posted by gcoghill View Post
Also, this hint at MacOSXHints.com suggests saving scripts as Application Bundles if you are on an Intel Mac.
Thanks!! I had no idea. I'll go switch to application bundles.

Edit to add: I just verified that on 10.5.7, my AppleScript-Applications were indeed PowerPC applications.

Last edited by minckster; 08-05-2009 at 02:34 PM.
Reply With Quote
  #10  
Old 08-05-2009, 03:56 PM
gcoghill gcoghill is offline
Registered User
 
Join Date: Nov 2007
Posts: 33
Sounds great, thanks for the info!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
SuperDuper Failing on Backup - I/O Errors Stephen Kuhn General 1 08-13-2006 04:03 PM
Source HD won't boot after canceled Backup enderws General 3 03-04-2006 04:02 PM
How to verify a Scheduled Backup? tuqqer General 3 12-06-2005 06:50 PM
(Zero-length) File caused SuperDuper to abort backup alancfrancis General 7 08-31-2005 10:42 AM
Smart Backup Error bill s General 20 02-04-2005 09:46 AM


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


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