Skip to content

Instantly share code, notes, and snippets.

@movitto
Created August 28, 2019 20:49
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 movitto/e6d68a8a16a47e6a43c5b7acb9b28d52 to your computer and use it in GitHub Desktop.
Save movitto/e6d68a8a16a47e6a43c5b7acb9b28d52 to your computer and use it in GitHub Desktop.
Remove all LVM Snapshots with a certain prefix
#!/bin/bash
# Remove all LVM Snapshots
# Set executable: chmod +x lvmbak.sh
VG="dnp00" # LVM volume group we are snapshoting
BACKUP_PREFIX="dnv1-snap-" # Prefix of snapshot volume name.
/sbin/lvs -o lv_name --noheadings | sed -n "s@$BACKUP_PREFIX@@p" | while read DATE; do
if [ "$DATE" ]; then
VOLNAME="$BACKUP_PREFIX$DATE"
/sbin/lvremove -f "$VG/$VOLNAME"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment