Created
May 29, 2015 06:29
-
-
Save prasincs/bb38e6049ce3938c9731 to your computer and use it in GitHub Desktop.
Removing Hbase 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
#!/bin/bash | |
function remove_bucket() { | |
s3cmd rm --force --recursive s3://$1 && s3cmd rb s3://$1 | |
} | |
dry_run=0 | |
HBASE_SNAPSHOT_BUCKETS=$(aws s3api list-buckets | jq -r ".Buckets[].Name" | grep "hbase-snapshots") | |
echo "About to delete the following buckets: $HBASE_SNAPSHOT_BUCKETS" | |
for bucket in $HBASE_SNAPSHOT_BUCKETS; do | |
echo "Checking $bucket" | |
if [ $dry_run == 1 ]; then | |
echo "Would Delete $bucket"; | |
else | |
read -p $'All contents in \e[1;33m'"$bucket"$'\e[0m will be deleted including the bucket. Do you want to continue?' -n 1 -r -e | |
if [[ ! $REPLY =~ ^[Yy]$ ]] | |
then | |
exit 1 | |
else | |
remove_bucket $bucket | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment