How to retrieve a deleted object from AWS S3
In this article we can learn to the options to recover the deleted objects in S3 bucket and Best practices to avoid data loss.
Retrieving a deleted object from AWS S3 depends on whether you have versioning enabled on your S3 bucket or not. Here’s how you can approach both scenarios:
Scenario 1: Versioning Enabled
If versioning is enabled on your S3 bucket, deleted objects are not permanently removed. Instead, they are archived and can be restored.
Using AWS Management Console:
Navigate to the S3 console: AWS S3 Console
Select the bucket where the object was deleted.
Click on the "Show versions" tab to see a list of all versions of objects in the bucket.
Select the file with type "Delete marker" and delete that file
Once the Delete marker is removed we can find the original object in bucket
Scenario 2: Versioning Not Enabled
If versioning is not enabled and an object is deleted, it cannot be directly recovered. AWS S3 does not keep a record of deleted objects without versioning.
In this case, the only way to potentially recover the object is if you have backups or copies stored elsewhere. AWS S3 does not provide a built-in recovery mechanism for permanently deleted objects without versioning.
Best Practices to Avoid Data Loss
Enable Versioning: Always enable versioning on your S3 buckets to protect against accidental deletions and to maintain a history of object versions.
Regular Backups: Implement regular backups of critical data stored in S3 to another location or service.
By following these practices, you can ensure better data protection and recovery capabilities for your objects stored in AWS S3.