Skip to content

Instantly share code, notes, and snippets.

@gistub
Last active November 28, 2024 13:24
Show Gist options
  • Select an option

  • Save gistub/6e9734dc1d87307ee453b97a6d9a4dac to your computer and use it in GitHub Desktop.

Select an option

Save gistub/6e9734dc1d87307ee453b97a6d9a4dac to your computer and use it in GitHub Desktop.
[macOS: Set up time machine on linux] Use samba and avahi #macos #linux #setup

Note: change the settings marked with <=== according to your network and user settings

Required packages

  • avahi sudo apt install avahi-daemon
  • samba sudo apt install samba

On manjaro we need to enable AUR packages to install netatlak.

Enable services

sudo systemctl enable avahi-daemon

Update /etc/avahi/avahi-daemon.conf to enable following settings:

[server]
allow-interfaces=eno1,enp13s0,wlp12s0  # <===

[wide-area]
enable-wide-area=yes

[publish]
publish-hinfo=no
publish-workstation=yes
publish-domain=yes
publish-dns-servers=10.42.0.2, 192.168.13.1 # <===

Add /etc/avahi/services/samba.service with:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!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>_adisk._tcp</type>
    <port>9</port>
    <txt-record>dk0=adVN=gmachine,adVF=0x82</txt-record>
    <txt-record>sys=adVF=0x100</txt-record>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=MacPro7,1@ECOLOR=226,226,224</txt-record>
  </service>
</service-group>

In above gmachine is the name of the time machine share in smb.conf.

In /etc/samba/smb.conf add a share pointing to the mount point of the (zfs) file system used for storing the TimeMachine sparsebundle.

[global]
   fruit:aapl = yes
   fruit:delete_empty_adfiles = yes
   fruit:model = MacPro7,1@ECOLOR=226,226,224
   fruit:nfs_aces = yes
[gmachine]
   comment = Time Machine server on a zfs filesystem
   path = /mnt/gmachine # <===
   available = yes
   browseable = yes
   writeable = yes
   guest ok = no
   write list = hamid # <===
   valid users = hamid # <===
   inherit permissions = yes
   create mask = 0600
   directory mask = 0700
   force create mode = 0600
   force directory mode = 0700
   # spotlight = yes
   # vfs objects = catia fruit streams_xattr
   vfs objects = catia fruit streams_xattr 
   ea support = yes
   fruit:time machine = yes
   fruit:metadata = stream
   # Added from https://wiki.samba.org/index.php/Configure_Samba_to_Work_Better_with_Mac_OS_X
   fruit:veto_appledouble = no
   fruit:zero_file_id = yes
   fruit:posix_rename = yes 
   fruit:wipe_intentionally_left_blank_rfork = yes
   # fruit:model = AirPort5,177
   # fruit:model = MacSamba
   # https://fy.blackhats.net.au/blog/html/2021/03/22/time_machine_on_samba_with_zfs.html
   durable handles = yes
   kernel oplocks = no
   kernel share modes = no
   posix locking = no
   case sensitive = yes
   default case = lower
   preserve case = no
   short preserve case = no

Then restart services:

sudo systemctl restart smbd
sudo systemctl restart avahi-daemon

To see the Time Machin in macos, log into linux server in Finder. You may have to run defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Other sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment