Skip to content

Instantly share code, notes, and snippets.

@bsodmike
Created May 20, 2018 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bsodmike/5f3194cff203a4cb44b568a9b2c75f35 to your computer and use it in GitHub Desktop.
Save bsodmike/5f3194cff203a4cb44b568a9b2c75f35 to your computer and use it in GitHub Desktop.
FreeNAS ZFS delete snapshots retaining the last 'N' only.
#!/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
@bsodmike
Copy link
Author

Dry run with xargs -n 1 echo

Ref: https://serverfault.com/a/340846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment