Ubuntu with Apple’s Time Machine

timemachineOnce I had managed to get Leopard up and going on the mac mini with all of the user settings copied over, it was time to start exploring new features.  Time Machine was first on the list – but I wanted to have it back up over the network to my Ubuntu Linux server.  I probably took the long route to a solution, but what I have seems to be working.  The two main parts of getting time machine to work are: a) make it so the Mac can see the network storage b) trick time machine into using it as a destination.

Part A – I believe that you can use a non-AFP network storage solution (and my Mac can see my Samba volumes for shared files) but I went the route of enabling AFP.  This is based on instructions found here, but I’ll repeat it here with my comments:

  1. We’ve got to recompile netatalk to have encryption.  You’ll need the universe repository enabled, and the development tools.  Details can be found in the ubuntu forums.
    sudo apt-get install dpkg-dev
    sudo apt-get install devscripts
    sudo apt-get install libssl-dev
    apt-get source netatalk
    sudo apt-get build-dep netatalk
    sudo apt-get install cracklib2-dev
    cd netatalk-2.0.3
    DEB_BUILD_OPTIONS=ssl debuild
    sudo dpkg -i ../netatalk_2.0.3-3ubuntu1_i386.deb

    You’ll probably want to issue a ‘hold’ on the netatalk package by using dpkg –set-selections to prevent being upgraded
    For the lazy – here is a link to the .deb I created.
  2. Modify the configuration file /etc/netatalk/AppleVolumes.default to point at the location you are going to store files.  Ensure ownership and permissions are correct for the user you want to have access this location.
  3. Now we install avahi
    sudo aptitude install avahi-daemon
    Edit /etc/netatalk/afpd.conf to contain:
    - -noddp -uamlist uams_randnum.so,uams_dhx.so
    you might add -noslp to that line above to remove a warning, the key is that the configuration must be on a single line.
    Edit the hosts line in  /etc/nsswitch to match
    hosts: files dns mdns4
    Download using wget http://www.disgruntled-dutch.com/media/afpd.service
    and install that in /etc/avahi/services
    Restart the services:
    sudo /etc/init.d/netatalk restart
    sudo /etc/init.d/avahi-daemon restart

At this point your Mac should be able to discover the service and see the volume as a shared drive.

Part B - Tricking the Mac into using this volume as a backup.  You may not need to do any of the work in Part A at all as is evidenced by other people claiming success on the net.

  1. Create a file named “.com.apple.timemachine.supported” at the root of the filesystem we pointed at in (2).  I’m not entirely sure this is required, but it didn’t hurt.
  2. On the Mac we need to fiddle one default.  Enter the following command in a terminal:
    defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
    At this point, Time Machine would connect, but then fail with the error message: “Time Machine Error – Backup disk image could not be created”
  3. The ReadyNAS folk had a solution that worked for me.  Create the backup volume locally on the Mac and move it to the network volume:
    Determine your hostname, hopefully it is a simple one.
    Issue the command “ifconfig en0 | grep ether” which will find the MAC address of your Mac.
    Using <hostname>_<mac address>.sparsebundle as the filename we create a new volume:
    hdiutil create -size 140g -fs HFS+J \
    -volname "Backup of magpie" \
    magpie_0016cbaf91d7.sparsebundle

    Copy the newly created “sparse bundle” to the network volume.
  4. Now start up Time Machine – you should be good to go.  I opted to leave SpotLight enabled, this did significantly slow down the backup performance – but I do want the ability to search for “lost” files from the backup.

Time Machine is pretty weird.  I had assumed (wrongly) that it simply gave you a file view in time.  It turns out that many of the Mac applications are time machine aware, and will show you a views of the past.  For example, you can view your email through time and recover the mailbox from the past.

4 Responses to “Ubuntu with Apple’s Time Machine”

  1. Roo’s View » Blog Archive » Time Machine and Linux Says:

    [...] I had written about using an Ubuntu server to host Apple Time Machine backups.   Now that I’ve retired the old server, I needed to re-do some of that work to get [...]

  2. Joe Says:

    You left out adding support for pgp:
    After issuing: DEB_BUILD_OPTIONS=ssl debuild
    Towards the end:

    Finished running lintian.
    Now signing changes and any dsc files…
    Could not find a signing program (pgp or gpg)!
    debuild: fatal error at line 1261:
    running debsign failed

    Off I go to hunt it down…

    – Cheers!

  3. Return Privacy Says:

    Hi, you folks amaze me, and confuse me at the same time! I have a computer that is running Ubuntu 8.04 (new for me), and an iMac and Macbook Pro on home network. I did a google search to find out how to have my Time Machine send my backups to my Ubuntu computer and found this site. Seriously guys, what the ? does “repository, depository, compile, sudu, build, etc.” mean? It all looks greek to me. I heard great things about Ubuntu, so I put it on an old pc, and it does work, but how are we supposed to know all this greek stuff you talk about? Is there any easy way to get Time Machine to put my backups on my Ubunti computer? Thanks

  4. Roo Says:

    While Ubuntu is quite user friendly – for the most part almost all of the postings in my blog here are ultra geeky and require some degree of Unix/Linux knowledge.

    >Is there any easy way to get Time Machine to put my backups on my Ubunti computer?

    No. Or at least, not that I know of. Possibly at one point someone will packages it up in some way that makes this easy. Until that happens, head on down to the Apple store and pick up a Time Machine unit – they have great service and support.

Leave a Reply