Linux server as Apple Time Capsule

TimeMachine Backup

Since I am using my MacBook Air I had the thoughts to automate my backups. Using the in macOS integrated backup solution Time Machine it should not be a problem but here we can already recognise the limitations of the "walled garden".

It is not possible to access any of my shares to save the backup to my NAS. The price of a Apple Time Capsule is scaring me to buy one, which is nothing else than a slim downed NAS. A little bit of tinkering and googling helped me to find a solution to convert my Linux server to a Apple Time Capsule.

The steps described below are tested on Ubuntu but might also work on Debian or any other on it based distributions.

Step 1

Netatalk, the open source deployment of Apple Filling Protocol (AFP) has to be installed

sudo apt-get install netatalk libc6-dev avahi-daemon libnss-mdns 

Step 2

Edit the hosts line in /etc/nsswitch.conf with the editor of your choice. I am using nano.

sudo nano /etc/nsswitch.conf 

The line should be adjusted as followed:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns 

Step 3

Create the file /etc/avahi/services/afpd.service

sudo nano /etc/avahi/services/afpd.service

and fill it with this content:

< ?xml version="1.0" standalone='no'?>< !--*-nxml-*-->
< !DOCTYPE service-group SYSTEM "avahi-service.dtd">
< service-group>
    < name replace-wildcards="yes">%h
    < service>
        < type>_afpovertcp._tcp
        < port>548
    < /service>
    < service>
        < type>_device-info._tcp
        < port>0
        < txt-record>model=TimeCapsule
    < /service>
< /service-group>

Step 4

Now just the shares for the backups are missing. Edit /etc/netatalk/AppleVolumes.default and add the parameter tm.

sudo nano /etc/netatalk/AppleVolumes.default

I have created for each mac an own share.

# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,usedots,tm
# By default all users have access to their home directories.
/media/Data/Backup/dennis "TimeMachine Dennis"
/media/Data/Backup/natha "TimeMachine Natha"
# End of File

Step 5

At least Netatalk has to be adjusted.

sudo nano /etc/default/netatalk

Edit it as followed:

#### Set which legacy daemons to run.
#### If you need AppleTalk, run atalkd.
#### papd, timelord and a2boot are dependent upon atalkd.
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no

Restart the services for Netatalk and Avahi.

before Ubuntu 16.04:

sudo service netatalk restart
sudo service avahi-daemon restart

since Ubuntu 16.04:

systemctl restart netatalk.service
systemctl restart avahi-daemon.service

Now you should be able to access the shares. Time Machine Shares

Dennis Lauton

Read more posts by this author.