大网数据广告活动
服务器运维问答

Samba shadow_copy2 and snapshots don't appear in windows

· 52CE 我爱测

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 = Sh…

问题原文

原帖链接 · Arthur Mitchell · CC BY-SA 4.0

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

已采纳解答

原帖链接 · Arthur Mitchell · CC BY-SA 4.0

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 = *,*.*,.*,.*.* 

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-07-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。