This was much trickier than I had originally anticipated and have spent a few hours testing.
The config from samba wiki absolutely works, but it wasn't ranked higher in search engine and it's not general enough. https://github.com/zfsonlinux/zfs-auto-snapshot/wiki/Samba
Tested on ubuntu 22.04LTS, samba 4.15.9 and windows 11.
If you snapshot utility labels the snapshot in a format other than [wildcard][timestmap], it's unlikely that it will work.
sanoid and zfsnap both have dynamic labels after the timestamp, so they won't work.
The default names for zfs-auto-snapshot is zfs-auto-snap_[label]_%Y-%m-%d-%H%M. This is the minimal viable config.
vfs_objects = shadow_copy2
shadow:snapdir = .zfs/snapshot
shadow:snapprefix = .*
shadow:delimiter = -20
shadow:format = -%Y-%m-%d-%H%M
Optional:
shadow:snapdirseverywhere = yes
Don't try to get creative, shadow_copy2 is extremely particular.
-20works as NULL forshadow:delimiter. I haven't found anything else that worked in its place. Dashes, hypens, regex patterns, alpha only strings, quoted, empty quotes, etc etc.- removing the leading
-fromshadow:format. - Using regex anywhere besides
shadow:snapprefix - Quoting your parameter
shadow:snapprefix = zfs-auto-snap_hourly
shadow:delimiter = -
shadow:format = %Y-%m-%d-%H%M
shadow:snapprefix = zfs-auto-snap
shadow:delimiter = _hourly-
shadow:format = %Y-%m-%d-%H%M
shadow:snapprefix = zfs-auto-snap_
shadow:delimiter = hourly
shadow:format = -%Y-%m-%d-%H%M
shadow:format = .*-%Y-%m-%d-%H%M
The original config from samba wiki, but won't generalize for other snapshot naming pattern.
vfs objects = shadow_copy2
shadow:snapdir = .zfs/snapshot
shadow:format = -%Y-%m-%d-%H%M
shadow:snapprefix = ^zfs-auto-snap_\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}
shadow:delimiter = -20
If you don't need regex/wildcards, then using just hard code everything in shadow:format.
vfs objects = shadow_copy2
shadow: snapdir = .zfs/snapshot
shadow: sort = desc
shadow: format = zfs-auto-snap_hourly-%Y-%m-%d-%H%M
sanoiduses:in the snapshot names,vfs objects = catiaand some extra catia config is needed for the folders under the hidden.zfsto display properly.- Using some of the
shadowoptions will force you to specify another option. For example:snapprefixandsnapdir. Read the manpage carefully. - The
zfs-auto-snapshotpackage from ubuntu installs cron jobs in/etc/cron.d,/etc/cron.hourly, and etc.
I spent too much time trying to make it work myself and with LLMs.
At the end, was just feeding the LLM with configs and logs, hoping at least those could understand what's wrong.
Finally, I fed my configs to LLMs alongside with those notes, and it just gave me the fix on the first try.
Thanks, man!