I'm trying to remove the current marker from AWS S3 in order to restore a previous version. I have plenty of files to delete. But when using the following command, yes or no prompt is triggered. Is there any way to avoid this prompt?
aws s3api list-object-versions --bucket my_bucket --output json --query 'DeleteMarkers[].[Key, VersionId]' --region us-east-1 | jq -r '.[] | "--key '\''" + .[0] + "'\'' --version-id " + .[1]' | xargs -p -L1 aws s3api delete-object --bucket my_bucket --region us-east-1
Following is the sample output for this script.
aws s3api delete-object --bucket my_bucket --region us-east-1 --key 58a7ec1f77dd6e3ff3024a65/1487498355//39.jpeg --version-id _VY88LfKX3tXy2JABbC6rhDzKl3xhkg0 ?...
Here we need to give "y" as the answer. Then next prompt will be triggered. The issue is I have 800,000 files to do the same operation.
Now I'm using the following command.
echo '#!/bin/bash' > undeleteScript.sh && aws --output text s3api list-object-versions --bucket my_bucket | grep -E "^DELETEMARKERS" | awk '{FS = "[\t]+"; print "aws s3api delete-object --bucket my_bucket --key \42"$3"\42 --version-id "$5";"}' >> undeleteScript.sh && . undeleteScript.sh; rm -f undeleteScript.sh;
But, this seems to be very slow. Any other commands to make this easy & quick?