Use a SMB share as a Time Machine disk

Time Machine-networkA lot of people moan that this functionality should’ve been included by Apple and be fully supported. Anybody else who had excluded this would’ve been ridiculed, but being Apple, they get away with it. Was it a business decision so that they can market their own Time Machine backup appliance? Or was it lack of programming time/talent?

As usual, I’m documenting this for my personal effects so that I can easily reference it later; but if somebody finds this on google and it helps, great. It took me a couple of minutes compiling how to pull this all together from a couple of different sources. Just a quick note: I find the difference between the windows and mac community is that mac people never document anything completely. They either leave out steps they just assume people should know or their they’re poor writers (I guess I’m a poor writer too). Not sure which.

On a difficulty scale of 1 to 10, this one is going to be a 4. Just because you have to know how to setup a server in the first place that has an SMB share … or a NAS I suppose. I’m going to go ahead and assume that you already have a server, or NAS, with an SMB share ready to go. As a sidenote, if this server is shared with other people, please, take the time to setup a dedicated account that has read/write for this share.

  1. This is the easiest to find step. Open up terminal:
    defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
  2. Most of the sites will say log out and log back in … not necessary. Again, in terminal:
    killall "Finder"
  3. In Finder, mount the new share, Go – Connect to Server – smb://, and use the account you want to connect with.
  4. Open up Time Machine and you will now see your SMB share listed as an available drive.

Now here’s where things get a bit annoying. You’ve enabled Time Machine to see SMB (and AFP, etc) shares as Time Machine backup drives. There’s just a small problem to overcome: size. Time Machine isn’t smart enough to allow the user to set the maximum size of the backup set, so it’ll cherrily hog the whole thing. If you notice, Time Machine will delete old backup sets and keep files needed for a full restore between backup sets. That’s great, but say your server or NAS has 1.5TB of space free, do you really want that all dedicated as backup?
Windows server, and most NAS, can implement per-user quotas. So that’s one way to limit the size of the back, especiallly since you’re already using a dedicated user account for security purposes.
The other way to do is, is create your own sparsebundle image with a limited size and slip it in as the Time Machine’s sparsebundle. And here’s where my description differs from other tutorials … I take the easy way out. Most of the other tuts tell you to get your machine name, and your mac addr and combine them for the proper name of the sparsebundle that you need. Nah, that’s too much work.

  1. Now that Time Machine sees your SMB share, select it. Let it do it’s thing.
  2. This is where I cop out, and go the easy route. Hop on over to the Time Machine SMB share, get info on the sparsebundle directory and copy the name.
  3. Stop the Time Machine backup at this point and turn it Off
  4. Think a little bit about how much space you want to give to your Time Machine backup. My OS X install typically stays around 40-50GB (unless I’m working with video) so I only gave it 160GB total.
  5. Back to terminal again:
    hdiutil create -size XXg (XX = size in GB) -type SPARSEBUNDLE -nospotlight (Keeps spotlight from indexing it) -volname “Name of your Backup” -fs “Case-sensitive Journaled HFS+” -verbose ./Computername_MACaddress (Just insert your copied file name from previous step)
  6. Now just copy this over to the SMB share (overwriting the old one if Time Machine left it behind).
  7. Turn Time Machine back On and force a backup.

A couple of notes now. If you’re on wi-fi, and you can, do the first backup over wire. Otherwise be patient and be prepared for it to run overnight. There are a lot of older posts about Time Machine not cleaning up the sparsebundle correctly and deleting backups without notification while not shrinking the size. This has been fixed in the latest update so make sure you’re running the latest. I’ve personally encountered Time Machine claiming that it wasn’t able to mount the backup volume eventhough it could be done in Finder. For me, a reboot fixes it. I still need to look into this further because it should be easier than a reboot … I was just in a hurry. [Update: just saw that one of the improvements in 10.5.6 released today was a fix for issues that could cause Time Machine to state that the backup volume could not be found. Possibly?]

Now, for some other fun stuff. If you have Finder set to display mounted volumes on the desktop, the Time Machine SMB volume is going to mount each time the backup runs. Macosxhints.com has a really easy way to cover this. And make sure to check out the link toward the bottom that shows you how to look to see if you already have SetFile on your computer as part of another package.

[update]
If you ever change your Mac’s hostname ( sys prefs – sharing – comp name ) you’ll also have to change the name of the sparse file otherwise Time Machine won’t be able to mount the image. (Probably the same thing happens if you’re using a supported drive too?)

[update 8/8/09]
After installing the parallels demo I’m now having massive issues with my network adapters. VPN connections drop after a few minutes, airport connections drop, but most importantly my time machine back ups have been corrupting because of the airport connection drops. Unfortunately, I recall this happening the last time I tried Parallels and didn’t learn my lesson. I’ll either have to dig up info on deleting and recreating my network adapters or reinstall OS X from scratch (which is what I think I did last time).

[update 8/12/09]
Finally it got posted today that it’s a problem with Mozy that I’ve also been using for the free 2GB of backup. I was using it for my docs folder and my itunes db, just to have a quadruple copy somewhere else. Uninstalled Mozy, and now Time Machine is working again. Unfortunately, I was tearing my hair out and killed my old sparsebundle.