OS X Time Machine backups to a Debian Linux ZFS volume

I pulled together information from enough other sources to warrant a post of its own for getting this to work. Here are some of the other sources that I found helpful:

Several others posts have what seems to now be outdated information about needing a newer netatalk than stable Linux distributions have available. I’m using the Debian netatalk package version 2.2.5-2, from Debian Stretch (v9). I also checked the versions available in Debian testing (2.2.6-1) and Ubuntu 16.04 LTS (2.2.5-1).

First, set up the Linux server:

I’ve installed a pair of 6 TB hard drives:

$ zpool create tank mirror /dev/disk/by-id/ata-WDC_WD60EZRZ-... /dev/disk/by-id/ata-WDC_WD60EZRZ-...

Add a dedicated user:

$ sudo useradd -m macbook
$ sudo passwd macbook

Install netatalk:

$ sudo apt install netatalk libc6-dev avahi-daemon libnss-mdns

Update the hosts line in nsswitch.conf:

$ sudo vim /etc/nsswitch.conf
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns myhostname

Update afpd.service:

$ sudo vim /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!---nxml--->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
   <name replace-wildcards="yes">%h</name>

Create a location on your ZFS volume to store Time Machine backups, ensure that it is owned by the appropriate user, and establish a quota since Time Machine will ultimately fill whatever storage it has access to:

$ sudo su macbook
$ cd
$ mkdir timemachine
$ sudo zfs create -o mountpoint=/home/macbook/timemachine tank/timemachine
$ sudo zfs set quota=2500G tank/timemachine
$ chown -R macbook:macbook timemachine/

Now configure the folder share where Time Machine will write its backups. I removed the line that automatically shared home directories for all users, as I don’t want to share all users’ home directories.

$ sudo vim /etc/netatalk/AppleVolumes.default
/home/macbook/timemachine "debian Time Machine" options:tm

Restart the avahi and netatalk services:
$ sudo service avahi-daemon restart
$ sudo service netatalk restart

Now, switch to the Macbook

$ defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

In Time Machine settings, there should now be another option (matching the quoted string configured above in AppleVolumes.default). It is necessary to provide the password that was configured when running passwd above. I also opted to enable Time Machine’s native support to encrypt the backup, which requires its own password. Don’t lose that one!

This worked for me and the backup started. However, after only around 1GB backed up, I ran into an error. It read 'Backup Failed The backup on "debian" is already in use.' There was a “Details” button. Clicking it, the expanded dialog read 'Time Machine couldn't complete the backup to "debian". The backup disk image "/Volumes/Time Machine/Name of my macbook.sparsebundle" is already in use.'

I tried three things at once, and have not yet identified which one(s) were essential to solving the problem:

  • While experimenting I had previously left the per-user home directories enabled in AppleVolumes.default and mounted one of them in the Finder. I don’t know whether this is problematic, since it is a parent directory of the separate share where the Time Machine backups will go. I removed that line since it was in that config file by default and I don’t actually want every user’s home directory to be shared.
  • Avoiding switching back and forth between WiFi and wired ethernet while a backup is running.
  • Adjusting the power management settings to keep everything but the display running while connected to AC Power.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s