Mac 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!
First log in to SSH as root (or login and sudo to root) and install the required packages to build netatalk:
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
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.
tar vxzf netatalk-3.1.10.tar.gz
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:
./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
./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):
If netatalk compiled and installed correctly, running the command below should result in the output below the command:
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
state directory: /usr/local/var/netatalk/
UAM search path: /usr/local/lib/netatalk//
Server messages path: /usr/local/var/netatalk/msg/
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 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
basedir regex = /media/data/TimeMachine/
path = /media/data/TimeMachine/user1
valid users = user1
time machine = yes
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.
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!
Added instructions for Ubuntu 14.10 as they are using a myuch different version of used libraries.