My wife recently got a MacBook Air, and as with most things on my wife's computers, I try to set up silent, smoothly-running processes to back up, update, and do general maintenance. I'm a little new to Macs (I just got one myself for work) but I knew how seamless Time Machine backups were due to helping my mom set them up in the past.

I also have a recently reconfigured home NAS / htpc with a big zfs pool (I keep meaning to do a post about it, I'll link it here when I do) that runs Ubuntu, so I wanted to be able to utilize that if possible to host the Time Machine backups. I came across this post and blantatly ripped it off into this post, with the changes needed for Ubuntu 16.04.

Pretty much, the best way to have an Ubuntu system host a Mac-accessible drive is to use Netatalk. Netatalk implements the Apple Filing Protocol (AFP) for *nix systems, and can be used to host a Mac-accessible drive.

Installation

First, you need to grab Netatalk. The version of Netatalk in the repositories for Ubuntu is SUPER old and out of date, so I wanted to grab the latest source release and build it. I grabbed the latest version from the Netatalk Sourceforge Page and put it my downloads directory.

Then, you need to grab some dependencies that Netatalk needs to compile. These are the dependencies that worked with Ubuntu 16.04 LTS. Basically, these are the same as the instructions linked above, with two changes:

  • libtracker moved from 0.16 to 1.0
  • libevent-dev is now needed
$ sudo apt-get install autoconf \
  libtool \
  automake \
  build-essential \
  libssl-dev \
  libgcrypt11-dev \
  libkrb5-dev \
  libpam0g-dev \
  libwrap0-dev \
  libdb-dev \
  libmysqlclient-dev \
  libavahi-client-dev \
  libacl1-dev \
  libldap2-dev \
  libcrack2-dev \
  systemtap-sdt-dev \
  libdbus-1-dev \
  libdbus-glib-1-dev \
  libglib2.0-dev \
  tracker \
  libtracker-miner-1.0-dev \
  libtracker-sparql-1.0-dev \
  libevent-dev 

Then configure the package. Make sure to replace pkgconfig-version with the latest version of tracker, which you installed above. At the time of this writing,the version is 1.0.

$ ./configure \
  --with-init-style=debian-sysv \
  --without-libevent \
  --with-cracklib \
  --enable-krbV-uam \
  --with-pam-confdir=/etc/pam.d \
  --with-dbus-sysconf-dir=/etc/dbus-1/system.d \
  --with-tracker-pkgconfig-version=1.0
$ make
$ sudo make install

Make sure that it works:

$ afpd -V

If everything works, you should get some output that looks like this:

afpd 3.1.8 - Apple Filing Protocol (AFP) daemon of Netatalk

This program is free software; you can redistribute it and/or modify it under  
the terms of the GNU General Public License as published by the Free Software  
Foundation; either version 2 of the License, or (at your option) any later  
version. Please see the file COPYING for further information and details.

afpd has been compiled with support for these features:  

Then you need to configure the system. The system configuration is located here on my install, and you can edit it with your normal text editor:

$ sudo vim /usr/local/etc/afp.conf

Because there are two macs on my home network (mine and my wife's), I wanted to have two users able to have access to my AFP shares, as well as access to the Time Machine system that I'm going to set up. Here are some givens that went into my configuration:

  • Let's pretend like my computer will connect with user1 and my wife will connect with user2.
  • user1 and user2 are both set up and configured on my NAS machine, and have /home/user1 and /home/user2 as their home directories, respectively
  • I want my time machine backup data to be held in /mnt/timemachine, which is a zfs pool.
  • I wanted a total time machine backup size of 1GB

I configured Netatalk in this way:

[user1]
path = /home/user1  
rolist = user1

[user2]
path = /home/user2  
rolist = user2

[TimeMachine]
path = /mnt/timemachine  
time machine = yes  
; Set volume size to 100000 (1TB)
vol size limit = 1000000  
valid users = user1 user2  

Then, you need to install the needed daemons to "announce" this Time Machine share to the world:

$ sudo apt-get install avahi-daemon

Then, you need to start and enable all the daemons needed:

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

After you do all this, the Time Machine server should be available and be able to be configured on your mac! Make sure you log into the backup server with your local user like user1 and the matching password.

Let me know in the comments if you have any issues / changes!