I recently put my mind to tackling the problem that had been plaguing mine and my fiancés MacBook Pros: backups.
We both have files held on our systems that we simply can't afford to lose. We also work wirelessly. For those reasons Apple's TimeMachine seemed like a really good option. However, at the £250GBP price tag and already having a home server, a bespoke solution appealed to both the geek and cost-saver in me.
After collating information from several different sources, please find below the steps required to setup and configure an Ubuntu instance to take backups from your Mac via TimeMachine:
Download netatalk 2.2 (The version held in Ubuntu repositories is 2.1 and Lion requires 2.2)
Natty i386: https://launchpad.net/~stefanor/+archive/ppa/+files/netatalk_2.2.0-0ppa2~natty1_i386.deb
Natty amd64: https://launchpad.net/~stefanor/+archive/ppa/+files/netatalk_2.2.0-0ppa2~natty1_amd64.deb
(Others here: https://launchpad.net/~stefanor/+archive/ppa/+packages)
Install netatalk
via dpkg -i <netatalk package name>
Edit /etc/netatalk/afpd.conf
The only line you want: "- -udp -noddp -uamlist uams_randnum.so,uams_dhx.so,uams_dhx2.so -nosavepassword"
Edit /etc/netatalk/AppleVolumes.default
Remove the default line for ~/ (if it exists) by commenting it out (a # should do). Add a new line: "~/.TimeMachine "$u Backup" allow:jamesanslow cnidscheme:dbd options:usedots,upriv,tm" - REPLACING "jamesanslow" with YOUR server username.
Create your Timeachine directory
mkdir ~/.TimeMachine should do it fine
Edit /etc/netatalk/netatalk.conf
Add/append/uncomment/leave the same the following important lines to:
ATALK_NAME=`echo ${HOSTNAME}|cut -d. -f1`
ATALK_UNIX_CHARSET='LOCALE'
ATALK_MAC_CHARSET='MAC_ROMAN'
export ATALK_UNIX_CHARSET
export ATALK_MAC_CHARSET
CNID_METAD_RUN=yes
AFPD_RUN=yes
AFPD_MAX_CLIENTS=20
ATALKD_RUN=no
PAPD_RUN=no
TIMELORD_RUN=no
A2BOOT_RUN=no
Create a new file in /etc/avahi/services/afpd.service
Copying in the following:
<?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>
Restart netatalk:
sudo /etc/init.d/netatalk restart
Connect to your server from your mac
Go to Finder and your server should appear in the left hand side. If not, CMD+K to manual connect.
Create your sparse backup file
Open up a terminal on your Mac. Move (cd) to the folder where your server's mounted. This should be /Volumes/<username> Backup. So for me that would be "/Volumes/jamesanslow Backup". Then run this command to create your backup file (replacing 512g with the size you'd like your TimeMachine to be in Gigabytes):
hdiutil create -size 512g -fs HFS+J -volname "Time Machine" `grep -A1 LocalHostName /Library/Preferences/SystemConfiguration/preferences.plist | tail -n1 | awk 'BEGIN { FS = "|" } ; { print $2 }'`_`ifconfig en0 | grep ether | awk 'BEGIN { FS = ":" } ; {print $1$2$3$4$5$6}' | awk {'print $2'}`.sparsebundle
Configure OS X to show all types of media for use in TimeMachine
Set OS X to show all types of media, such as ours by running this command in the terminal:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
Go for it. Open up TimeMachine, select your network TimeMachine instance and get backing up!