How to use your Raspberry Pi as a Time Machine backup server for macOS


Introduction


Thanks for watching my video, in the following document you will find all the commands you need to get your Raspberry Time Machine running.

Requirements

  1. Raspberry Pi, connected to your local network (ethernet recommended)
  2. Raspbian Jessie/Stretch/other current linux distro
  3. Any type of USB storage
  4. A computer running macOS (Tested on High Sierra and Mojave as of 10/15/2018. Hackintosh should work aswell.)

Preparing your drive#back to top

Installing gparted

                            sudo apt-get install gparted
                            


Enter your Pi via VNC or control it locally and enter "Run..." and enter:

                            sudo gparted
                            


Create a EXT4 partition. Continue with creating a mounting folder.

                            sudo mkdir /mnt/TimeMachine
                            sudo chmod 777 /mnt/TimeMachine
                            


Find out your partition's UUID with this commend:

                            sudo blkid
                            


Edit /etc/fstab with this command:

                            sudo nano /etc/fstab
                            


And create a new line with your UUID and the following parameters:

                            UUID=YourUUIDHere /mnt/TimeMachine ext4 nofail,defaults 0 2
                            

Installing Netatalk#back to top

Installing dependencies

                            sudo apt-get install build-essential libevent-dev libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libtdb-dev avahi-daemon libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libio-socket-inet6-perl tracker libtracker-sparql-1.0-dev libmariadbclient-dev libtracker-miner-1.0-dev
                            


Download Netatalk sources and extract

                            wget http://prdownloads.sourceforge.net/netatalk/netatalk-3.1.11.tar.gz
                            sudo tar -xf netatalk-3.1.11.tar.gz
                            


Prepare configuration by pasting this (all the lines) into your terminal:

                            ./configure \
                                --with-init-style=debian-systemd \
                                --without-libevent \
                                --without-tdb \
                                --with-cracklib \
                                --enable-krbV-uam \
                                --with-pam-confdir=/etc/pam.d \
                                --with-dbus-daemon=/usr/bin/dbus-daemon \
                                --with-dbus-sysconf-dir=/etc/dbus-1/system.d \
                                --with-tracker-pkgconfig-version=1.0
                            


Compile and install:

                            make
                            sudo make install
                            

Configuration#back to top

Edit nsswitch:

                            sudo nano /etc/nsswitch.conf
                            

In this file, you want to go to the end of the hosts line and append:

                            mdns4 mdns
                            

Enabling autostart:

                            sudo systemctl enable avahi-daemon
                            sudo systemctl enable netatalk
                            sudo service avahi-daemon start
                            sudo service netatalk start
                            


Edit afp.conf

                            sudo nano /usr/local/etc/afp.conf
                            


Under [Global], you want to add:

                            mimic model = TimeCapsule6,106
                            


And at the end of the file, uncomment all the lines concerning Time Machine so it looks like this:

                            [YourCustomName]
                                path = /mnt/TimeMachine
                                time machine = yes
                                valid users = pi
                            


Mount the drive and edit permissions:

                            cd /mnt
                            sudo mount -a
                            sudo chown -R pi:pi TimeMachine
                            


Restart the services for finishing configuration:

                            sudo service avahi-daemon restart
                            sudo service netatalk restart
                            

Set up Time Machine#back to top

In your Mac, go to System Preferences, Time Machine, Select Backup Disk and select the newly created drive.

Log in with your pi user and its password.

That's it!