Improve Time Machine performance on network drives

For those who use Time Machine backups over a network drive, it’s possible to optimize Time Machine disk image using larger sparsebands with some command line steps.

Time Machine creates a sparse bundle disk image to store backups.
A sparse bundle disk image is a virtual disk consisting of blocks stored on files. The image could be mounded and used like any external disk.

By default, the size of the bands (which are the physical files in which virtual disk data blocks are stored) is 8 MB, so for a backup of 100 GB over 12000 band files are created and modified during subsequent backups.
This can cause performance bottlenecks and slow down your backup time, in particular on network drive.

This guide explains how to simple convert the Time Machine image file in order to use 128 MB band size and therefore improve backup performance.
The protocol used in this guide is AFP (which is the one used by almost all NAS producer), but can be adapted also for other protocols.

 

The fastest way is to convert the image file during the creation, so during first backup.
In this case, the best way is to:

  • Open Console application
  • Setup Time Machine to backup on your network drive
  • While Time Machine starts first backup, keep looking at the Console window
  • Stop the backup after this line appears:
    com.apple.backupd[*]: Forcing deep traversal on source
  • At this point, the volume is already created and can be converted quickly because will be near empty

The conversion could be done also on a volume already in use, but will temporary duplicate the volume, so verify the available space on the network drive (including user quotas) and be prepared to huge runtime for the conversion.

You must fit the parameters in highlighted lines:

  • <hostname/IP> : Hostname or IP of the server/appliance that hosts the Time Machine share
  • <share_name> : Name of the Time Machine share
  • <share username>  / <share password> : Username and password used on network share by Time Machine
  • <volume name> : Name of the backup volume (instead of the default “Time Machine Backups”)

Commands 10 to 12 are optional, in case you want to rename your Time Machine volume.

 

For older OS X versions (up to and including OS X 10.9 “Mavericks”), you can directly create the Time Machine volume with the right sparse bundle size, before the first backup.
The trick I’ve used is to name the file as hostname plus mac address of en0 network interface, so Time Machine uses (and renames) it, during first backup.

 

After that, Time Machine will run faster on network drives.
I’ve also experienced less problem of backup volume corruption, but I haven’t made any scientific experiment about this point.