Created
February 7, 2021 10:08
-
-
Save deogracia/f23b7957a8b4af972ff495a11a4d7d06 to your computer and use it in GitHub Desktop.
undelete files from a deleted directory, s3 bucket with versioning enabled
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
# taken from https://superuser.com/a/1019940 | |
MY_BUCKET=yourbucket-name | |
MY_PREFIX=my-directory | |
echo '#!/usr/bin/env bash' > undeleteScript.sh && aws --output text s3api list-object-versions --bucket ${MY_BUCKET} --prefix ${MY_PREFIX} | grep -E "^DELETEMARKERS" | awk '{FS = "[\t]+"; print "aws s3api delete-object --bucket ${MY_BUCKET} --key \42"$3"\42 --version-id "$5";"}' >> undeleteScript.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment