Forked from weavenet/delete_all_object_versions.sh
Last active
April 11, 2017 17:50
-
-
Save joekiller/d5b1955db37bbbd61f91630e4aae6489 to your computer and use it in GitHub Desktop.
Revisions
-
joekiller revised this gist
Apr 11, 2017 . 1 changed file with 7 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ if [ $count -gt -1 ]; then versionId=`echo $versions | jq .[$i].VersionId |sed -e 's/\"//g'` cmd="aws s3api delete-object --bucket $bucket --key $key --version-id $versionId" echo $cmd $cmd & done fi @@ -31,6 +31,10 @@ if [ $count -gt -1 ]; then versionId=`echo $markers | jq .[$i].VersionId |sed -e 's/\"//g'` cmd="aws s3api delete-object --bucket $bucket --key $key --version-id $versionId" echo $cmd $cmd & done fi for job in $(jobs -p); do wait $job done -
Brett W. created this gist
May 4, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ #!/bin/bash bucket=$1 set -e echo "Removing all versions from $bucket" versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'` markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'` let count=`echo $versions |jq 'length'`-1 if [ $count -gt -1 ]; then echo "removing files" for i in $(seq 0 $count); do key=`echo $versions | jq .[$i].Key |sed -e 's/\"//g'` versionId=`echo $versions | jq .[$i].VersionId |sed -e 's/\"//g'` cmd="aws s3api delete-object --bucket $bucket --key $key --version-id $versionId" echo $cmd $cmd done fi let count=`echo $markers |jq 'length'`-1 if [ $count -gt -1 ]; then echo "removing delete markers" for i in $(seq 0 $count); do key=`echo $markers | jq .[$i].Key |sed -e 's/\"//g'` versionId=`echo $markers | jq .[$i].VersionId |sed -e 's/\"//g'` cmd="aws s3api delete-object --bucket $bucket --key $key --version-id $versionId" echo $cmd $cmd done fi