— macOS, linux, pi — 2 min read
Update Nov 2021: Applied changes suggested by Alexis, Johnny, and Joel. Full changes are logged in the git history for this post. Thank you all.
I've now had a few months of reliable, consistent automated Time Machine backups accomplished via my Mac and Rapberry Pi 4B now, attached to a spare 1TB 2.5" USB 3.0 drive. Using the Pi 4B alongside some spare drives can give you a very versatile, cost-effective NAS and server.
sudo apt-get update && sudo apt-get upgrade -y
sudo apt install samba avahi-daemon hfsutils hfsprogs
ls -lha /dev/disk/by-uuid. Make note of the drive reference and UUID
/dev/sda1and UUID is
sudo mkfs.hfs /dev/sda1 -v TimeMachineor use Gparted to repartition the drive and label it
sudo nano /etc/fstab
UUID=8c9d728a-54f3-4948-81ea-f0482c89fc73 /media/pi/TimeMachine hfsplus force,nofail,rw 0 0(if your username is not
pi, edit this path to use your nane instead and do the same in subsequent areas)
df -hand make sure your drive is present.
sudo fdisk -lalso for a little more verbosity. Make sure everything looks good based on the specs of the drive.
sudo apt-get install netatalk -y
sudo nano /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dnsbecomes
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
sudo nano /etc/samba/smb.confand append
1[backups]2 comment = Backups3 path = /media/pi/TimeMachine4 valid users = pi5 read only = no6 vfs objects = catia fruit streams_xattr7 fruit:time machine = yes
sudo nano /etc/netatalk/afp.conf
1[Global]2 mimic model = TimeCapsule6,10634[Time Machine]5 path = /media/pi/TimeMachine6 time machine = yes
sudo service avahi-daemon startand
sudo service netatalk start
afp://192.168.1.50/(use the local static IP for your pi instead though)
And that should do it!
sudo chown -R pi:pi /media/pi/)
sudo rmdir /media/pi/TimeMachine) and reboot (this fixed an issue for me that chmod did not)
sudo fsck.hfsplus -f /dev/sda1(or simply re-format)
1sudo tmutil setdestination -ap "afp://email@example.com/Time Machine" # (use the local static IP for your pi instead though)
Gregology's Raspberry Pi Time Machine -- this guide is most similar to this one, but uses ext4 instead of hfsplus
Mudge's Using a Raspberry Pi for Time Machine -- uses ext4 and smb as a protocol, and other steps look good but I couldn't get the macOS Time Machine service to find it