Last active
February 3, 2022 17:36
-
-
Save hypevhs/2a6aae780f5e15032e623c82e7f5b354 to your computer and use it in GitHub Desktop.
estimate space actually used by snapshots of a dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# vim:set et sw=2 ts=2: | |
# estimate space actually used by snapshots of a dataset | |
# original by https://www.reddit.com/r/zfs/comments/bzo817/running_out_of_space_easy_way_to_visualize/er0ccbe/ | |
# edits by me | |
# NO WARRANTY | |
set -euxo pipefail | |
here="$(realpath "$1")" | |
{ echo -e "NAME\tRECLAIM"; | |
for snapshot in $(zfs list -Hpr "$here" -t snapshot -o name -s creation -d 1); do | |
echo -ne "$snapshot\t" | |
zfs destroy -nv "${snapshot/@/@%}" | sed -nre "s/would reclaim (.+)/\1/p" | |
done } | column -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment