Is there a way to restore a folder completely deleted from s3?

0

Someone from my team deleted by accident a whole folder from an s3 bucket (root directory). We have versioning enabled. Is there a way to restore this folder?

Currently, the folder doesn't appear when I enable "show versions".

Regards,

Diego
asked 17 days ago82 views
6 Answers
1

Hello,

Since versioning was enabled on the S3 bucket, the folder and all its contents should still be retrievable even after deletion. When an object is deleted from a versioned bucket, S3 doesn't permanently remove it but rather inserts a delete marker to indicate it was deleted.

You can try listing the object versions for the bucket to see if you can locate the folder. The

aws s3api list-object-versions

command would show all versions including any delete markers. You may be able to identify the folder by name or last modified time.

If the folder is present but marked as deleted, you can make it current again by removing the delete marker. The

aws s3api delete-object --object <folder-name> --version-id <delete-marker-id>

the command would do this.

For some extra information:

https://repost.aws/knowledge-center/s3-retrieve-deleted-object

profile picture
Julian
answered 17 days ago
profile picture
EXPERT
reviewed 17 days ago
1

When you empty a bucket that has S3 Versioning enabled or suspended, all versions of all the objects in the bucket are deleted.

https://docs.aws.amazon.com/AmazonS3/latest/userguide/empty-bucket.html

profile picture
Julian
answered 17 days ago
profile picture
EXPERT
reviewed 17 days ago
1

You can utilize CloudTrail to review logs and determine which user performed the "empty bucket" action. Additionally, if you have Amazon S3 backups configured in your account, you can restore the deleted folder at any time. However, this feature must be enabled beforehand. For more information on setting up S3 backups, please visit the AWS documentation: AWS S3 Backups.

profile picture
EXPERT
answered 17 days ago
0

Thanks for your answer. It seems that the user that "deleted" this files through selecting it on the web console, and pressing the "empty" Button. I comment this because I don't seem to be able to find those files.

Diego
answered 17 days ago
0

It may also be possible that the user has permanently deleted the folder that already had a delete marker.

Here is my Console, I have created a sample folder with versioning, and deleted it by adding a delete marker. And I can still see it when I turn on show versions.

S3 Console

Enter image description here

profile picture
Julian
answered 17 days ago
0

It seems that since the files were deleted through "empty bucket", the files get permanently deleted.

This would be the issue that is causing us not to be able to find the files.

I'm not sure if this is true though.

Diego
answered 17 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions