
You deleted an object from a production Amazon S3 bucket. The bucket enables versioning. This section explains how to retrieve the object.
Amazon S3 uses delete markers in versioned buckets. When you delete an object, S3 creates a delete marker. The marker becomes the current version. The original object becomes a previous version. S3 treats the object as deleted. GET requests return an error.

Update the script path to match your file location. Run the script.
CODE
01#! /bin/bash02# List of file paths to be restored!03arr=(s3://restoring_archived_bucket_test/rollups/user_id=1210/user_performance=rollups_i/yr=2020/month=9/day=2020-09-09/hour=all_hours/part-00000-28107112-478b-47ae-89cf-c71dc873e9c9.c000.snappy.parquet s3://restoring_archived_bucket_test/rollups/user_id=1210/user_performance=rollups_i/yr=2020/month=9/day=2020-09-10/hour=all_hours/part-00000-28107112-482c-47ae-89cf-c71dc873e9c9.c000.snappy.parquet)0405for i in "${arr[@]}"06do07 echo $i08 [[ $i =~ (s3://restoring_archived_bucket_test/)(.*) ]] # Modify bucket name09 prefix=${BASH_REMATCH[2]}10 version=`aws s3api list-object-versions --bucket restoring_archived_bucket_test --prefix $prefix --query 'Versions[0].VersionId' --output text` # Modify bucket name11 [[ $i =~ (s3://restoring_archived_bucket_test/)(.*)(all_hours/)(.*) ]] # Modify bucket name and last prefix of file path12 full_path=${BASH_REMATCH[1]}${BASH_REMATCH[2]}${BASH_REMATCH[3]}13 file_name=${BASH_REMATCH[4]}14 aws s3api get-object --bucket restoring_archived_bucket_test --key $prefix --version-id $version $file_name # Modify bucket name15 aws s3 cp $file_name $full_path16done

See related articles. Talk to our team.
Contact Us
