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 03-08-2007, 11:10 PM
parabel parabel is offline
Registered User
 
Join Date: Nov 2006
Posts: 3
Question Automated Sparse Image Shrinking?

Hello!

Is there a way to shrink my sparse image file automatically every time after updating it with SuperDuper?
At the moment, after using SD! I always shrink it manually with the "hdiutil compact " command in the Terminal.

Could I make a script and include it in the backup/updating process of SD?
And how would this script have to look like?

Or will this soon be an easy-to-use checkbox option included in SD? (Still hoping for it!) (If so, I would also appreciate an additional option to shrink it only every xx-th backup. )

Thanks for your answers!
Reply With Quote
  #2  
Old 03-09-2007, 09:46 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
You could try to do this, parabel, but it's not a really good idea to over-compact. How about writing yourself a little AppleScript that you can schedule in iCal ever few weeks?

If you really must do this in SD!, you'd want to use a shell script like:

Code:
!/bin/sh
nohup /bin/bash -c "sleep 30;hdiutil compact $6" &
Basically, this put a background process in place that waits 30 seconds, then compacts the image. We wait 30 seconds (and go into the background) because SD! isn't done with the image when the after copy script runs. So, we wait 30 seconds to try to give it a chance to complete. $6 is the 6th parameter to the script, which is the name of the image file being processed. See the User's Guide for more information...
__________________
--Dave Nanian
Reply With Quote
  #3  
Old 03-10-2007, 11:14 AM
klmorin klmorin is offline
Registered User
 
Join Date: Aug 2006
Posts: 28
What is your reserve when you write: “but it's not a really good idea to over-compact”?

I am not familiar with the process of scripts. I would like such a script carry out by iCal or SD using the option “Run shell script after copy completes”.

I sought well in iCal and SD guide, but I do not reach that point. Could you be more specific with the steps to be followed?

Thank you very much
Reply With Quote
  #4  
Old 03-10-2007, 11:16 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
You know, if you're not terribly familiar with shell scripting, etc, it might not be a good idea to take these steps, since it requires a certain amount of familiarity with Unix... you sure you want to avoid doing this manually every so often?
__________________
--Dave Nanian
Reply With Quote
  #5  
Old 03-10-2007, 12:27 PM
klmorin klmorin is offline
Registered User
 
Join Date: Aug 2006
Posts: 28
I have every intention of familiarize me with the writing of scripts, not only for SD. I seek references on the subject.
The option “Run Shell script after Copy” could be enabled, only when needed, without having to repeat each time the operations in Terminal.
Reply With Quote
  #6  
Old 03-10-2007, 01:13 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
There are many books on Shell Scripting, including a number of well known ones from O'Reilly. I think there are even online versions of those books that can be accessed, perhaps even for free...
__________________
--Dave Nanian
Reply With Quote
  #7  
Old 03-10-2007, 02:00 PM
klmorin klmorin is offline
Registered User
 
Join Date: Aug 2006
Posts: 28
I start to work immediately...
Reply With Quote
  #8  
Old 03-17-2007, 12:28 PM
klmorin klmorin is offline
Registered User
 
Join Date: Aug 2006
Posts: 28
Smile Eureka!

Eureka!

I do not know, Dave, if you will approve?

Here is an AppleScript which I make run by SD via the option “Run Shell after Copy complete”
We can enable the option as need or leave it always enabled.

---------------------------
tell application "Finder" to eject disk "MyBackup"
-- wait for it
repeat until (list disks) does not contain "MyBackup"
delay 2
end repeat
delay 30
set diskImage to POSIX path of "/Volumes/MyDisk/BackupFolder/MyBackup.sparseimage"
do shell script "/usr/bin/hdiutil compact " & quoted form of diskImage
----------------------------

I used AppleScript editor to write and compile this script and I saved it as application (Compact.app) in Saved Setting. Obviously, if there are several scenarios of backups, each one must have its own adapted script.
Reply With Quote
  #9  
Old 03-17-2007, 01:40 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
Well... there can definitely be issues there, because SD! doesn't expect the volume to vanish during the "After" script...
__________________
--Dave Nanian
Reply With Quote
  #10  
Old 03-17-2007, 11:07 PM
klmorin klmorin is offline
Registered User
 
Join Date: Aug 2006
Posts: 28
However, i certify that this script works perfectly. I tested it.

It ejects volume “MyBackup” and thus releases the image disc “MyBackup.sparseimage”.
The operation hdiutil compact can then be carried out.

And SuperDuper! finish its operations all gently, normally, as it should be.
No problem, no message of error.

I admit not too well understand how the last instruction “unmount MyBackup” can be carried out, but it's done. I'm merely stating a fact.
Attached Images
File Type: png Window.png (96.6 KB, 668 views)
Reply With Quote
  #11  
Old 03-17-2007, 11:15 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
Oh, I believe you: I'm just saying that we don't expect that script to eject the image, so I can't guarantee it'll continue working...
__________________
--Dave Nanian
Reply With Quote
  #12  
Old 03-18-2007, 08:30 PM
klmorin klmorin is offline
Registered User
 
Join Date: Aug 2006
Posts: 28
For the skeptics, there is also this freelance version.

------------------------------
choose file with prompt "Compact this sparse disk image:" without invisibles
set diskImage to POSIX path of result
do shell script "/usr/bin/hdiutil compact " & quoted form of diskImage
display dialog diskImage & "
-- Compresssing process completed -- "
-------------------------------

It makes more user-friendly the hdiutil of Terminal and can be used when needed.

This script must be written, compiled and be saved in the same way that the precedent, but used then like any application.

Last edited by klmorin; 03-18-2007 at 08:32 PM.
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
Restoring from sparse image catxtwo General 7 11-11-2008 03:25 PM
Ever-Growing Sparse Image File... Marco_Polo General 6 02-19-2007 10:21 AM
Testing a sparse image... macmidiguy General 5 05-14-2006 01:51 PM
not ejecting sparse image after backup rossb General 7 02-08-2006 05:20 PM
Sparse image from aborted DMG backup? Winston General 9 10-22-2005 12:28 PM


All times are GMT -4. The time now is 05:19 AM.


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