1

I'm setting up Ubuntu server with Samba. The file system is BTRFS and I can't seem to get Windows to see the previous versions from the snapshots.

My smb.conf has this for the share:

[Backup]
    path = /mnt/pool1/backup
    comment = Share for backups
    writeable = yes
    delete readonly = yes
    browseable = yes
vfs object = recycle shadow_copy2

recycle:repository = /mnt/pool1/backup/.recycle/%U
recycle:touch = Yes
recycle:keeptree = Yes
recycle:versions = Yes
recycle:noversions = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
recycle:exclude = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
recycle:excludedir = /.recycle,/tmp,/temp,/TMP,/TEMP

shadow:snapdir = /mnt/pool1/snapshots/backup
shadow:basedir = /mnt/pool1/backup
shadow:sort = desc
shadow:format = GMT-%Y.%m.%d-%H.%M.%S

The directory structure is as follows: the BTRFS volume is mounted at /mnt/pool1 and the shares and snapshot directory are at this level:

ll /mnt/pool1
total 20
drwxr-xr-x 1 root root    98 Jul 14 09:14 ./
drwxr-xr-x 4 root root  4096 Jul 14 09:13 ../
drwxrwxr-x 1 root users   74 Jul 14 11:28 backup/
drwxrwxr-x 1 root users    0 Jul 13 16:50 docker/
drwxrwxr-x 1 root users    0 Jul 13 16:49 homes/
drwxrwxr-x 1 root users    0 Jul 13 16:51 install/
drwxrwxr-x 1 root users    0 Jul 13 16:51 media/
drwxrwxr-x 1 root users   80 Jul 13 16:58 snapshots/
drwxrwxr-x 1 root users    0 Jul 13 16:51 timemachine/

ll /mnt/pool1/snapshots total 16 drwxrwxr-x 1 root users 80 Jul 13 16:58 ./ drwxr-xr-x 1 root root 98 Jul 14 09:14 ../ drwxrwxr-x 1 root users 184 Jul 14 11:55 backup/ drwxrwxr-x 1 root users 0 Jul 13 16:58 docker/ drwxrwxr-x 1 root users 0 Jul 13 16:58 homes/ drwxrwxr-x 1 root users 0 Jul 13 16:58 install/ drwxrwxr-x 1 root users 0 Jul 13 16:58 media/ drwxrwxr-x 1 root users 0 Jul 13 16:58 timemachine/

The structure in use is that the snapshots directory has a sub-directory per share. You can see the file names on the snapshots I already have:

tree -a
.
├── backup
│   ├── .recycle
│   │   └── ubuntu
│   │       └── File from windows - Copy.txt
│   ├── File from windows.txt
│   └── test.txt
├── docker
├── homes
├── install
├── media
├── snapshots
│   ├── backup
│   │   ├── GMT-2023.07.14-09.19.31
│   │   │   └── test.txt
│   │   ├── GMT-2023.07.14-09.30.57
│   │   │   └── test.txt
│   │   ├── GMT-2023.07.14-09.57.41
│   │   │   └── test.txt
│   │   └── GMT-2023.07.14-10.48.31
│   │       └── test.txt
│   ├── docker
│   ├── homes
│   ├── install
│   ├── media
│   └── timemachine
└── timemachine

I can find nothing in the logs to help investigate this and there doesn't seem to be any way to diagnose what the issue from the server side. Can anyone suggest what might be wrong here please or how I can get more diagnostic information? Many thanks, Arthur

1 Answers1

1

I've spent a lot of time on this and finally got to a solution. Details are here:https://github.com/ArthurMitchell42/BTRFS_Snapshots including an example script to generate he snapshots in the correct way.

The key settings for smbd.conf are:

[global]
   vfs object = recycle shadow_copy2 btrfs fruit cap catia

recycle:repository = /mnt/pool1/%S/.recycle/%U recycle:touch = Yes recycle:keeptree = Yes recycle:versions = Yes recycle:noversions = .tmp,.temp,.o,.obj,.TMP,.TEMP recycle:exclude = .tmp,.temp,.o,.obj,.TMP,.TEMP recycle:excludedir = /.recycle,/tmp,/temp,/TMP,/TEMP

; shadow:localtime = yes shadow:sort = desc shadow:format = GMT-%Y.%m.%d-%H.%M.%S shadow:snapprefix = ^[A-Za-z0-9_]{0,}$ shadow:delimiter = GMT-

NOTE shadow:localtime must be commented out or you will see nothing and in each share:

[Media]
   path = /mnt/pool1/Media
   shadow:snapdir = /mnt/pool1/.snapshots/Media
   shadow:basedir = /mnt/pool1/Media
    comment = Music, video and books
    writeable = yes 
    delete readonly = yes 
    browseable = yes
;    recycle:exclude = *,*.*,.*,.*.*