HOWTO Use Ubuntu As A Mac OS X Time Capsule
Agradecimiento a: http://ubuntuforums.org/showthread.php?t=2105755
In past versions of Mac OS X, the built in backup tool, Time Machine was a lot less picky about where you back up your files to. You could even back up to a Samba file share if you enabled the “unsupported volumes” hack.
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
But that ended with Snow Leopard. Starting with the release of OSX 10.7 Lion, Apple started cinching down on where you could back up your system to, ostensibly for security reasons. Now, with Mac OS X 10.8 “Mountain Lion”, it’s gotten to the point where essentially the only places you can back up your system using Time Machine are either on another Mac OS X File Server or on an Apple Time Capsule. My assumption is that their intent is merely to bolster their hardware sales.
I don’t know too many people who stay exclusively within the “walled garden” for all their computing needs. Certainly people with a lot more money to burn than me. But for a much more economical approach than shelling out around $300 for an over-glorified USB drive, you could just follow this guide to set up your Ubuntu file server to look and behave exactly like Time Machine would expect a real Time Capsule or Mac to.
Step 1: Install Netatalk
installing Netatalk, the open source Apple Filing Protocol (AFP) implementation is easy! The packages are already in the repos, which makes me wonder why it’s not enabled by default.
Install the following packages:
sudo apt-get install netatalk libc6-dev avahi-daemon libnss-mdns
Step 2: Configure /etc/nsswitch.conf
Once those packages are installed, there are actually 4 configuration files that need to be edited in order for the Macs on your network to access your AFP shares properly.
sudo nano /etc/nsswitch.conf
locate the line that reads
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
and add ‘mdns’ to it so it now reads
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
press ctrl+o to save and ctrl+x to exit.
Step 3: /etc/avahi/services/afpd.service
sudo nano /etc/avahi/services/afpd.service
paste the following code
<?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=TimeCapsule</txt-record> </service> </service-group>
NOTE: Just for fun you can change the string “<txt-record>model=TimeCapsule</txt-record>” to the following devices to change how they appear in Finder on OSX:
Type them exactly as I have typed them. They are case sensitive. If you type the model name in wrong, your AFP share will show up as a Cinema Display in Finder. There are actually dozens more. Too many to list actually, but if you’re interested you can find the name strings in /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist
Step 4: /etc/netatalk/AppleVolumes.default
This is where you actually declare your shared file.
sudo nano /etc/netatalk/AppleVolumes.default
scroll down to the bottom and find the section that reads
# The line below sets some DEFAULT, starting with Netatalk 2.1. :DEFAULT: options:upriv,usedots # By default all users have access to their home directories. ~/ "Home Directory" # End of File
change the path “~/” (which points to /home/username) to the directory you want to share. For me I created a separate partition mounted at /TimeCapsule.
IMPORTANT!!! You would be able to access the share from a Mac, but if you plan to use this share for Time Machine backup, you need to add ‘tm’ to options:upriv,usedots
# The line below sets some DEFAULT, starting with Netatalk 2.1. :DEFAULT: cnidscheme:dbd options:upriv,usedots,tm # By default all users have access to their home directories. /TimeCapsule "Time Capsule" # End of File
press ctrl+o to save and ctrl+x to exit.
Step 5: /etc/default/netatalk
this is the last file that you need to edit. Edit with
sudo nano /etc/default/netatalk
find the section that looks like this
#### Set which legacy daemons to run. #### If you need AppleTalk, run atalkd. #### papd, timelord and a2boot are dependent upon atalkd. ATALKD_RUN=no PAPD_RUN=no TIMELORD_RUN=no A2BOOT_RUN=no
and edit it so it looks like this:
#### Set which legacy daemons to run. #### If you need AppleTalk, run atalkd. #### papd, timelord and a2boot are dependent upon atalkd. ATALKD_RUN=no PAPD_RUN=no CNID_METAD_RUN=yes AFPD_RUN=yes TIMELORD_RUN=no A2BOOT_RUN=no
That is all. Now you can enjoy making incremental backups with Time Machine without the hassle of manually mounting disks. I actually did this on my Windows 8 HTPC/Mediaserver using a very stripped down headless Debian virtualbox installation that runs at boot as a background service and uses only 64MB of RAM and paravirtualized bridged ethernet.
Screenshot of my Mac backing up to the Debian virtual machine on my Windows 8 box.