Wednesday, November 3, 2010

Manually Creating MacOS Time Machine Targets

You can convince MacOS' Time Machine to backup to just about any volume, local or network, as long as you prepare it with a specially-named "sparsebundle" file in the top of the volume you want to backup to.  Here's an example of how I get Time Machine to backup to my NAS appliance.  Here's my setup:
  • My computer is named "neap"
  • My NAS appliance is named "spring"
  • My NAS appliance has a CIFS shared volume called "backups"
First thing you have to do is create the sparsebundle file.  What Time Machine is looking for is a sparsebundle file named with your system's hostname, then an underscore, and then your machine's main ethernet address, with ".sparsebundle" on the end.  Furthermore, the volume name has to be "Backup of " your hostname.  You have to create this on your local system -- not directly on the NAS volume -- I've got no idea why.  I use a command-line invokation of hditutil, to do this.  Open the Terminal app (In your Applications directory, in the Utilities subdirectory) and issue this command:

  hdiutil create -fs HFS+J -volname "Backup of `hostname -s`" `hostname`_`ifconfig en0 | grep ether | awk '{print $2}' | sed s/://g`.sparsebundle

Or if you would like to define an upper limit to how much space this Time Machine target can occupy total, add a "-size" argument, like this:

  hdiutil create
-size 420g -fs HFS+J -volname "Backup of `hostname -s`" `hostname`_`ifconfig en0 | grep ether | awk '{print $2}' | sed s/://g`.sparsebundle

Kewl, now mount your target NAS volume.
  • In the Finder I choose "Connect to Server..." from the "Go" menu.
  • I enter "smb://spring/" since "spring" is the name of my NAS file server.
  • Click connect, and when prompted I supply my connection credentials.
  • From the list of available volumes on "spring" I select "backups" and click OK.
And now I move my new "sparsebundle" file into the NAS volume.  Again, on the command line.  In the terminal I issue this command:

  mv *.sparsebundle /Volumes/backups/

And at this point, I can run Time Machine as usual, and tell it to backup to the network volume.  I do this:
  • From the Apple menu, I select "System Preferences"
  • Click the "Time Machine" icon.
  • Click "Select Disk"
  • It should list the NAS volume, in my case it's "backups" on "Backup to spring"
  • I click the volume name once, then click the "Use for Backup" button.
  • I supply my username and password, so that Time Machine can reconnect in the future.
  • After that, Time Machine switches to "On" and starts counting down to the next backup.
And that should be it.  When the countdown hits zero, Time Machine should begin to backup to the NAS volume.  Seriously convoluted, but now you're backing up to a NAS volume, and optionally you've set an upper limit on disk space your backups can take -- so Time Machine won't try to fill the disk.  w00t!

No comments:

Post a Comment