Skip to content

Instantly share code, notes, and snippets.

@Devp00l
Created December 16, 2019 16:50
Show Gist options
  • Save Devp00l/2473f5953d578f440fc71b3d602a9c23 to your computer and use it in GitHub Desktop.
Save Devp00l/2473f5953d578f440fc71b3d602a9c23 to your computer and use it in GitHub Desktop.
A way to delete all CephFS snapshots in a given directory
#!/bin/bash
#$1 = CephFS directory
# Snapshots starting with underscore names are related to snapshots based in a higher directory and can't be used.
# Therefore they are filterd out with `grep`
find $1 -type d | while read i; do
ls --color=none $i/.snap | while read j; do
echo $i/.snap/$j
done
done | grep --color=never ".snap/[^_]" | xargs rmdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment