Created
January 22, 2017 01:53
-
-
Save lincolnthomas/50906cfc2ec4c2bb75552c468278a719 to your computer and use it in GitHub Desktop.
Scripts to create / delete lots of snapshots
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
Create a lot of snaps, serially or in parallel: | |
snaps-create.sh | |
====================== | |
#!/bin/bash | |
set -x | |
VOLUME=$1 | |
NUMSNAPS=$2 | |
PARALLEL=$3 | |
echo Creating $NUMSNAPS snapshots on volume $VOLUME | |
if [ -n "$PARALLEL" ]; then | |
echo Will run commands in parallel | |
else | |
echo Will run commands serially | |
fi | |
for ((i=1; i<=$NUMSNAPS; i++)) ; do | |
echo "Creating snapshot $i" | |
COMMAND="euca-create-snapshot $VOLUME" | |
if [ -n "$PARALLEL" ]; then | |
$COMMAND & | |
else | |
$COMMAND | |
fi | |
done | |
====================== | |
Example usage, creating 10 snapshots on each of 3 volumes already created, all in parallel (remove 'y' params to do serially instead): | |
# snaps-create.sh vol-e7d3f9fa 10 y & snaps-create.sh vol-1c77102b 10 y & snaps-create.sh vol-3f61d26a 10 y | |
Deleting all snapshots for all volumes: (careful!) | |
snaps-delete.sh | |
====================== | |
#!/bin/bash | |
#set -x | |
while true ; do | |
snapshot=$(euca-describe-snapshots | head -1 | awk '{ print $2 }' | tr -d "\n") | |
if [ -z "$snapshot" ] ; then break; fi | |
echo "Deleting snapshot $snapshot" | |
euca-delete-snapshot $snapshot | |
done | |
====================== | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment