There are many writeups on how to backup a Mac using Time Machine to a Linux server. These are my notes.
First, create a user on the Linux system to which the Mac will login:
$ sudo useradd -m macbook
$ sudo passwd macbook
Next, install the necessary servers and libraries. Most sites I looked at showed
downloading and source code for netatalk
specifically to compile in encryption support (which may
have be required by OSX). On Ubuntu 16.04 right now, the current version of netatalk
is
compatible with OSX; no download and compilation required.
$ sudo apt install netatalk libc6-dev avahi-daemon libnss-mdns
Update the nsswitch.conf
:
$ sudo vim /etc/nsswitch.conf
Make the hosts
line to read as such:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
Dump the following into afpd.service
:
$ sudo vim /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=Xserve</txt-record>
</service>
</service-group>
Note that the firewall will need to accept connections on TCP port 458.
The main configuration for the file server appears to be in AppleVolumes.default
. Configuration
seems to have a generous number of knobs. For now, I’ll create two shares, one for Time Machine
backups and another for miscellaneous file sharing.
$ sudo vim /etc/netatalk/AppleVolumes.default
/home/$u "Home Directory"
/archive/TimeMachine/$u "Time Machine" options:tm
The $u
is a parameter that resolves to the user that has logged into the file sharing service.
Since I created the macbook
user above, the macbook
user will get two file shares customized to
that user.
Restart the services:
$ sudo service avahi-daemon restart
$ sudo service netatalk restart
Changes to AppleVolumes.default
require a restart (or possibly just a reload?) of netatalk
, but
not avahi-daemon
.
References
https://fzhu.work/blog/mac/making-ubuntu-server-a-mac-time-capsule.html
https://kremalicious.com/ubuntu-as-mac-file-server-and-time-machine-volume/