Setting up a TimeMachine backup server on Ubuntu 12.04 Server

Recently I purchased a new home server of which I am using to backup both my iMac and MacBook Pro, I thought I’d quickly document how I achieved this for future reference and also to help others too! – Both my Apple Mac computers are running Apple MacOSX 10.7 (Lion)..

Firstly we need to install a few packages, on your Ubuntu 12.04 server, firstly check that you’ve updated your sources by runnings:-

sudo apt-get update

Now we’ll installed the required packages…

sudo apt-get install netatalk avahi-daemon

Now we need to create a backup directory, I personally created a seperate partition for this but if you have a standard install of Ubuntu and therefore under a single partition you’ll need to create a directory to store your time machine backups, you can do this like so:-

mkdir /timemachine

Now we have to change the owner of the folder to a system user, I’ve created an account on the server like so and named the account ‘timemachine’ – this is the account you will need to type in on your Mac when choosing the Time Machine backup target.

useradd timemachine -M
 passwd timemachine (The enter a password, this is what you will need to use when connecting to the time machine drive.)
chown -R timemachine:timemachine /timemachine/

Next we need to modify the following file like so:-

sudo nano /etc/netatalk/afpd.conf

You need to add the following line to the bottom of the file:-

- -tcp -noddp -uamlist uams_randnum.so,uams_dhx.so,uams_dhx2.so -nosavepassword

Now save and close the file (CTRL+O, CTRL-X)

Next we need to modify the file located /etc/netatalk/AppleVolumes.default, again we need to add another line at the bottom of the file as follows (replace <username> with the username you choose, In my case it would be ‘timemachine‘):-

/timemachine TimeMachine allow:<username> cnidscheme:dbd options:usedots,upriv,tm

We’re almost done, just one more file we need to create:-

nano /etc/avahi/services/afpd.service

Now populate the file with the following:-

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

That its! – Just restart a couple of daemons and your new TimeMachine backup server is ready for use 🙂

 restart netatalk
 restart avahi-daemon

Done! – Congratulations… You now have a remote timemachine backup server or which you can use to backup multiple MacOSX machines too… I am currently using mine to backup my iMac and my MacBook Pro!