Friday, January 13, 2017

How To Set Up AFP File Sharing On Linux for Use With Time Machine

How To Set Up AFP File Sharing On Linux for Use With Time Machine



Preface:

In past versions of Mac OS X, the built in backup tool, Time Machine was a lot less picky about where you back up your files to. You could even back up to a Samba file share if you enabled the "unsupported volumes" hack.

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

But that ended with Snow Leopard. Starting with the release of OSX 10.7 Lion, Apple started cinching down on where you could back up your system to, ostensibly for security reasons. Now, with Mac OS X 10.8 "Mountain Lion", its gotten to the point where essentially the only places you can back up your system using Time Machine are either on another Mac OS X File Server or on an Apple Time Capsule. My assumption is that their intent is merely to bolster their hardware sales.

I dont know too many people who stay exclusively within the "walled garden" for all their computing needs. Certainly people with a lot more money to burn than me. But for a much more economical approach than shelling out around $300 for an over-glorified USB drive, you could just follow this guide to set up your Ubuntu file server to look and behave exactly like Time Machine would expect a real Time Capsule or Mac to.

Step 1: Install Netatalk

installing Netatalk, the open source Apple Filing Protocol (AFP) implementation is easy! The packages are already in the repos, which makes me wonder why its not enabled by default.

Install the following packages:

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

Step 2: Configure /etc/nsswitch.conf

Once those packages are installed, there are actually five configuration files that need to be edited in order for the Macs on your network to access your AFP shares properly.

sudo nano /etc/nsswitch.conf

locate the line that reads

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

and add mdns to it so it now reads

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

press ctrl+o to save and ctrl+x to exit.

Step 3: /etc/avahi/services/afpd.service

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

paste the following code

<?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=TimeCapsule</txt-record>
    </service>
</service-group>

NOTE: Just for fun you can change the string "<txt-record>model=TimeCapsule</txt-record>" to the following devices to change how they appear in Finder on OSX:



Image

Apple Product

Identifier Strings



Airport Express

AirPort4

AirPort4,102

AirPort4,107



Airport Extreme

AirPort

Airpor5

AirPort5,104

AirPort5,105

AirPort5,108

AirPort5,114

AirPort5,117



Aluminum 20” iMac

iMac7,1

iMac8,1



Aluminum 24” iMac

iMac9,1



Aluminum Unibody MacBook

MacBook5,1



Apple Cinema Display

Any invalid or blank string




AppleTV

AppleTV

AppleTV1,1



Black MacBook

MacBook1,1,Black

MacBook2,1,Black

MacBook3,1,Black

MacBook4,1,Black



eMac

PowerMac4,4

PowerMac6,4




Flower Pot G4 iMac 15”

PowerMac4,2



Flower Pot G4 iMac 17”

PowerMac4,5

PowerMac6,1



Flower Pot G4 iMac 20”

PowerMac6,3



Graphite G4 PowerMac

PowerMac

Available link for download