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.

[Edit: April 2013 – it’s been some time since I stopped using this solution. I experienced this failing twice for me in basically the same manner. When the timemachine volume would get full my backup would stop being accessible. Instead of spend more time figuring out what exactly was wrong, I’ve moved onto an rsync (rsnapshot) based solution].

13 thoughts on “Ubuntu with Apple’s Time Machine”

  1. 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!

  2. 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

  3. 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.

  4. Hi,

    I Followed this tutorial but I can’t login on my iMac?
    It says wrong username/password but I used my ubuntu login!
    Please help,
    Tim!

  5. @Geremia – The link you provide seems to be about accessing a time machine backup on a Linux box. That is something completely different.

    @iTimOSX – you need to log into your iMac using your OSX username and password, not your Ubuntu user/password.

  6. Hi I have a similar issue as iTimOSX.

    I can see the bonjour/avahi server in my mac mini but when I select it is asks me for a user id and password, when I supply the user id from my Ububtu machine and password it tels me it is not correct but I know 100% sure it is.

    Also I would like this share to be rw for everybody but until now I have not found the correct option in services.conf or services to set that.

  7. Hmm,

    Strange, I can see the shares now and Timemachine is backing up fine (had to do the sparse bundle copy trick) but what troubles me is that even though MAC OS says the UBUNTU server is a MAC server it is showing all the shares I am sharing through SMB and through AFP it should only show the backup volume.

    How can I make sure I am only using AFP for Time machine?

  8. @Ferno – I simply disabled SMB entirely to “prove” this to myself.

    I should probably disclose that I’m not using Timemachine for my backups anymore. I keep meaning to write a follow up..

  9. yeah I’m having the same issues as others are having.. that when I try accessing the afp share it just tells me that I got the wrong user or pass.

    strange thing is that I can’t see anything in the linux server’s log files and also, the error message pops up really fast. I’d imagine there’d be some delay if it actually tried to authenticate on a remote machine.

    I’ve tried this and many other guides just like it and I am confident some part if missing when it comes to gaining access to the shares…

  10. Ok Thanks,

    Not that the backup of the mini is that crucial as it is only running Itunes and Plex but I just cant stand it when something that is supposed to work doesn’t.
    Had it running on Freenas without a glitch, quite good implementation of AFP with a web front end etc.

    Is there a similar web frontend fro Ubuntu something like a plugin for webmin in which you can manage the AFP shares and access etc.

  11. Hmm, this might be somewhat circular – but one place I’d look for help is on Rick’s site:

    http://talklikeaduck.denhaven2.com/trackbacks?article_id=595

    (now, many of you may have reached here by reading his syndicated article…) At least Rick is a current Mac user, and I believe he’s still using his Ubuntu timemachine setup and thus may be more helpful. I’ve moved away from this for my backup needs (been using rsnapshot – again, something I should write up)

    A few alternative solutions:
    1) Run a something like virtual box on your Ubuntu system and host a FreeNAS instance in it.
    2) If nothing is in the logs, try using wireshark to do some packet sniffing. Also investigate the Mac logs

Leave a Reply

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