[Samba] Shadow Copy2 & zfs Snapshots

lists.samba.org at sjau.ch lists.samba.org at sjau.ch
Thu May 28 07:15:28 UTC 2020


Hi there

I did investigate the problem a bit more. I also setup a test server and 
a test vm (for windows) and then I used a live data example, copied it 
to the test server including snapshots. After each test I did roll back 
the snapshots to 2020-05-27 13:00 UTC.

The snapshots existing in the test server for that dataset until 
yesterday when I run the tests can be found here 
https://paste.simplylinux.ch/view/raw/f01a7654 ) as well as the 
(current) output of /shadowcopy2/.zfs/snapshot done with a simple ls -al 
( https://paste.simplylinux.ch/view/raw/b8f4ab4f ).

At the end you'll find the full /etc/samba/smb.conf file content.


For the test I did create 3 different shares. One that doesn't use the 
prefix at all (sc2norm), one that uses the prefix but is not using BRE 
(sc2snap) and one that uses the snap prefix with BRE (sc2bre).

I also tested with enforcing SMB3 but that did not have any effect. In 
the samba config I just allow VPN IPs to access the server and the 
shares for this test setup, so no additional security measures were taken.

In the Windows VM I just mounted the shares with a cmd.exe terminal and run:

net use n: \\IP-OF-TEST-SERVER\sc2norm
net use o: \\IP-OF-TEST-SERVER\sc2snap
net use p: \\IP-OF-TEST-SERVER\sc2bre

For each of the shares I did first check one specific file and 
screenshotted the "old versions" listed in Windows. Then I edited that 
file and took another screenshot.



When using the sc2norm share, I got the following results:

  [sc2norm]
  browseable = yes
  create mask = 0644
  directory mask = 0755
  guest only = yes
  hosts allow = 127.0.0.1, 10.10.20.0/24
  path = /shadowcopy2
  read only = no
  shadow:format = easysnap-hourly_%Y-%m-%d-%H-%M-UTC
  shadow:localtime = yes
  shadow:snapdir = .zfs/snapshot
  shadow:sort = desc
  vfs objects = shadow_copy2

- Searching for old versions did show all previous edits on the file: 
https://images.sjau.ch/img/320efef3.png
- After editing it and doing a search again, it did show a new previous 
version: https://images.sjau.ch/img/a98e6e08.png



When using the snapprefix but no BRE, I got the following results:

  [sc2snap]
  browseable = yes
  create mask = 0644
  directory mask = 0755
  guest only = yes
  hosts allow = 127.0.0.1, 10.10.20.0/24
  path = /shadowcopy2
  read only = no
  shadow:delimiter = _
  shadow:format = _%Y-%m-%d-%H-%M-UTC
  shadow:localtime = yes
  shadow:snapdir = .zfs/snapshot
  shadow:snapprefix = ^easysnap-hourly
  shadow:sort = desc
  vfs objects = shadow_copy2

- Searching for old versions did not show all the previous edits on the 
file: https://images.sjau.ch/img/449eabcc.png --> several edits from 
2020-05-26 are missing
- After editing it and doing a search again, it did show the last edit 
also, but still missing edits from 2020-05-26: 
https://images.sjau.ch/img/00ea231e.png



When using the snapprefix with BRE, I got the same results as without BRE:

[sc2bre]
  browseable = yes
  create mask = 0644
  directory mask = 0755
  guest only = yes
  hosts allow = 127.0.0.1, 10.10.20.0/24
  path = /shadowcopy2
  read only = no
  shadow:delimiter = _
  shadow:format = _%Y-%m-%d-%H-%M-UTC
  shadow:localtime = yes
  shadow:snapdir = .zfs/snapshot
  shadow:snapprefix = 
^easysnap-\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}
  shadow:sort = desc
  vfs objects = shadow_copy2


- Searching for old versions did not show all the previous edits on the 
file: https://images.sjau.ch/img/07962cc8.png --> several edits from 
2020-05-26 are missing
- After editing it and doing a search again, it did show the last edit 
also, but still missing edits from 2020-05-26: 
https://images.sjau.ch/img/a89ab810.png



Also in earlier tests with other datasets I noticed a strange behaviour 
that I couldn't replicated otherwise: When using snapprefix with BRE and 
searching for old version, it did list some (not all) old versions. 
After editing the file and doing the search again, it did not show any 
old versions at all. I have encountered that serveral times but have 
been unable to replicated this behaviour consistently.



smb.conf:

[global]
security = user
passwd program = /run/wrappers/bin/passwd %u
pam password change = false
invalid users = root
#            protocol = SMB3
             server string = NixTesti
             workgroup = WORKGROUP
             hosts allow = 127.0.0.1, 10.10.20.0/24
             map to guest = bad user


[sc2bre]
  browseable = yes
  create mask = 0644
  directory mask = 0755
  guest only = yes
  hosts allow = 127.0.0.1, 10.10.20.0/24
  path = /shadowcopy2
  read only = no
  shadow:delimiter = _
  shadow:format = _%Y-%m-%d-%H-%M-UTC
  shadow:localtime = yes
  shadow:snapdir = .zfs/snapshot
  shadow:snapprefix = 
^easysnap-\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}
  shadow:sort = desc
  vfs objects = shadow_copy2
  [sc2norm]
  browseable = yes
  create mask = 0644
  directory mask = 0755
  guest only = yes
  hosts allow = 127.0.0.1, 10.10.20.0/24
  path = /shadowcopy2
  read only = no
  shadow:format = easysnap-hourly_%Y-%m-%d-%H-%M-UTC
  shadow:localtime = yes
  shadow:snapdir = .zfs/snapshot
  shadow:sort = desc
  vfs objects = shadow_copy2
  [sc2snap]
  browseable = yes
  create mask = 0644
  directory mask = 0755
  guest only = yes
  hosts allow = 127.0.0.1, 10.10.20.0/24
  path = /shadowcopy2
  read only = no
  shadow:delimiter = _
  shadow:format = _%Y-%m-%d-%H-%M-UTC
  shadow:localtime = yes
  shadow:snapdir = .zfs/snapshot
  shadow:snapprefix = ^easysnap-hourly
  shadow:sort = desc
  vfs objects = shadow_copy2

On 18.05.20 06:13, lists.samba.org--- via samba wrote:
> Hi there
> 
> I'm having some troubles with Shadow Copy2 & zfs Snapshots. I have 
> hourly and daily snapshots. If I use the following settings it works 
> (but omits daily snapshots):
> 
>   vfs objects = shadow_copy2
>   shadow:snapdir = .zfs/snapshot
>   shadow:sort = desc
>   shadow:localtime = yes
>   shadow:format = easysnap-hourly_%Y-%m-%d-%H-%M-UTC
> 
> However when I try to use the BRE with the prefix, so that daily and 
> hourly snapshots would be included, it won't work (no previous old 
> versions being shown in Windows file properties):
> 
>   vfs objects = shadow_copy2
>   shadow:snapdir = .zfs/snapshot
>   shadow:sort = desc
>   shadow:localtime = yes
>   shadow:format = _%Y-%m-%d-%H-%M-UTC
>   shadow:snapprefix = ^easysnap-\(hourly\)\{0,1\}\(daily\)\{0,1\}
>   shadow:delimiter = _
> 
> Any suggestions why it won't work with the BRE?
> 
> sjau
> 



More information about the samba mailing list