Time Machine Backup to any Network Attached Storage (NAS)

I learned today that a somewhat undocumented feature of Mac OS allows users to backup to any NAS, and not just AirPort or NAS with the Apple Filesystem.

The reasons this is interesting is because, first, AirPort has been discontinued, so it’s no longer an option. Secondly, I’ve tried running a NAS formatted as HFS+ on my Raspberry Pi from guides like this. Unfortunately, in my experience, HFS+ support on Linux is not great, and if the device wasn’t properly unmounted (e.g. a power outage), the filesystem would get corrupted and couldn’t be fixed.

The solution I bring you today is compatible with EXT4, the native filesystem for Raspbian (Debian).

My setup

I have a raspberry pi (RPi) that’s connected to my router via Ethernet, and also connected to two 2TB hard drives.

The RPi, among other things, is running Samba, that allows any client on the local network to access any file on those USB drives. Pretty convenient to stream videos, etc.

Two 2Tb USB drives connected to Raspberry Pi, and RPi herself connected to Netgear home router. Note the hard drives are fed by a USB power rack.

Turning an EXT4 NAS Time Machine capable

On the Raspberry Pi

I am assuming your USB drive is already mounted and you can access it from another device on the network using samba. If that’s not your case, I can recommend this guide.

With that done, last part is to install Netatalk. Netatalk is included on the standard Raspbian package repository, but the version there is too old; so instead, we are going to compile the latest version available.

First off, install the system dependencies that will let you compile netatalk:

On your Mac

After running this command, head to your Time Machine preferences. Once there, go to Select Disk, your NAS should be selectable:

After that, the first backup should complete. It will probably take a long time (4+ hours). My advice is to leave your Mac plugged overnight, with the screen off, and to check the next morning. After that, new backups are incremental, hence small in size and much faster.

Give your self a pat in the back, your Mac will now back up on its own at everyone opportunity it gets on your NAS.

Also, very important that if you plan to run this 24/7, as I do, I can’t recommend enough getting a USB Power Hub with an external power supply. Hard drives have high peak demands that the RPi will most likely not be able to meet, with its simple power control unit, this will lead to a courrupt file system.