zsd - Quickly destroys a specified amount of ZFS snapshots
] --keep number-of-snapshots
] --keep number-of-snapshots
] --destroy number-of-snapshots
(ZFS snapshot destroyer) is a zfs
(8) wrapper to destroy a
number of snapshots on a given dataset using a more convenient interface.
The number of snapshots to destroy can be specified directly, or indirectly by
specifying the number of snapshots that should be kept. Snapshots are
destroyed in the (by default chronological) order they are listed by zfs
goes nicely with zogftw's
to grow a certain number of
snapshots on new backup datasets while keeping the number of snapshots on old
backup datasets constant.
is mainly developed and tested using OpenZFS on FreeBSD, but is
expected to work on other platforms as well.
If enough snapshots are available, destroy
snapshots until reaching either the specified number or the number of
snapshots to keep specified with --keep
. If --keep
one snapshot is kept so receival of incremental snapshots continues to work.
(8) list the available
snapshots sorted by name which is a lot faster (on FreeBSD) as less metadata
has to be read. This should only be used if the order in which snapshots are
destroyed doesn't matter or if sorting the snapshots by name keeps the
Fork a process for each snapshots that should be
destroyed and don't check if the operation is successful. If the ZFS pool
is unsupported or disabled, this is generally
faster than destroying the snapshots one-by-one. The downside is that it
requires more memory and that errors are ignored.
Destroying too many snapshots at the same time can cause some FreeBSD versions
to become unresponsive under some conditions and rebooting the system a couple
of times may take longer than destroying the snapshots one-by-one. You may
want to experiment with this option before using it in production
When used without --destroy
enough snapshots are available, snapshots are destroyed until the given number
of snapshots is reached. If the option is used together with --destroy
it specifies the number of snapshots that should be kept.
Show how many snapshots would be destroyed if the option
wasn't being used, but don't actually destroy them.
Be more verbose. When specified once, the destroyed snapshots
are shown. When specified twice, the kept snapshots are shown as well.
All options can be shortened as long as there are no ambiguities.
The following examples are independent and assume a dataset tank/blafasel
with 100 snapshots.
zsd --destroy 10 tank/blafasel
Destroys 10 snapshots.
zsd --destroy 100 tank/blafasel
Destroys 99 snapshots as
not using --keep
implies that at least one snapshot should be kept.
zsd --destroy 100 --keep 0 tank/blafasel
all the 100 snapshots as no snapshot has to be kept.
zsd -d 100 -k 0 tank/blafasel
Same as the above, but
requires less typing.
zsd --destroy 100 --keep 40 tank/blafasel
60 snapshots as 40 snapshots have to be kept.
zsd --destroy 10 --keep 40 tank/blafasel
snapshots, keeping 90 as 40 is only the lower limit.
zsd -d 20 -k 20 -n tank/blafasel
many snapshots would be destroyed without -n
zsd --destroy 100 --keep 200 tank/blafasel
no snapshot as the number of snapshots to keep is above the number of
snapshots available on the dataset.
zsd --keep 10 tank/blafasel
Destroys 90 snapshots as not
implies that all the snapshots above the limit should
Fabian Keil <email@example.com>