Raspberry Pi-Powered Time Machine Backups – No Really, Do It This Way. The Other Ways Are Wrong.

TL;DR – If you want to set up a Raspberry Pi and a hard drive to act as a network Time Machine server, use Samba and ext4. If you find a post on some site that tells you to install netatalk and hfsprogs, flip off your monitor, close the tab, and Google again.

A long, long time ago, I looked into setting up a Raspberry Pi to handle network backups for all the Macs at home. There were many posts on how to set up a Pi with an USB-connected external hard drive to act as a now discontinued Airport Time Machine Capsule.

This was great and a great fit for several reasons:

  • All the machines that are relevant at home are Macs. Time Machine backups are easy to set up on the Mac side.
  • Apple discontinued the Time Machine Capsule because they want you to backup and store things in the cloud. This is stupid. Do. Not. Trust. The. Cloud. You have been warned.
  • Time Machine Capsule was a great idea in an overpriced (typical) package anyway. A Pi solution would be cheap and scale way better than TMC ever did.
  • A Time Machine Capsule would let me back up all my Macs to it on the network with little fuss on the Mac side
  • This is not my primary backup method. My primary backup method is copying my HDs every quarter or so onto a HD and putting that HD in a safe deposit box. This primary method is for the “oh shit I’ve lost everything but at least I have my files” scenario. This backup method is just for occasionally recovering a deleted file that I needed.

In google searches, there’s a slew of blogs and content farms that walk you through how to set this up. They all say the same thing, because, well, they just copy the same crap from each other. After some trial and error, turns out, the way these sites tell you do to it is absolute garbage. They’re just there to generate clicks for the site, and no one actually tested to see if they work.

Using a Raspberry Pi for Time Machine on Paul Mucur’s site is the only way to set up a reliable Pi-powered Time Machine server.. Do not trust any other site.

Do not trust howtogeek, lifehacker, etc. Do not trust any other blog site that shows you how to do this. Paul Mucur’s way is the only way to do it if you actually want a functioning Time Machine backup solution.

Every other site tells you to use Apple File Protocol via the unix package, netatalk, to communicate with the machine. They tell you also to format the drive with HFS+ and access it via the hfsprogs package. Neither technology works reliably. It’d be easy to blame the software, but it’s more likely AFP and HFS+ are terrible and have always been terrible.

I remember messing with netatalk in the late 90’s trying to get some Macs to talk to some unix shares. Fucking thing never worked, and apparently is only marginally ok today. However, it still isn’t reliable to handle Time Machine backups.

HFS+’s woes and shortcomings have been well critiqued.

At first I had an issue where the first Time Machine backup would work, taking like 24 hours. This is expected. Incremental backups would work fine for maybe three or four times. Then, the backup file on the drive would get corrupted. Time Machine would complain, and I’d have to start all over, running that initial 24 hour+ backup again. This was insane. I didn’t think it was necessarily the drive, because I could still connect and write to it ok. I could also transfer huge files, big and small, via other methods like FTP and SCP. My hunch was the networking was crap.

I found that Time Machine also supported Samba, not just AFP. I got rid of netatalk and switched to Samba. The incremental backup corruptions disappeared. Great! I thought. I could go into Time Machine and see all my backups. I thought my old nemesis netatalk was to blame. Turns out, it was only partial.

After a power outage, I found the whole damn USB drive was corrupted. I could go into the Pi and mount the shares just fine, but they were always mounted as read only. No amount of fscking could fix it. I thought it was the cheap Amazon Basics USB hard drive enclosure, so I got a better rated one. No difference. I always had to format the drive and do the huge initial backup again. I went through three power failures like this. I was about to give up on the whole idea, but on a whim, I tried formatting the drive as ext4. Macs can’t read/write ext4, but Samba handled that detail for the Macs. There was no reason that couldn’t work.

I’ve now suffered through three additional power outages, and I’m able to recover flawlessly. I have to manually re-mount the shares on the Pi, but they mount as RW. This is just an automation task that I haven’t implemented yet. The clients then can reconnect, and the backup file is not corrupted. I’m able to backup from High Sierra and Catalina. Time Machine just picks up where it left off on all machines.

My hardware setup is a Raspberry Pi 4, Seagate 6TB NAS HD in a Inatek enclosure connected via USB 3. The Pi 4 is connected via Cat 6 cable. Due to the USB and ethernet architecture limitations of other Pi’s, don’t do this on anything but a Pi 4.

I was going to document the steps, but found Paul Mucur already did it. The only thing I deviated from was not installing Avahi initially. This then requires me to manually reconnect from the Macs, after re-mounting should a power outage occur. I will try in install Avahi again in the future. The rest of the instructions on that site on Samba and ext4 are solid and look like they should work.

2 replies on “Raspberry Pi-Powered Time Machine Backups – No Really, Do It This Way. The Other Ways Are Wrong.”

This one. It comes with a fan, which you’ll probably want to install especially if you run something else on it. Backups aren’t computationally intensive, but the Pi4’s throttle when they get hot.

Leave a Reply