Sunday, September 27, 2009

Setup of a Linux TimeMachine backup server, accessible from OS X

I've found a couple of sites that describe a procedure for defining a networked TimeMachine Volume using Ubuntu Linux.


The last one is very clear and complete. This is a summary of the commands I used for configuring Ubuntu 9.04.

Update: seems that this procedure also work for Ubuntu 10.04. After upgradind the server I could not mount the shares and received the messages:

Jul  5 09:04:35 machine afpd[18138]: cnid_open: dbenv->open of /home/user/TimeMachine/.AppleDB failed: DB_VERSION_MISMATCH: Database environment version mismatch
Jul  5 09:04:35 machine afpd[18138]: Cannot open CNID db at [/home/user/TimeMachine].
Jul  5 09:04:35 machine afpd[18138]: Fatal error: cannot open CNID or invalid CNID backend for /home/facciolo/TimeMachine: cdb
The database contained in the .AppleDB directories has changed format. The solution is to remove it (See: http://www.gentoo-wiki.info/HOWTO_Share_Directories_via_AFP#Troubleshooting).


1) Install and configure packages in Ubuntu 9.04
apt-get install netatalk
apt-get install avahi-daemon
apt-get install libnss-mdns

Edit: /etc/default/netatalk
ATALKD_RUN=no
PAPD_RUN=no
CNID_METAD_RUN=yes
AFPD_RUN=yes
TIMELORD_RUN=no
A2BOOT_RUN=no

Append to: /etc/netatalk/afpd.conf
- -transall -uamlist uams_randnum.so,uams_dhx2.so -nosavepassword -advertise_ssh

Edit: /etc/netatalk/AppleVolumes.default
~/ "$u" allow:username1,username2 cnidscheme:cdb

/home/username/TimeMachine TimeMachine allow:username1,username2 cnidscheme:cdb options:usedots,upriv

Do not forget to create the backup directory:
mkdir /home/username/TimeMachine


2) Configure avahi and start services (Ubuntu)

Edit: /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Edit: /etc/avahi/services/afpd.service

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<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>


Start the services:
/etc/init.d/netatalk restart
/etc/init.d/avahi-daemon restart
By now the network drives (home and TimeMachine) should be visible from OSX Finder.


4) Enable networked TimeMachine Volumes in OS X
In a terminal run:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1


5) Create a disk image for the first use of TimeMachine
5.1) Obtain the MAC address (ifconfig -a) here marked as XXXXXXXXXXXX:
en0: flags=8863.....
ether XX:XX:XX:XX:XX:XX
....
5.2) Obtain the computer name (hostname -s) : mycomputer
5.3) Create the image with Disk Utility
  1. New Image
  2. Set the image name to : mycomputer_XXXXXXXXXXXX.sparsebundle
  3. Set Image Format to: sparse bundle disk image
  4. Set Volume Size to: Custom
  5. Create and save the image on the LOCAL drive (not the networked one)
  6. Copy the image to the networked drive and erase the local one

6) Choose the TimeMachine network drive and backup.
You may also want to change the backup interval (3600 sec by default):
Edit the file /System/Library/LaunchDaemons/com.apple.backupd-auto


No comments:

Post a Comment