Home NAS (Advanced), x86 • Your NAS as a TimeMachine backupserver

Your NAS as a TimeMachine backupserver

 - 

TimeMachineMac users may be familiar with the TimeMachine functionality OSX provides, in order to use this you’ll have to buy a quite expensive TimeCapsule station which functions as a backupserver and router.

There is a possibility to create your own TimeCapsule using the software “Netatalk” which emulates the AFP (Apple Filing Protocol) and is able to function as TimeCapsule service.

Here I will guide you through the process of installing and configuring this TimeCapsule server using Debian or Ubuntu and have tested this myself using Debian 7 and Ubuntu 14.04. It may work for older distributions but cannot guarantee it. Also we will be building Netatalk ourselves, because the used version nowadays in Debian and Ubuntu is 2.2.1 and available as source is version 3.1.7 which incorporates major enhancements, better speeds and more reliable backups!

Preparation:
First log in to SSH as root (or login and sudo to root) and install the required packages to build netatalk:

Debian 7:
apt-get install build-essential libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libmysqlclient-dev libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev tracker libtracker-sparql-0.14-dev libtracker-miner-0.14-dev

Ubuntu 14.04:
apt-get install build-essential libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libmysqlclient-dev libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev tracker libtracker-sparql-0.16-dev libtracker-miner-0.16-dev

Ubuntu 14.10 and higher:
apt-get install build-essential libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libmysqlclient-dev libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev tracker libtracker-sparql-1.0-dev libtracker-miner-1.0-dev

Download the software:
Version 3.1.10 is the newest version at this time.

wget http://sourceforge.net/projects/netatalk/files/netatalk/3.1.10/netatalk-3.1.10.tar.gz
tar vxzf netatalk-3.1.10.tar.gz
cd netatalk-3.1.10

Building the software:
The configure process is a bit different between Ubuntu and Debian, the appropriate configure line four your distro can be found below:

Debian 7:
./configure --with-init-style=debian-sysv --with-cracklib --enable-krbV-uam --with-pam-confdir=/etc/pam.d --with-dbus-sysconf-dir=/etc/dbus-1/system.d --with-tracker-pkgconfig-version=0.14

Ubuntu 14.04:
./configure --with-init-style=debian-sysv --with-cracklib --enable-krbV-uam --with-pam-confdir=/etc/pam.d --with-dbus-sysconf-dir=/etc/dbus-1/system.d --with-tracker-pkgconfig-version=0.16

Ubuntu 14.10 and higher:
./configure --with-init-style=debian-sysv --with-cracklib --enable-krbV-uam --with-pam-confdir=/etc/pam.d --with-dbus-sysconf-dir=/etc/dbus-1/system.d --with-tracker-pkgconfig-version=1.0

The compile and install process is the same on both platforms (building it on your NAS may take a while):
make
make install

Checking installation:
If netatalk compiled and installed correctly, running the command below should result in the output below the command:

afpd -V

Will result in the output below:

afpd 3.1.10 - Apple Filing Protocol (AFP) daemon of Netatalk

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version. Please see the file COPYING for further information and details.

afpd has been compiled with support for these features:

AFP versions: 2.2 3.0 3.1 3.2 3.3 3.4
CNID backends: dbd last tdb mysql
Zeroconf support: Avahi
TCP wrappers support: Yes
Quota support: Yes
Admin group support: Yes
Valid shell checks: Yes
cracklib support: Yes
EA support: ad | sys
ACL support: Yes
LDAP support: Yes
D-Bus support: Yes
Spotlight support: Yes
DTrace probes: Yes

afp.conf: /usr/local/etc/afp.conf
extmap.conf: /usr/local/etc/extmap.conf
state directory: /usr/local/var/netatalk/
afp_signature.conf: /usr/local/var/netatalk/afp_signature.conf
afp_voluuid.conf: /usr/local/var/netatalk/afp_voluuid.conf
UAM search path: /usr/local/lib/netatalk//
Server messages path: /usr/local/var/netatalk/msg/

Configuration:
Now that netatalk is installed, we need to configure it. All configuration needed goes in “/usr/local/etc/afp.conf”. Open it up using your preferred editor.

My sample configfile is found below:

;
; Netatalk 3.x configuration file
;

[Global]
; Global server settings
hostname = NetworkSpace2
uam list = uams_dhx.so uams_dhx2.so uams_guest.so
zeroconf = yes
guest account = nobody
log level = default:warn
log file = /var/log/afpd.log

[Homes]
basedir regex = /media/data/TimeMachine/

[user1]
path = /media/data/TimeMachine/user1
valid users = user1
time machine = yes

[user2]
path = /media/data/TimeMachine/user2
valid users = user2
time machine = yes

Some explanation for the settings:
hostname = the name AFP will show when browsing network devices and will also show up in the OS X Finder in the devices section on the left.
basedir regex = the absolute path AFP operates in, any users created in the config will have their backups created in this folder (with a separate folder for that user itself).
[userX] = the name of the share that will be shown if browsing shares on the AFP service, and will be used to connect to the share.
path = the path where userX will have it’s content in and must be inside the basedir regex folder.
valid users = the users on the Linux box which are allowed to use the share.
time machine = no need to explain right?

The users that you supply within the valid users section are the users that reside on the Linux box, so any users that are (or are to be created) on the system can be placed there and can login using their regular password and will be asked when connecting to shares. In my local setup I have a share that is named “jeffrey” and the valid user is “jeffrey” as well, it’s best to use share names that can be easily recognized for the user or host it’s needed for.

Start netatalk:
Once the configuration file is changed to your needs, save the changes and restart netatalk to use the new config:

service netatalk restart

Setting up TimeMachine:
In this case I assume you are using an up-to-date version of OS X, configuring TimeMachine is a piece of cake!

1. Open System Preferences
2. Select Time Machine
3. Click “Select Disk”
4. At the “Available Disks” section, your server with the shares should show up, select the appropriate share and choose whether to encrypt your backups or not (for security I always use encryption) and select “Use disk”

If you have selected to encrypt the backups, a password for encryption will be asked twice, make sure to store that password somewhere safe as losing it will render your backups completely useless!

That’s it! TimeMachine will now start creating backups after 2 minutes to the share you have selected!

Update:
Added instructions for Ubuntu 14.10 as they are using a myuch different version of used libraries.

Author:langerak

9 responses to “Your NAS as a TimeMachine backupserver”

  • Alessio 10-02-2015 at 21:52 Reply 

    dunno why, but following this how-to, when I start the backup from my mac, it say “preparing bk….”.
    Few minutes later got a kernel panic on my debian 7 saying “kernel panic not syncing fatal exception in interrupt time machine”.
    I’ve made an ext4 partition mounted on /mnt/timecapsule and configured afpd.conf like:

    ale@hub:~$ cat /usr/local/etc/afp.conf
    ;
    ; Netatalk 3.x configuration file
    ;

    [Global]
    ; Global server settings
    hostname = hub
    uam list = uams_dhx.so uams_dhx2.so uams_guest.so
    zeroconf = yes
    guest account = nobody
    log level = default:warn
    log file = /var/log/afpd.log

    [Homes]
    basedir regex = /mnt/timecapsule/

    [jarvis]
    path = /mnt/timecapsule/jarvis
    valid users = ale
    time machine = yes
    ale@hub:~$


    • langerak 13-02-2015 at 22:09 Reply 

      Hi! Can you confirm that the compile and installation went allright? Please try to run “afpd -V” to see if it will tell you with what options it has been compiled with and what it’s version is etcetera. Are you able to connect to the AFP share using the Finder for example and placing files in it?


  • Mrengles 16-04-2015 at 04:11 Reply 

    Thanks your ununtu instructions worked great on my raspberry pi2. Are you willing to make a ppa for Ubuntu armhf and netatalk 3.1.7?


    • langerak 16-04-2015 at 09:18 Reply 

      Hi, great to see it worked for you! Unfortunately there will not be a PPA for Netatalk as I do not have the time to maintain it. For now the instructions should do just fine :).


  • Mrengles 17-04-2015 at 14:49 Reply 

    I managed to get an Ubuntu ppa setup for the Raspberry Pi 2. I’ve enabled armhf compiling and copied over Patrick Kaiser’s netatalk 3.1.7 packages… Works great and save allot of space not having to install dev-tools. If you want to try it check out the link below.

    https://launchpad.net/~mrengles/+archive/ubuntu/rpi2


  • Asphix 04-09-2015 at 09:13 Reply 

    Thank you for your tutorial. It was easy with it. Just I want to point that after the “make”, you wrote “make install” but as it installs in other folders of the system, I had to write “sudo make install” for proper installation.
    Thanks!!


  • Misna 07-01-2016 at 14:30 Reply 

    Hi!

    Great guide. Finally got this working on Ubuntu Server 14.04!


    • langerak 07-01-2016 at 14:53 Reply 

      Great to hear! Nice to see you got it up and running 🙂


Leave a Reply

Your email address will not be published. Required fields are marked*

*

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.