Samba shadow_copy2 和快照不会出现在 Windows 中

Samba shadow_copy2 和快照不会出现在 Windows 中

我正在使用 Samba 设置 Ubuntu 服务器。文件系统是 BTRFS,我似乎无法让 Windows 从快照中看到以前的版本。

我的 smb.conf 有以下共享:

[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

目录结构如下:BTRFS 卷挂载在 /mnt/pool1,共享和快照目录位于此级别:

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/

使用的结构是快照目录每个共享都有一个子目录。您可以在我已有的快照上看到文件名:

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

我在日志中找不到任何有助于调查此事的信息,而且似乎没有任何方法可以从服务器端诊断问题所在。有人能建议这里可能出了什么问题吗,或者我如何获得更多诊断信息?非常感谢,Arthur

答案1

我花了很多时间才找到解决方案。详情如下:https://github.com/ArthurMitchell42/BTRFS_Snapshots包括以正确方式生成快照的示例脚本。

smbd.conf 的关键设置是:

[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-

笔记阴影:本地时间必须被注释掉,否则你将看不到任何内容,并且在每个共享中:

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

相关内容