Quantcast
Channel: Talk Like A Duck : Category site_news, everything about site_news
Viewing all articles
Browse latest Browse all 10

Ubuntu TimeMachine server for Snow Leopard

0
0

I've been contemplating improving my backup strategies lately.

Last year, I signed up with Backblaze to back up my MacBook to the cloud. There are a few players in this arena, another is Carbonite.

But off-site backup is only one leg of the backup stool. The wisest course for backup is a 3, 2, 1 strategy. That is to have three copies of your data, on two media (i.e. at least one of the copies should be on a different medium than the others), and one of the three should be offsite.

I consider on-line backup (a la Backblaze) to be a different medium, where rather than the medium just being a hard disk it's the whole off-line backup company's infrastructure.

Offline/offsite backup is really targeted for disaster recovery, if the building housing my on-site backups was destroyed by fire, or some other calamity, along with those backups I could recover the data from backblaze, but it would take a while to get it, either by downloading or getting them to ship me an external hard disk.

And for certain important data, I also use DropBox which can not only save data to the cloud, but sync that data between multiple machines. To make sure I've got a copy of the contents of this blog, I have a cron job on the Linux server where it runs which does a sql dump of the database to a dropbox folder, along with any new files (images, documents, etc) used by the blog. This runs in the wee-dark hours, and every morning, my MacBook informs me that DropBox has copied that data down to my MacBook.

But I've been feeling a gnawing need for better on-site backup, with faster access for either full recovery, or to get back a mistakenly deleted, or corrupted file.

One requirement is that the backups be done automatically. I've got too many other things on my mind than to remember to backup frequently, that's what I have computers for. Also I want the backups of my Macbook to work anywhere it can access the LAN. I tend to use my MBP in various areas of the house, upstairs in my office, where it's next to the server, and can be jacked into the same ethernet switch as the server, but also in the family room and even the bedroom, where it's connected by wi-fi.

TimeMachine

I've been wanting to use Apple's TimeMachine for a while, but haven't had the necessary hardware. I'd been thinking about buying a TimeCapsule, but I've been just a little leery since several of my friends have had their TimeCapsules die within a year.

I did a bit of research, and came up with the idea of looking at using my Linux server to hold a TimeMachine backup. The box has several available drive bays, and I could get a 2TB WD SATA drive for $120. With the cable and tax it came to just around $150.

But first I wanted to make sure that it would really work.

Existing How-Tos

I asked my friend Google about TimeMachine and Ubuntu and the first hit was a detailed how-to on kremaliscious.. Unfortunately that how-to is about two years old. Fortunately it still pretty much applies, but things have been simplified a bit.

That how-to, which was last updated when the latest Ubuntu was 8.04, "Hardy Heron" and the latest OS X was still 10.5.x, "Leopard", describes building a custom debian package for netatalk to add support for ssh connections. Netatalk is an open source implementation of Apple's AppleTalk Protocol Suite. I also encountered a much more succinct article by my old OTI friend Andrew "Roo" Low, which did the same.

For context, I'm running Ubuntu 10.04, "Lucid Lynx", on the Linux box, and OS X 10.6.4, "Snow Leopard" on the MBP.

A comment near the end of a long string of comments in that first article indicated that a custom netatalk package was no longer necessary, since the standard debian/ubuntu netatalk package now has ssh support. But following the rest of the instructions got me to the state where my Mac could see the shared volumes on the server, but when I tried to connect to them, I couldn't authenticate.

Figuring that I really did have to build a custom netatalk package, I followe Roo's article and built one. But it ended up in the same place.

It turned out that the crucial bit was a change to the configuration of netatalk's afp configuration.

The article gives the following configuration line in /etc/netatalk/afpd.conf

  - - transall -uamlist uams_randnum.so,uams_dhx.so -nosavepassword -advertise_ssh

But with the current netatalk this needs to be changed to:

  - - transall -uamlist uams_randnum.so,uams_dhx2.so -nosavepassword -advertise_ssh

This is actually mentioned in comment 330 (of 670!) but I missed it.

After making that change, I could connect to the shares. So I removed my custom netatalk package and installed the standard one, and it still works.

Avahi setup

Netatalk is one half of what's needed to have a Linux box participate in an Apple friendly network. The other half is Avahi which is an open source implementation of the Zeroconf standard or what Apple calls Bonjour. Bonjour/Zeroconf is how Macs find services on the local network.

Most current linux distributions include Avahi, as does Ubuntu 10.04, so it was just a matter of configuring it. The instructions in the kremaliscious article are fine. However, while I was at it, I also configured Avahi to publish a VNC server which allows me to easily start a graphic login to the server from the Mac finder. Bonjour uses the service type rfb (remote frame buffer) for the VNC server. To get this working I followed this article. I combined the configuration of both the afpd and rfb services into a single configuration file in /etc/avahi/services/multi.service

Here's that file:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
  <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
  <service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
      <type>_rfb._tcp</type>
      <port>5901</port>
    </service>
    <service>
      <type>_afpovertcp._tcp</type>
      <port>548</port>
   </service>
    <service>
      <type>_device-info._tcp</type>
      <port>0</port>
      <txt-record>model=Xserve</txt-record>
    </service> 
  </service-group>

File Server Setup

First I configured netatalk to give me a test 'drive' by publishing a directory in my own home directory on the linux box. Once I'd proved to myself that TimeMachine could in fact connect to this, it was time to buy that drive and hook it up.

I make it a standard procedure to install disks on Linux under control of LVM. Here's a pretty good and succinct guide on getting started with LVM on Ubuntu.

So I installed the drive, and set it up as an LVM Physical Volume called FileServer, I then added a couple of logical volumes to the group:

  sudo lvdisplay
    --- Logical volume ---
    LV Name                /dev/FileServer/TimeMachine
    VG Name                FileServer
    LV UUID                VIdN7y-0gDa-1Azr-0oYB-MRj3-Woxt-Utyef8
    LV Write Access        read/write
    LV Status              available
    # open                 1
    LV Size                1.50 TiB
    Current LE             393216
    Segments               1
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           251:3

    --- Logical volume ---
    LV Name                /dev/FileServer/MunimulaClone
    VG Name                FileServer
    LV UUID                Y36agh-Tgnk-1dcf-34tw-AJLm-1Mc2-jcqsuk
    LV Write Access        read/write
    LV Status              available
    # open                 0
    LV Size                320.00 GiB
    Current LE             81920
    Segments               1
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           251:4

I gave TimeMachine 1.5 terabytes to play with, and reserved enough to hold a snapshot of my laptop drive in MunimulaClone. Munimula is the name I gave my MacBook pro, inspired by it's construction and a childhood memory. I then installed an ext3 filesystem in both of these logical volumes.

I set up /etc/fstab to mount these in to mount points in the /var directory

  /dev/FileServer/TimeMachine /var/TimeMachine ext3
  /dev/FileServer/MunimulaClone /var/MunimulaClone ext3

Following Roo's suggestion I created an empty file “/var/TimeMachine/.com.apple.timemachine.supported” with the touch command, and on the Mac I executed the command:

  defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Then I added the following two lines at the end of /etc/netatalk/AppleVolumes.default to publish the two network volumes:

  /var/TimeMachine TimeMachine allow:rick cnidscheme:cdb options:usedots,upriv
  /var/MunimulaClone MunimulaClone allow:rick cnidscheme:cdb options:usedots,upriv

I did run into the problem encountered by others of TimeMachine giving an error that it couldn't create the backup disk image, but IIRC this only happened once, it created a file called munimula.tmp.sparsebundle, and removing the .tmp from the file name seemed to allow TimeMachine to proceed.

Results

With the MBP connected via an ethernet cable through a switch to the linux box, the first backup (about 290GB) took around 11-12 hours. It had just finished when I checked this morning. The second 'hourly' backup took just a few minutes. I then disconnected the hard-wired connection and brought the laptop downstairs.

It didn't seem to automatically start a new backup cycle over wifi when it should have, but getting it started by holding the mouse down over the TimeMachine icon in the dock until the menu appeared and then selecting "Back up now" got things kicked off, and it's been taking hourly backups wirelessly all day so far. The hourly backups take a bit longer, may 10-15 minutes. I'm not sure if that's because of lower bandwidth over wifi, or just because I've been using the laptop, and there's more delta data than there was first thing in the morning.

So far I'm pretty happy with the setup, I'll update this article should any surprises occur, good or bad.


Original article writen by Rick DeNatale and published on Talk Like A Duck | direct link to this article | If you are reading this article elsewhere than Talk Like A Duck, it has been illegally reproduced and without proper authorization.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images