Score:0

Samba shadow_copy2 and snapshots don't appear in windows

tc flag

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

Score:0
tc flag

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 = *,*.*,.*,.*.* 
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.