Created
August 28, 2019 20:49
-
-
Save movitto/e6d68a8a16a47e6a43c5b7acb9b28d52 to your computer and use it in GitHub Desktop.
Remove all LVM Snapshots with a certain prefix
This file contains hidden or 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 | |
# 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