Garrett L. Ward

Using a Linux Server With Time Machine

Setting up Time Machine to back up over the network to a linux server is now fairly straightforward, since release 2.0.5 of netatalk, the FOSS implementation of Apple’s AFP network file protocol supports time machine volumes out of the box. For this to work, you’ll need a linux computer that’s connected to the same network as your Mac, the latest (2.0.5 at the time of this writing) version of netatalk, which is probably available in your distrobution’s repositories, and the latest avahi.

First, obviously, install netatalk and avahi. You’ll need to set both up so that you announce the share over avahi for your Mac to easily pick it up. Configuring afp is fairly straightforward. Open /etc/netatalk/AppleVolumes.default, and scroll to the bottom. Comment out the ~ line and add the following:

1
2
#~
/path/to/folder share_name options:tm

where /path/to/folder is the path to the folder you want to store the TM backup in and share_name is how the Mac will identify the mount. It can be at most 27 characters and must be enclosed in double quotes if you want spaces in the name, apparently. The options:tm bit tells afpd that you’re going to be using the mount for time machine backups.

Now you need to set up avahi as well. In most modern distros this is straightforward, just install it and start the avahi-daemon daemon. You’ll need add a service description for the AFP share; This is an XML file containing information about the AFP share that avahi will publish to any computers on the network. The service files are usually located in /etc/avahi/services. Here’s the one I use. Change name and host-name as necessary; if you’re not using zeroconf on your network use the ip address of your linux box instead.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<!-- $Id: time_machine.html,v 1.5 2009/10/06 03:47:50 shuey Exp $ -->

<!--
  This file is part of avahi.
 
  avahi is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2 of the
  License, or (at your option) any later version.

  avahi is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with avahi; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA.
-->

<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>

  <name replace-wildcards="yes">AFP on helios</name>

  <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
    <host-name>helios.local</host-name>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=Xserve</txt-record>
  </service>

</service-group>

The model=Xserve gives the share an Xserve raid icon in Finder; presumably you could also use model=MacPro or the like if you want something different.

Now then, restart avahi-daemon and afpd, and see if you can at least access the share in finder. You’ll need to log in with your unix username and password, so before we proceed make sure the folder you’re using for backups is writable by the user you’ll log in as. If you don’t see it in finder, try going to connect to server and use afp://ip.of.server to see if it will connect that way; sometimes OSX is a little slow to see new servers on the network.

Once you’ve gotten the AFP server set up you’re almost there. To actually allow Time Machine to use the network share you need to do one final thing. By default Time Machine will ignore network volumes that aren’t time capsules, so open a terminal window on your man and run the following command:

1
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Now make sure the AFP volume is mounted, and go to set up Time Machine as normal. You should be able to select the network share and start backing up. Now go grab some food or a nap, this will take awhile. Even over a gigabit ethernet connection it took about 4 hours for a 180GB backup.