How to delete all ZFS snapshots before a given date.

You can identify which snapshots are taking up real space by using:

zfs list -o space -r [pool_name]

The column 'USEDSNAP' is the total space consumed by snapshots for that dataset.

Count the number of snapshots between now and cut-off period. List snapshots from newest to oldest and trim with `head` - the last line is your cut-off date.

zfs list -H -t snapshot -o name -S creation -r [pool_name]/[dataset] | head -n10

List all snapshots of the dataset, in reverse, and trim the required top amount of listed snapshots (inverse tail).

The example below keeps only the last 10 snapshots (10 days if done daily, 0.5 day if done hourly).

zfs list -H -t snapshot -o name -S creation -r [pool_name]/[dataset] | tail +10 | xargs -n 1 zfs destroy -np

* use -np to "dry-run"
* use -vr to recursively remove with output