Setting Up Time Machine Backup on Ubuntu Server 18.04 With Samba 4.8

Time Machine is a backup solution developed by Apple for macOS. You can set up a Time Machine backup destination on your Ubuntu Server 18.04 using Samba 4.8 to allow Macs on your network to back up their data. Here’s a step-by-step guide to help you achieve this:

1. Install Samba 4.8

First, install Samba 4.8 by adding the PPA repository and updating your package list:

1
2
3
sudo add-apt-repository ppa:linux-schools/samba-latest
sudo apt update
sudo apt install samba

2. Configure Samba

Remove the old Samba configuration and create a new one:

1
2
sudo mv /etc/samba/smb.conf /etc/samba/smb.confORG
sudo nano /etc/samba/smb.conf

Paste the following configuration into the file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[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

[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

3. Create Avahi Service for Time Machine

Create and edit the Avahi service file for Time Machine:

1
sudo nano /etc/avahi/services/timemachine.service

Paste the following content into the file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?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>

4. Start Samba and Avahi

Create and edit the /etc/rc.local file to ensure Samba starts at boot:

1
sudo nano /etc/rc.local

Add the following lines:

1
2
3
4
#!/bin/bash
echo "Starting Samba from rc.local"
smbd
exit 0

5. Create Backup User and Directory

Create the backup user, set the SMB password, and create the backup directory with appropriate permissions:

1
2
3
4
5
sudo useradd -m backups
sudo smbpasswd -a backups
sudo mkdir -p /space/backups
sudo chown backups /space/backups
sudo chmod 700 /space/backups

6. Restart Services

Restart Avahi and Samba to apply the changes:

1
2
sudo /etc/init.d/avahi-daemon restart
sudo smbd

Now, your Ubuntu Server 18.04 is set up as a Time Machine backup destination for your Macs on the network. Remember to enable encrypted backups for data security.

To view the progress of your Mac backups, you can use the following command:

1
log stream --style syslog --predicate 'senderImagePath contains[cd] "TimeMachine"' --info

Please make sure your server and network are properly configured for this setup to work smoothly.

0%