Categories Mac OS X, Ubuntu

Configure Time Machine Network Backup to Ubuntu Linux Server


Update for MacOS X Lion : it is necessary to download the latest version of the Netatalk service that supports the AFP protocol from the following link. Without this, Time Machine will no longer work on MacOS X Lion.

Following the acquisition of a server at Protuts.net, here is a tutorial to learn how to use Time Machine to perform your backups to a local server not using MacOS X. Thanks to Linux Ubuntu, this tower is easily achievable!

Foreword

Prerequisites

First of all, be aware that this tutorial is not intended for all our readers. Not because it is more difficult than others but because you have to be in a situation similar to ours.

You will therefore need the following elements to follow this tutorial:

  • Have 1 or more networked computers (PC/Mac);
  • 1 classic server running on Linux Ubuntu 10.10;
  • The operating systems installed on each of the machines;
  • All your machines must belong to the same network domain;
  • The machines are connected to each other by Ethernet cable — WIFI is not suitable for this type of situation;

Problem

From there, here is the problem to solve: how to ensure that each machine in the network can benefit from the storage capabilities — and thus backup, of the server (2 TB) while knowing that some use Windows systems (XP and 7) and others MacOS systems?

Several operating systems, this also means several types of partitions: NTFS for Windows and HFS+ for MacOS. The server must therefore be able to manage the 2 types of partitions to perform the backups correctly.

And that’s all the advantage of using Ubuntu!It handles these 2 types of partitions very well... but we'll go further by creating Ext4 partitions (Linux format) to perform our TimeMachine backups on MacOS X.

Moreover, given that Linux Ubuntu and MacOS X are based on UNIX, we will see that these two are perfectly interoperable — understand that they know how to collaborate.

For Windows, we will have to create NTFS partitions on the server... but we'll get back to it in a future tutorial.

In the end, MacOS X systems will save on Ext4 partitions and PCs on NTFS partitions.

Sources of departure

To carry out this mission, we relied on 2 English tutorials... we combined the 2 techniques while adapting them for Ubuntu 10.10.

  1. Making Time Machine Works With Ubuntu 10.10 Using AFP ;
  2. HOWTO: Make Ubuntu A Perfect Mac File Server And Time Machine Volume [Update6] ;

The most advanced, note that many steps have been removed since the previous distributions of Ubuntu.

Configuration of the Ubuntu Linux server

As I said in the introduction, I am starting from the principle that you have already installed Ubuntu 10.10 on your server machine. For info, a server is nothing different from a traditional client post in our case.

Step 1 — Installation of netatalk

So start by logging in and launch a Terminal.

Capture d'écran - Terminal sous Linux Ubuntu
Screenshot of screen — Terminal under Linux Ubuntu

Often you will be asked for your session password. Enter it while knowing that it does not appear on the screen.

Paste this first command:

sudo apt-get install aptitude

Wait a few moments then enter this second command:

sudo aptitude install netatalk

You have just installed netatalk to communicate between your computers.

Step 2 — Specification of Backup Authorisations

Let’s now edit the file AppleVolumes.default to configure backups. To do this enter this command to automate the process:

sudo gedit/etc/netatalk/AppleVolumes.default

Here we will indicate who has the right to save on a particular partition. You should not create backup conflicts between your machines.

So we need to specify an IP address whose associated machine will have write rights on a dedicated partition.

Capture d'écran - Configuration de AppleVolumes.default
Screenshot — Setup of AppleVolumes.default

Go to the end of the file, just after the line:

~/“Home Directory”

Then insert a line for each of your network machines in this form:

/media/TimeMachineAD allow:@anoste options:usedots,upriv,tm allowed_hosts:192.168.1.11

The beginning indicates the partition of the server that will host the backup — in this case, /media/TimeMachineAD while the end of the line indicates the IP address of the client machine — here, 192.168.1.11.

You must also specify the authorised domain. In my case, it is a matter of @anoste. This is the famous Workgroup Windows.

Save the file and close it. Note this file editing command, as you will need to add a line for each of your machines wishing to perform automatic network backups.

Let’s now restart the AFP service — AppleTalk Filing Protocol via the command:

Sudo/etc/init.d/netatalk restart

Step 3 — Settings of Avahi Daemon

To continue the tutorial, you must have Avahi Daemon and libns-mdns on your Ubuntu.

Normally, they are installed by default but let’s check through the command:

sudo aptitude install avahi-daemon libnss-mdns

That’s done, we need to modify the file nsswitch.conf via the following command:

sudo gedit/etc/nsswitch.conf
Capture d'écran - Paramètrage de nsswitch.conf
Screenshot — Settings of nsswitch.conf

Then locate the line:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

Then add the word mDNS just at the end of the line like this:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Save and close this configuration file.

Step 4 — AFP Configuration

Let’s now make TimeMachine capable of identifying the backup partition we assigned to it.

Open the folder /etc/Avahi/services/ and create a new file afpd.service using a text editor.

Capture d'écran - Configuration du service AFP
Screenshot of screen — Configuration of the AFP service

Then paste the following code:

%h

_afpovertcp._tcp
548


_device-info._tcp
0
model=iMac

At the antipenultith line, modify the Mac type model by indicating one of the following names: Macbookpro, MacMini, iMac, MacPro, Xserve, MacBook or MacBook Air.

Step 5 — Restarting services

Go back to a Terminal then enter the following order:

/etc/init.d/avahi-daemon restart

Then restart your Ubuntu and your backup machine — a Mac so.

We are now finished for the Ubuntu server configuration.

MacOS X client configuration

Now switch to your Mac to save. Run Time Machine and then do Choose a Disc.

You should see the network partition present on your Ubuntu server.

Capture d'écran - Choix de la partition de sauvegarde réseau via Time Machine
Screenshot — Select Network Backup Partition via Time Machine

So select the latter and launch the backup.

Of course, the first backup will take several hours as transfers will take place over the network via Ethernet (cable). Thereafter, only incremental backups will be operated, which will take much less time — in the order of a few minutes knowing that a standard 5th class Ethernet cable transmits at 10-12 MB per second.

If by case, the network partition does not appear, use the function Connect to the server... present in the menu Go of Finder.

Then enter the following command by replacing this example with the IP address of your server:

afp://192.168.1.10

You now have a network backup system running with Time Machine from MacOS X and Linux Ubuntu. Soon, the same for Windows PCs with a Ubuntu server!

Tags

28 comments

Leave a Reply

  • Coincidence? Would Protuts read my thoughts? Just yesterday, I was googling without results in search of this tutorial there very exactly.

    It’s perfect! On the other hand, I don't thank you... it’s not yet that I would work my classes!

  • In step 2 you say:

    You must also specify the authorised domain. In my case, it’s @anoste. This is the famous Workgroup on Windows. “

    How to find the workgroup of the mac and/or Ubuntu? And should we leave @ before?

  • Good morning,

    I tried to apply your tuto, but I don't understand this workgroup story seen that my mac is not on any working group.

    I see my server on the pac too, but on the other hand, I can't connect: he doesn't recognise my password.

    • Aurélien Denis Post author

      In the Network properties under MacOS X, in Advanced and then on the WINS tab, you will find the title of the working group.

      For the password, this is the user account present on the server and not that of your Mac.

      • Thank you for your answer, but I admit that in fact it doesn't make me too much:
        — As far as the working group is concerned, I have found it right. But I'm not in any band. Which is no wonder since I don't have windows on my network. Do I have to set up a working group? And I don't understand why I need it because it’s a windows protocol. And that I want to make a link between a pimp and linu
        — about the password and the logins... thank you for your advice, but I understood well. It’s good by returning my linux identifiers that it doesn't work. Is there a way to regenerate password and root ID?

        • Thomas

          As far as the tuto is concerned, it is well done. The link here is just for Time Machine backup. For file sharing you can enable samba.
          To limit the size of the backup target folder you need to create a sparsebundle on the Mac disk utility

  • Mathieu

    I've done the whole tutorial again. For the working group, I set up “workgroup”
    And it works. In the end, in my finder I see all the directories of/home.

    However, I added a bigger hard disk and I would like to put my backup on it. But impossible to see it in my finder, even if the disk and “mount” in the linux file explorer.

    I took over the netalk configuration like that but it doesn't work:
    ~/“Home Directory”
    /dev/SDA/storage_server/TimeMachineAD TimemachineAD allow:@workgroup options:usedots,upriv,tm allowed_hosts:192.168.0.6

    (SDA being my new disc)

    I always see that the directories of my/home of my user.
    Should I change ~/“Home Directory” to redirect it to sda?

    • Thomas

      If you want to make a Time Machine backup on this disk, you don't have to worry if it’s in the finder, but especially if you see it in Time Machine directly.

    • Soriyath Straessle

      I think we need to put the directory mounted and not/dev/sda...
      you should find something like/media/new disc/TimeMachine......

  • Mathieu

    I don't see the directories of my new disk in finder and time machine either. Unless I get him into the finder via smb. But in that case, when I launch the backup, it puts me a mistake:
     “Cannot create the folder/opt/lampp/htdocs/www/wp-content/uploads/2011/03. Is his parent folder accessible in writing by the server”
    The backup works “well” on the first disk, but I don't have enough space.

    Thank you again for your advice. I‘m at the point where I think I’m going to have to reinstall my linux server on the larger disk capacity.

    • Aurélien Denis Post author

      I don't really understand your problem. There are several things you say at the same time and it’s not very clear to help you.

      I don't think you need to reinstall your Linux. Just create empty partitions to host your data.

  • Mael

    Hello Aurélien,

    I followed the tutorial from end to end however, TimeMachine can't find the Ubuntu severor while it goes smoothly in the finder.

    I added the workgroup in the config of my pimp but still does not change anything.
    What can I do?

  • Freddo57580

    Hello Aurélien,

    I'm thinking of buying an imac and keeping my old PC to go to Ubuntu.
    I'd like to create my own TimeCapsule with your tuto but I have a novice question...
    This concerns the partition of the server that will host the backup(/media/TimeMachineAD for you in your tutorial):
    —it’s a partition you created when installing UBUNTU? (thus one in primary ext4 for the system , one in primary for swap, one in primary for documents in ext4 (/home) and one last for time machine in ext4? or is it simply a/home file?

    Last question: if on the network we have a mac, the pc with ubuntu and a portable pc with windows:
    —how to make sure that from windows and from the mac one can enjoy the files present on the pc with ubuntu (which becomes server somehow)? one has to make another partition? in NFS? In this case, is it limited by the size of the files?

    Thank you

    • Aurélien Denis Post author

      You don't have to create the TimeMachine partition when installing Ubuntu.

      I separated the system on another default partition (the home so). No SWAP for me.

      I have the same type of network as you: on your Mac you can make backups on your Ubuntu server. On your PC, only view NTFS partitions shared via Samba under Ubuntu.

      You cannot access a backup partition from Windows because it is not a format recognised by Windows.

      No file size problems. It all depends on the disk space you have.

      • Freddo57580

        Thank you! It’s nice to have answered so quickly!
        it’s clear, it won't be simple, but my goal is really to discover the possibilities of LINUX!
        I've got a job!

    • dellp

      I found the file (without google) it was not hard to find but this is my first time on ubuntu but I can't create “afpd.service” or even to put it in the folder

      • Jureju

        Hello deelp
        To create the file:

        in the terminal you type:

        CD/etc/avahi/
        chmod 777/services/

        And you should be able to create your file

  • Alex

    Hi, precision for those who use the latest versions of everything (in my case, ubuntu 12.04)

    In/etc/netatalk/afpd.conf, these options should be used:
    — -tcp -noddp -uamlist uams_dhx.so,uams_dhx2_passwd.so

    And use dbd as cnidscheme in/etc/netatalk/AppleVolumes.default

    For my part, I couldn't log in at all after an update (catastrophic, I lost a whole XFS partition on 6 TB raid due to a race condition to boot) from 11.04 to 12.04.

    Apparently connection problems appear from 11.10.

    With these new settings, my backups resume, I'm quieter!