Concisest guide to setting up Time Machine server on Ubuntu Server 12.04

How to quickly set up Time Machine server on Ubuntu Server 12.04 without using extra repositories, unnecessary packages and redundant configuration. Backing up tested on OS X 10.6 Snow Leopard and OS X 10.8 Mountain Lion.

If you need to install a new drive, follow the guide on Ubuntu Help.

1. That’s all you need to install:

sudo apt-get install netatalk avahi-daemon

2. Create a new user for Time Machine, for example, danny:

sudo adduser danny

3. Backup the configuration file:

sudo mv /etc/netatalk/AppleVolumes.default /etc/netatalk/AppleVolumes.default.old

4. Create a new configuration file and open it for editing:

sudo nano /etc/netatalk/AppleVolumes.default

Paste the following line which sets default settings for all shares:

:DEFAULT: options:upriv,usedots

Then add this line to share a folder with danny:

/path/to/shared/folder "Danny's Time Machine" options:tm volsizelimit:300000 allow:danny

Obviously “volsizelimit:300000″ limits the share to 300000 MiB (~314GB). (Finder will show “314GB available” when connected). Remove it if you want.

5. Restart netatalk:

sudo service netatalk restart

6. Connect to your server using Finder (username “danny”). Open System Preferences > Time Machine, click “Select Disk…” and select your server under “Available Disks”:

time-machine-available-disksOnce again you’ll be asked for the login and password, after that you can disconnect from the share in Finder if you want, because Time Machine will open a new connection.

* * *

Bonus! Make your server appear as Xserve in Finder:

xserve-device-info

1. Open /etc/avahi/services/afpd.service for editing:

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

2. Paste this:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
    <name replace-wildcards="yes">%h</name>

    <service>
        <type>_device-info._tcp</type>
        <port>0</port>
        <txt-record>model=Xserve</txt-record>
    </service>
</service-group>

3. Restart avahi-daemon:

sudo service avahi-daemon restart

* * *

If avahi-daemon does not start after rebooting the server (so the server doesn’t re-appear in Finder’s sidebar), change AVAHI_DAEMON_DETECT_LOCAL from 1 to 0 in /etc/default/avahi-daemon (more information in my post on ServerFault). Note that if it never appeared in the first place, probably it has a different problem.

This entry was posted in How to’s and tagged , , . Bookmark the permalink.

25 Responses to Concisest guide to setting up Time Machine server on Ubuntu Server 12.04

  1. Jan-Cees Tjepkema says:

    Thanks alot man! It works great!

  2. Casey Friday says:

    I did this, and I’m getting an OSStatus Error 2 message, stating “Time Machine can’t access the backup disk”.

    Any ideas?

    • Dae says:

      Is your Time Machine share writable? (Can you upload a regular file via Finder into it?)

    • carlos perez says:

      Hi. I’m getting the same error.

      Did you figured how to solve it?
      The permissions are ok. I tried to copy a file into the shared folder using the same credentials and works ok..

      Thanks.

  3. Marco says:

    hey dear,

    i did the same, but when i type user and password required by timemachine configuration i get this error message:

    There was a problem connecting to the server “lab.local”.

    Check the server name or IP address, and then try again. If you continue to have problems, contact your system administrator.

    let me know.

    thanks

  4. Marco says:

    no, i can’t.. connection failed

  5. Marco says:

    Any suggestion?

  6. Andrew Zimmerman says:

    Thanks works fine,
    For those trying to figure it out I just simply did
    mkdir /home/timemachine/backup
    chmod 777 /home/timemachine/backup
    gave permissions for my username.

  7. John Walker says:

    Thank you for this post. I know there are a few comments from those that had problems, but I found it worked a treat using a big fat disk attached to an O2 Joggler running Ubuntu 12.10, with Time Machine running on Macs using OS X 10.7 Lion and 10.9 Mavericks.

    For both my back-ups I made sure that the only thing being backed up on the first round was a small folder. So you use Time Machine’s options dialog to exclude almost everything, then bring them in on subsequent back-ups. This just gets that first back-up done, so what follows is incremental.

    It did seem to take a long while at first to “locate” the backup disk, even though the share was listed instantly in the list of available disks for backup, it took ages to locate when actually backing up. To any who loose their nerve at this point, I suggest waiting before tweaking your settings and seeing if it completes. Thereafter it is quick.

    I haven’t tried restoring in earnest yet. But while I was migrating data from another backup on USB to a client’s mac, my Ubuntu Time Capsule was presented as a possible source of migration data in Migration Assistant.

  8. Sporkman says:

    Thanks for the nice description.

    I run an iptables-based firewall on my fileserver – what ports need opened for this setup?

    • Mir says:

      I see that three different protocols are used; samba, netatalk, avahi. I am guessing here but I would look for the ports these protocols use.

  9. Mir says:

    I got this to work and it great but I had two questions.

    First the initial backup is so long, I was considering to plug in my drive for the initial backup; can I then use that same backup on the server?

    Second can I do all this for another Mac device?

    • Dae says:

      can I then use that same backup on the server?

      I’ve heard that people do this, but I don’t know if there are any pitfalls.

      Second can I do all this for another Mac device?

      If you want to backup another computer, you can either:

      (1) Repeat step 6 on another Mac and use the same Linux user/password. This way, two Macs will be backed up to the same Time Machine share.

      This is easier, but not very secure: if you’re using Mac #1 and your friend is using Mac #2, you and your friend will be able to access files of each other through the backups.

      (2) If you want your Macs backed-up into separate shares, repeat step 2 and step 4. In Step 4 obviously you may skip the “Paste the following line” part because you should already have that line in your AppleVolumes.default file.

  10. Cameron says:

    This is working great for me. Thanks for the instructions. Question though: does anybody know if there any way to read the backed up files from the Ubuntu machine if the Mac dies? I’ve been looking at instructions such as

    http://superuser.com/questions/238297/accessing-time-machine-backup-from-windows-linux-laptops

    but the folder names and structure mentioned there don’t seem to be the same. It seems that things are stored differently.

    Thanks,

    • Dae says:

      I’m not sure I understand the part about folder names. My guide does not impose any specific folder structure.

      Keep in mind that OS X stores its backup in a “.backupd” file, that is a container with Apple’s proprietary HFS+ filesystem. By default Ubuntu cannot read HFS+ and thus it cannot read your “.backupd” container, until you specifically tune it to do so with additional packages and hacks, as suggested by your link.

  11. robert says:

    thanks, so simple. I had Tiger backing up to Ubuntu, but when I went to Snow Leopard it stopped and I couldn’t get it working again until I came across this. Now the mac is backing nicely and I go access back to those original backups from the tiger days!

  12. Pingback: CentOS: Instalar o Netatalk 3.1.0 (Time Machine) | Blog do TadeuCruz

  13. Moosila says:

    This is great help. Thank you.

    Andrew Zimmerman, Thanks for the solution!

  14. Gary Corcoran says:

    I think the below commands are needed to be run on Mavericks, they were for me anyway,
    ===================
    BEGIN WORKAROUND
    ===================
    cd /usr/lib/netatalk
    mv uams_dhx2.so uams_dhx2.so.broken
    ln -s uams_dhx2_passwd.so uams_dhx2.so

    • bfh says:

      That wasn’t necessary for me. Working just fine in mavericks.

    • Tom says:

      For the record: I also needed to apply the workaround from Gary Corcoran to make it work on Mavericks (on a new system). Thanks, Gary!

  15. Pingback: Jeff Beard » Blog Archive » Store Time Machine Backups on an Ubuntu Server - Blog.blog

  16. James says:

    If you getting the “OSStatus Error 2 message” message with an external drive try not auto-mounting the drive but instead use a system wide mount by editing fstab or using pysdm to do that.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>