Last active
October 5, 2016 17:17
-
-
Save concubidated/28178afa1434270db86325cd488552d1 to your computer and use it in GitHub Desktop.
Delete with s3cmd, X at a time in BG.
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 | |
CONFIG="/etc/pod/.s3cfg-live" | |
BUCKET="live" | |
NUM_DELETES=20 | |
CHANNELS=$(s3cmd -c $CONFIG ls s3://$BUCKET/ | grep DIR | awk -F'/' '{print $4}') | |
i=0 | |
TOTAL=0 | |
for CHAN in $CHANNELS | |
do | |
echo "Deleting $CHAN" | |
EPOCH_GROUP=$(s3cmd -c $CONFIG ls s3://$BUCKET/$CHAN/ | grep DIR | awk -F'/' '{print $5}') | |
for GROUP in $EPOCH_GROUP | |
do | |
echo "Deleting $GROUP" | |
#delete group | |
s3cmd -c $CONFIG rm --recursive s3://live/$CHAN/$GROUP/ >> deletelog.log & | |
i=$((i+1)) | |
TOTAL=$((TOTAL+1)) | |
if [ "$i" -ge "$NUM_DELETES" ] | |
then | |
#wait for bath to finish deleting in BG | |
wait; | |
i=0; | |
fi | |
done | |
echo $TOTAL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment