I have a disk drive connected to my router that I'm using for TM backups. What I did is I created a .sparsebundle image using Disk Utility and then copied that image to my disk drive. Then, in Terminal I typed the following:
sudo tmutil setdestination /Volumes/MYCIFSvolume
All works OK, but I have to manually mount the .sparsebundle by double clicking it and then Time Machine recognizes the drive and make backups to it.
Is there any way TM automounts this .sparsebundle when a backup is scheduled?
I'm using OS X 10.9
Many thanks,
Best Answer
These instructions assume you're using a sparsebundle file in 10.9 because you use an encrypted drive. If not, modify accordingly.
First, follow the instructions in the link below to figure out how to use
security find-generic-password
to grab the password to your encrypted drive out of your Keychain programmatically.http://blog.joshdick.net/2012/10/14/programmatically_mounting_encrypted_disk_images_in_os_x.html
Then create a file called
mounter
in your local bin directory~/bin
that contains the following code (replace all paths with your paths, and in thesecurity find-generic-password
, use the name of the key in Keychain):This is a bit verbose, but means no storing passwords anywhere but keychain. In any case, now we have to get it to run. Create a file in
~/Library/LaunchAgents/
like~/Library/LaunchAgents/com.martorana.dave.mounter.plist
and put the following code in it, replacing, of course, the paths with your own paths:We're using
launchd
instead ofcron
for a host of reasons, the most important being access to your keychain.Now load your launch daemon:
And that should do it. Now
launchd
will run your shell script every 60 seconds, and if not mounted and available, will mount yoursparsebundle
disk image.Cheers,
Dave