Recent Posts

2018-05-12

How to get Mac High Sierra Time Machine backups working on an Ubuntu 18.04 server

There are lot's of howtos out there how to get Linux servers to support TimeMachine networked backups for Mac clients. But lately they all stopped working due to latest Mac High Sierra updates. Apple moves away from Netatalk protocol and recommends using SMB. Unfortunately the latest Samba you will get on Ubuntu 18.04 is 4.7, and this does not support so called fruit extensions needed by Mac to have Time Machine writing it's data to the destinations. We need to get Samba 4.8 that was released not so long ago.

So let's start. I'm assuming you do not have any other samba installed. The backup folder will pop up as "backup on <your linux server name>" and you will be using user name backups with the password you'll set on the way. I strongly recommend to read the howto I've posted at the end. It allows for a multi user setup.

Install samba:
sudo apt-get-repository ppa:linux-schools/samba-latest
sudo apt update
sudo apt install samba
This installs samba 4.8 that is a hard requirement to get SMB based TimeMachine backups working.

Let's get the old samba config out of the way
mv /etc/samba/smb.conf /etc/samba/smb.confORG
Now create and edit /etc/samba/smb.conf

[global]
server role = standalone server
passdb backend = tdbsam
obey pam restrictions = yes
security = user
printcap name = /dev/null
load printers = no
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=524288 SO_SNDBUF=524288
server string = Samba Server %v
dns proxy = no
wide links = yes
follow symlinks = yes
unix extensions = no
acl allow execute always = yes
# Special configuration for Apple's Time Machine
fruit:model = MacPro
fruit:advertise_fullsync = true
fruit:aapl = yes
fruit:time machine = yes
## Definde your shares here
[backup]
path = /space/backups
valid users = backups
writable = yes
durable handles = yes
kernel oplocks = no
kernel share modes = no
posix locking = no
vfs objects = catia fruit streams_xattr
ea support = yes
browseable = yes
read only = No
inherit acls = yes

Create and edit /etc/avahi/services/timemachine.service

<?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>
 </service>
 <service>
   <type>_device-info._tcp</type>
   <port>0</port>
   <txt-record>model=RackMac</txt-record>
 </service>
 <service>
   <type>_adisk._tcp</type>
   <txt-record>sys=waMa=0,adVF=0x100</txt-record>
   <txt-record>dk0=adVN=backup,adVF=0x82</txt-record>
 </service>
</service-group>
Create and edit /etc/rc.local as it looks like that samba 4.8 does not come with startup scripts.
#!/bin/bash
echo " # starting samba from rc.local"
smbd
exit 0
Add the backup directory, backup user and set permissions on the directory. This also sets the password for SMB/CIFS access:
useradd -m backups
smbpasswd -a backups
mkdir -p /space/backups
chown backups /space/backups
chmod 700 /space/backups
And let's start this (no reboot required):
/etc/init.d/avahi-daemon restart
smbd
And there, the new backup destination should show up in all macs connected to this network. REMEMBER KIDS, DO ENCRYPTED BACKUPS!

ps. how to view you mac backups progress:
log stream --style syslog --predicate 'senderImagePath contains[cd] "TimeMachine"' --info

Credits:
https://www.reddit.com/r/homelab/comments/83vkaz/howto_make_time_machine_backups_on_a_samba/