Yi Tang Data Science and Emacs

Wireless Backup Solution Using Raspberry Pi for MacOS

If you need automated backups for Time Machine and have a Raspberry Pi, You will find this post useful.

Motivation

After 3 months using my brand new MacBook Pro 14 M1 Pro, one of the USB-C port stopped working. I will have to send it back, not sure what Apple will do with it but I can't bear the risk of losing data. So I need a backup.

In fact, I need to backup regularly for situation like this so that's why I worked on it.

Wireless Backup Solution

The easiest solution is to get a USB-C portable SSD, plug it into my laptop and open Time Machine to start back up, do it once a week and call it a day.

But I'm reluctant to add more devices to my already cluttered home lab. There are a few hard drives in the drawers, it would be good to utilise them.

So I decided to set up a Time Machine backup solution using on my Raspberry Pi 4. The benefits are

  1. no additional costs, save me about £50-£100
  2. no need to buy new stuff, so fewer things to care of
  3. wireless backup to keep my desk clean

Later I realised the benefits of having a wireless backup is overlooked. It can backup anytime and anywhere in my house. Also, because of convenience, I can have more granular backups - instead of weekly backup, I have hourly backup without getting the cables and hard drives. I do less but get more value out of it.

The only concern I had was the speed. It turns out with SAMBA 3 protocol, I can get 55 MB/s write speed and 40 MB/s read speed from laptop to Raspberry Pi. So in theory, it would take around 2.5 hours to backup my 500 GB laptop. It might be a lot but only for the first backup, the subsequent incremental backup would be much simpler and faster, for example, as of now, the Time Machine completed a new backup within 3 minutes in the background without my notice.

A portal USB-C SSD can finish the backup within minutes but it's an overkill for an ordinary user like me and it's inconvenient.

So I'm satisfied with the current solution.

Set Up Raspberry Pi

I read a few guides on setting up Raspberry Pi for Time Machine, and I found this guide most accurate and useful.

One thing I noticed is the AFP (Apple File Protocol) is deprecated, so make sure you use SAMBA as the protocol.

Additionally, I followed this stack overflow answer to auto-mount the SAMBA server so that every time I reboot my laptop, the Time Machine will be ready to back up.

Time Machine Backup frequency

By default, Time Machine does hourly backup.

If you feel hourly backup is not necessary, you can change it by updating this file

/System/Library/LaunchDaemons/com.apple.backupd-helper.plist

for example, to change the frequency from hourly to daily backup, change the interval value from 3600 to 43200.

In the end, I left it with the default hourly backup so it does many small backup hourly instead of one big backup daily.

Backup for Backups

After couple of hours of work, I managed to get a wireless backup solution for my laptop so I won't have to worry about data loss. Plus I can time-travel files at hourly intervals.

One concern that occurred to me was the backup sits on my local hard drive. If the hard drive died, I would lose all my backups.

To solve that problem, I will have to go through the rabbit hole of doing backup for backups, or backup to a remote location or cloud, or setup a Raspberry Pi RAID.

At the moment, I'm not very concerned - I have Apple iCloud to back up my photos, videos, notes etc and I use GitHub to host my org-files and code. So having a backup for backups is not necessary for me for now.

If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!
comments powered by Disqus