Setting Up Samba To Work as a Time Machine Target

So you have your shiny new Mac, and you want to back it up to a Time Machine volume, but you don’t want to have it dangling from a USB cable, a great option is to back up to a linux host using Samba. In the past, you would have used netatalk over the AFP protocol, which still works, but Apple is deprecated the protocol, and it may go away in a future version. Samba, however, has been tweaked to support it with some MacOS specific options that work great.

The first thing you will need to do is install the samba suite. With Ubuntu, this will install everything you need. In other distributions you might need to install vfs modules separately. You also will want to install the avahi-daemon package so that the volume will “magically” appear as a volume.

First, follow the steps to set up Samba for use with MacOS.

You are almost there. Now you create a share to be the Time Machine volume. Add the following, and modify to taste, to your /etc/samba/smb.conf file.

[TimeMachine]
path = /storage/timemachine
writable = yes
browseable = yes
read only = no
inherit acls = yes
fruit:time machine = yes

Now if you want to get more fancy, you can make the volume show up as a proper Mac icon, create the following file /etc/avahi/services/smb.service with the following:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_smb._tcp</type>
    <port>445</port>
    <host-name>%h</host-name>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=MacPro6,1</txt-record>
  </service>
  <service>
    <type>_adisk._tcp</type>
    <txt-record>sys=waMa=0,adVF=0x100</txt-record>
    <txt-record>dk0=adVN=TimeMachine,adVF=0x82</txt-record>
    <host-name>timemachine.local</host-name>
  </service>
</service-group>

Set the hostname you want to appear in the host-name tags (i.e. replace “timemachine.local” with the FQDN of the host you want to appear), and the Mac model. In this case “MacPro6,1” corresponds to the 2013 trash-can Mac Pro. The list of model numbers/icons can be extracted from /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist.

1 thought on “Setting Up Samba To Work as a Time Machine Target”

  1. Two timemachines on the same server needs two Samba entries (as easy as you think). But in in the Avanti xml, you need a second line like so:

    dk1=adVN=TimeMachineTwo,adVF=0x82

    immediately after the dk0 line.

    Reply

Leave a Comment