Setting up Time Machine on a generic NAS

If you have a NAS that can serve SMB shares, you can use it for Time machine with a few simple tricks:

You need to create a sparsebundle volume locally, to copy over to the NAS and use as the backup root. This permits us to use a Journaling HFS+ filesystem for the backup even though the NAS uses some other filesystem with its own naming and permission scheme. The name of this bundle is apparently important, and has to contain both the host name and the MAC address of your computer.

Find out your MAC address on en0 by running

ifconfig en0
and looking for the string "ether". Write this down, without the colons.

Find out your hostname by running the command
hostname
Write this down, except for the trailing domain name.

Create the sparsebundle structure:
hdiutil create -size 128g -fs "HFS+J" -type SPARSEBUNDLE -volname "Backup of myhost" myhost_001f5b316e9c.sparsebundle
Adjust the volume name and the destination (last argument) by replacing the hostname and the MAC address with your own (without the colons!)

Now connect to the NAS with SMB and open the directory where you want to keep the Time Machine backup.

Copy the entire sparsebundle structure there:

cp -r seupp-myhost_001f5b316e9c.sparsebundle /Volumes/mybackupdir
(changing the command as needed)

Now you need to trick Mac OS into considering disks that aren't explicitly supported by Time Machine:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Now go to System Preferences | Time Machine and set it up:

  • Turn it On
  • Go to Change Disk... and select your private share on the NAS, which should now appear in the list.
  • Go to Options... and add everything non-essential to the "Do not back up" list.

Then click on the Time Machine icon in the menu bar (hint: looks like a clock with a counter-clockwise arrow around it). Select "Back Up Now" and wait.

If the backup fails, some troubleshooting will be necessary. If it succeeds, Time Machine should keep backing up your computer once every hour, saving daily and weekly backups depending on available space.

You can remove the local copy of the sparsebundle when you're done.