Building Your AFP TimeMachine

While it is possible to use a Windows or NFS share for your Apple TimeMachine backups, using the native Apple file sharing protocol (AFP) together with a service like Bonjour to broadcast the file services available you will find yourself with a much better file sharing experience. This tutorial walks you through how to configure your Ubuntu server to serve as an AFP host on your network and then discusses what you will need for TimeMachine to work properly.

Since my previous tutorial on how to setup NFS with TimeMachine, you might wonder what prompted me to do this. The TimeMachine backups write to a virtual filesystem that is encapsulated in something called a sparsebundle. Unfortunately, if you have a problem with your sparsebundle, it simply isn’t possible to correct that issue over NFS. As a result, when my system started experiencing errors I found myself in a situation where it was going to be necessary to copy 1TB of backup data to another drive that would be local to my Mac.

Copyright Beer Coaster

This scenario simply isn’t practical, and since it would be necessary to get another hard drive and devote quite some time to copy the data from one host to another, I decided to explore AFP and configure Apple’s file sharing so that this problem could be resolved over the network directly.

These instructions assume your Linux server is running a recent version of Ubuntu.

  1. Install Software. You’re going to need a few packages for this.
    apt-get install netatalk avahi-daemon libnss-mdns cracklib2-dev fakeroot libssl-dev
  2. Configure Netatalk Service. This is what is going to host the file sharing services for you. Edit the /etc/default/netatalk settings to support the following configuration:
  3. Setup Shares. Create the shares you want to access from your Mac. Edit your /etc/netatalk/AppleVolumes.default file and modify your share points from here. For this example, this was added to my AppleVolumes.default file to let me share the TimeMachine backup directory:
    /export/timemachine TimeMachine allow:eric cnidscheme:cdb options:usedots options:tm veto:lost+found
    Note that the veto option is handy as it will hide directories from your hosts that may be inaccessible.
  4. Setup Name Broadcast. Modify your Avahi configuration to broadcast your host name information. This will make it easier to locate your Linux server from your Mac.
    To do this, create a file called /etc/avahi/services/afpd.service and place the following in it:

    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <name replace-wildcards="yes">%h</name>
  5. Restart Sevices. With everything configured, restart your services.
    service netatalk restart
    service avahi-daemon restart

That should do it. From your Mac, your Linux server should now be visible in the Finder. Use the Connect As… option to logon to your server using your credentials, and the available file shares should then appear.

If you plan on using this share for a TimeMachine backup, modify your TimeMachine settings and it to the new share. It’s also possible to run Disk Utility to repair your sparsebundle file on the server. In my case it took around 2 hours to complete, but it was successful and everything ran remotely.