Created
October 5, 2016 16:41
-
-
Save concubidated/2d272aa2a2c6a5b8b2e48df75b1bed44 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/.s3cf-live" | |
BUCKET="live" | |
NUM_DELETES=5 | |
CHANNELS=$(s3cmd -c $CONFIG ls s3://$BUCKET/ | grep DIR | awk -F'/' '{print $4}') | |
i=0 | |
TOTAL=0 | |
for CHAN in $CHANNELS | |
do | |
EPOCH_GROUP=$(s3cmd -c $CONFIG ls s3://$BUCKET/$CHAN/ | grep DIR | awk -F'/' '{print $5}') | |
for GROUP in $EPOCH_GROUP | |
do | |
#delete group | |
echo "s3cmd -c $CONFIG rm --recursive s3://live/$CHAN/$GROUP/ &" | |
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