Website Logo. Upload to /source/logo.png ; disable in /source/_includes/logo.html

Zuzur’s wobleg

technology, Internet, and a bit of this and that (with some dyslexia inside)

Time Machine on a Network Drive : You Will Need to Increase the Band Size …

| Comments

… but not by hiring a new drummer :-)

My QNAP TS-209 pro’s newest firmware introduces direct support for Time Machine. It works out of the box and it is pretty cool, but i quickly realized there will be a problem in the long run: a full backup of my macbook creates about 22 000 bands in the sparse bundle volume, which the poor little QNAP has a lot of trouble reading. I believe Time Capsules and many other appliances with few CPU cycles to spare on reading directories will have troubles too. Maybe someone in Apple could think about adding 1 or 2 levels of directories in the bands of sparse images ? That would make a lot of happy Time Capsule users ;-)

Suggestion:

  • bands are named by hexadecimal codes (0..f, then 2 letters when the namespace is exhausted, etc …), so create one sub-directory per prefix. 0/(every file that starts with 0), …, f/(every file that starts with f).

  • in order to maintain compatibility with existing sparsebundle volumes, add a “directory-prefix-level” key in Info.plist that will be used by the function that returns a band in the bundle to find the band’s exact location.

  • directory-prefix-level should be increased each time the namespace exhausts, and the storage driver should be updated to redistribute files across the new directories when it happens (blocking any access to the volume when it happens). This is a classical problem to solve in a B-TREE (key redistribution in pages)

So, until Apple fixes their sparse bundle driver, the solution is to increase the band sizes, in order to make sure to have less files in the directory.

You need to have an existing backup stored on your NAS. First, I strongly suggest making a copy of the backup’s directory if you care about your backups (you care about your backups, don’t you ?)

The QNAP Time Machine service creates a share named /share/TMBackup. Once time machine has used it one time (even with a cancelled backup), it will contain a directory named after your mac’s hostname (mine is moody)

moody.sparsebundle

This directory is a plain, standard sparse bundle as those created with hdiutil(1), with the exception of a file named com.apple.TimeMachine.MachineID.plist. This file links the backup to your host (it contains its hostname and MAC address), and Time Machine will not recognize a sparse bundle as one of his if it can’t find this file in it. When this happens, TM creates another directory and starts all over: moody 1.sparsebundle

Make sure TM won’t try to access the drive remotely while you run the procedure. You should disable it altogether by choosing “no drive” in it’s preferences pane.

Make sure you have the share mounted, it should be accessible from a terminal. In order to do that, “enter Time Machine”, cancel, open a Terminal, sudo and then i was finally able to cd /Volumes/TMBackup (the name of the volume will obviously change depending on your setup)

Create a copy of your sparse bundle. This procedure needs free space, i believe there is no way to convert a sparse bundle in place, if you know how do to that in place, i’d be happy to hear about it :-) : hdiutil convert -verbose -tgtimagekey sparse-band-size=262144 -format UDSB moody.sparsebundle -o tmp.moody.sparsebundle

It will take a long time. Maybe hours for an existing, valid backup. Be warned. You are transferring a lot of data across the network.

Once the command completes, you should have moody.sparsebundle and tmp.moody.sparsebundle in the share directory on the NAS. Copy com.apple.TimeMachine.MachineID.plist to the new location:

cp moody.sparsebundle/com.apple.TimeMachine.MachineID.plist tmp.moody.sparsebundle/

Change the new sparse bundle’s name to the former one:

mv moody.sparsebundle moody.sparsebundle.old mv tmp.moody.sparsebundle moody.sparsebundle

You should be good to go with TM now. Give it a try …

Once you have validated TM can access your new bundle and is displaying data from your backup, you can get rid of the old moody.sparsebundle.old directory.

Comments