Created
September 30, 2020 04:33
-
-
Save n2p5/b311a722619acb19162e26f991b9e5ea to your computer and use it in GitHub Desktop.
undelete s3 objects that are marked for delete from versioned s3
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
aws s3api list-object-versions \ | |
--bucket "${BUCKET}" \ | |
--prefix "${PREFIX}" \ | |
--output text | grep "DELETEMARKERS" | while read obj | |
do | |
KEY=$( echo "${obj}"| awk '{print "${3}"}') | |
VERSION_ID=$( echo "${obj}" | awk '{print "${5}"}') | |
echo "${KEY}" | |
echo "${VERSION_ID}" | |
aws s3api delete-object \ | |
--bucket "${BUCEKT}" \ | |
--key "${KEY}" \ | |
--version-id "${VERSION_ID}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment