Created
May 20, 2018 01:42
-
-
Save bsodmike/5f3194cff203a4cb44b568a9b2c75f35 to your computer and use it in GitHub Desktop.
FreeNAS ZFS delete snapshots retaining the last 'N' only.
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
#!/bin/bash | |
# Retain last 10 snapshots only. | |
set -e | |
zfs list -t snapshot -o name -S creation | grep ^big/media@auto | tail -n +10 | xargs -n 1 zfs destroy -vr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dry run with
xargs -n 1 echo
Ref: https://serverfault.com/a/340846