Sunday, February 21, 2010

Symbolic Links are awesome!

OK, so I've known about symbolic links for a long time, but still, they just do the right thing 99% of the time, which is just awesome.

I recently bought a Drobo to store all of the data that has been maintained on our very power-hungry server at home.

This weekend I spent some time copying files from the server, but I also wanted to set up a Time Machine backup of my iMac (which is directly connected to the Drobo). However, I didn't want my own time machine (on the local disk) to take up all the space. I did some searching and found lots of ways to limit the space needed on a networked drive, but nothing much for a local drive. That is, until I found this blog.

The gist is that you need to create a sparse bundle disk image and put it at the root of your Drobo volume. If you don't put it at the root, it just won't work. This is because Time Machine will look for a file named MachineNetworkName_MACaddress.sparsebundle (e.g. mymachinename_a1b2c3d4e5f6.sparsebundle) at the root, and if it doesn't find a sparse bundle with that name which it can mount, it reverts to using the file-based approach of a local drive. Also, the sparse bundle can't be encrypted because then Time Machine can't mount it. What I also found odd is that you can't mount the image and point to it as the Time Machine disk; instead, Time Machine has to be pointed to the Drobo volume.

So, after some trial and error finding out all of the things that won't work, I got the sparse bundle approach to work, and truth be told, it works great. Time Machine mounts the image and backs things up great. I don't know for sure that it will limit the size to what I gave it (1TB), but I'm hoping it will, and it seems like it should given the fact that the image has only 700GB or so free.

But there was this niggling detail I didn't like: the image was at the root of the drive. That's just dumb. I want the image to be somewhere else in the directory structure of the Drobo. I'm anal that way, and I'm ok with that. So, I decided to just check to see if a symbolic link would work. And it did!

For those of you unaware of the power of a symbolic link, it's file in one directory that really just points to another file or directory somewhere else. The beauty is that it can point to a directory on your local system or even a mounted volume. It's brilliant for so many things, especially when you have multiple hierarchies for things. It's similar to a shortcut in Windows, but much more powerful since the applications on your system don't need to know anything about them: the symbolic link just looks like the file it's pointing to. In Finder, these look like Aliases, but that's OK, I know what it is underneath.

Now I can have my Time Machine image in a logical place, and a simple little symbolic link at the root. Still annoying that I need that, but I'll live with it.

Now, if only I'd thought to use symbolic links when setting up my iTunes library against a mounted volume. That would have saved me a ton of time since I now have to point all of those Media share references to a local volume. Maybe a symbolic link in the Volume directory will work. I'll have to try it out.