# Samba functions but unable to use it as a MacOS Time Machine destination



## puppyboy (Apr 17, 2021)

This has been driving me nuts and I hope someone here can help point me in the right direction. I've freshly installed 13.0-RELEASE on a server. I've installed Samba 4.13.7 and Avahi (packages samba413 and avahi, installed using pkg and not ports).

My /usr/local/etc/smb4.conf file is as follows:

```
[global]
     workgroup = WORKGROUP
     security = user
     passdb backend = tdbsam
     fruit:aapl = yes

[Time Machine]
    comment = Time Machine
    path = /data/timemachine
    browseable = yes
    writeable = yes
    spotlight = yes
    vfs objects = catia fruit streams_xattr
    fruit:time machine = yes
    fruit:metadata = stream
    create mask = 0600
    directory mask = 0700
```

I've enabled and started samba_server and avahi-daemon in /etc/rc.conf, and enabled dbus as well (required for avahi).

I've created a dedicated user for this, named timemachine. This user has been configured as a samba user (sambapasswd -a timemachine).

The target /data/timemachine is a zfs dataset with compression=lz4 and quota=2TB, and otherwise default properties. The directory is user- and group-owned by timemachine.

`drwx------  2 timemachine  timemachine  3 Apr 17 10:54 /data/timemachine/`

Permissions on the directory have been tested at 0700 and 0777 with no change in results.

On my macbook, in Finder I'm able to see the Time Machine share being broadcast like expected. I can open it, authenticate as the timemachine user, and write to the directory. I've verified that the files are created on the server just as I would expect.

In the Time Machine menu when I go to Add Disk, it also appears as a valid Time Machine target just as I would expect. I connect to it, authenticate, and it looks like it's ready to back up. But when it begins, it just throws an error saying "Time Machine couldn't back up to SERVER.local"

The logs on the mac show the following:

```
2021-04-17 10:52:36  Starting manual backup

2021-04-17 10:52:36  Attempting to mount 'smb://timemachine@SERVER._smb._tcp.local./Time%20Machine'


2021-04-17 10:52:40  Mounted 'smb://timemachine@SERVER._smb._tcp.local./Time%20Machine' at '/Volumes/.timemachine/SERVER_smb._tcp.local./3322C5F6-7936-47B1-9EC7-42D3972AA8A7/Time Machine'

2021-04-17 10:52:40  Initial network volume parameters for 'Time Machine' {disablePrimaryReconnect: 0, disableSecondaryReconnect: 0, reconnectTimeOut: 60, QoS: 0x0, attributes: 0x1C}

2021-04-17 10:52:40  Configured network volume parameters for 'Time Machine' {disablePrimaryReconnect: 0, disableSecondaryReconnect: 0, reconnectTimeOut: 30, QoS: 0x20, attributes: 0x1C}

2021-04-17 10:52:41  Mountpoint '/Volumes/.timemachine/SERVER._smb._tcp.local./3322C5F6-7936-47B1-9EC7-42D3972AA8A7/Time Machine' is still valid

2021-04-17 10:52:41  Mountpoint '/Volumes/.timemachine/SERVER._smb._tcp.local./3322C5F6-7936-47B1-9EC7-42D3972AA8A7/Time Machine' is still valid

2021-04-17 10:52:41  Creating a sparsebundle using Case-sensitive APFS filesystem

2021-04-17 10:52:41  Failed to create '/Volumes/.timemachine/SERVER._smb._tcp.local./3322C5F6-7936-47B1-9EC7-42D3972AA8A7/Time Machine/1EA0B124-7090-5391-8CDF-2267673EB331.sparsebundle', results: {

2021-04-17 10:52:43  Backup failed (20: BACKUP_FAILED_DISK_IMAGE_NOT_CREATED)
```

I'm at a loss. I can't figure out why Time Machine can see it but not use it, while I'm still able to use it like a normal share.


----------



## Deleted member 67440 (Apr 17, 2021)

Already tried an APFS file-based image, then a tmutil setdestination, instead of the Samba 4.8+ Time Machine support?


> Failed to create '/Volumes/.timemachine/SERVER._smb._tcp.local./3322C5F6-7936-47B1-9EC7-42D3972AA8A7/Time Machine/1EA0B124-7090-5391-8CDF-2267673EB331.sparsebundle', results: {


You can make a fixed-sized Mac OS Extended (Journaled) image, an APFS filesystem, by "hand"

I don't often use Mac, maybe new versions of the operating system understand when you try to write to an smb share and do it by themselves.
EDIT: newer Samba should do it
However, nothing prevents you from trying "manually"


----------



## puppyboy (Apr 17, 2021)

fcorbelli said:


> Already tried an APFS file-based image, then a tmutil setdestination, instead of the Samba 4.8+ Time Machine support?



No, but I was wanting this to be done just with samba from my fileserver just so I can have a central target for all my Macs.

Fortunately, as often seems to happen, immediately after posting this I think I found my solution. I added "zfsacl" to the vfs objects line, and it seems to work now. It failed at first but then when I tried to kick it off again it worked, and my backup is now running.


----------



## RypPn (Apr 17, 2021)

Lifted from my working setup


```
[global]
fruit:aapl = yes
fruit:nfs_aces = yes
fruit:copyfile = no
fruit:model = MacSamba

[TimeMachine]
    vfs objects = acl_xattr catia fruit streams_xattr
    fruit:resource = file
    fruit:time machine = yes
    fruit:time machine max size = 150G
    fruit:metadata = netatalk
    fruit:locking = netatalk
    fruit:encoding = native
        path = /your/path
        valid users = <your_user>
        public = no
        writable = yes
        printable = no
        create mask = 0664
        directory mask = 0755
```



			vfs_fruit


----------

