bdrewery / zfstools

Various ZFS scripts. Most notably, zfs-auto-snapshot, a ruby clone of OpenSolaris auto snapshotting
Other
141 stars 29 forks source link

Misclassification of parent dataset as 'recursive' #45

Open haasn opened 3 years ago

haasn commented 3 years ago
$ zfs list -rt filesystem -o name,mounted,com.sun:auto-snapshot media
NAME                MOUNTED  COM.SUN:AUTO-SNAPSHOT
media               yes      true
media/movies        no       true
media/movies/anime  yes      true
media/movies/big    yes      true
media/movies/yt     yes      true
$ zfs-auto-snapshot -n -v hourly 24 -P media
zfs snapshot -r media@zfs-auto-snap_hourly-2021-04-27-10h53
zfs snapshot -r media/movies/anime@zfs-auto-snap_hourly-2021-04-27-10h53
zfs snapshot -r media/movies/big@zfs-auto-snap_hourly-2021-04-27-10h53
zfs snapshot -r media/movies/yt@zfs-auto-snap_hourly-2021-04-27-10h53

Because media/movies is not mounted, it decides to create the leaf children's snapshots recursively. (Which is an... interesting design decision, to not snapshot unmounted filesystems)

However, it fails to treat the parent (media) as non-recursive. This results in the creation (but not subsequent deletion) of snapshots in media/movies:

$ zfs list -t snapshot media/movies | wc -l
3989

If I may ask, why all this.. sophistication, especially given that it's (clearly) brittle and results in bugs? What's wrong with treating every dataset as independent and issuing a zfs snapshot per dataset?