Recover deleted items from a versioned S3 bucket

,

I have a S3 bucket with versioning enabled. Another user’s access key (now suspended) was used to delete everything in my bucket. Every folder now shows 2 delete marker objects inside and nothing else. Also, they were able to set Bucket Versioning to Suspended (now re-enabled).

First, I contacted AWS Support who told me there’s nothing they can do, the files are gone. However, a couple weeks later, the Metrics tab on my account still shows several GB in DeepArchiveStorage, as well as thousands of objects, so I am really questioning the information I received.

Using AWS CLI, I can see that all the Delete Markers have a null VersionID. I tried deleting a couple of the delete markers (via CLI and via Console), but the object seems to disappear entirely after doing so.

Does anyone have any experience with this? Is there any way to recover the stuff sitting in Deep Archive?

It sounds like your S3 bucket was configured with versioning enabled, which means that every time an object is deleted, a delete marker is created in its place, but the previous versions of the objects are still stored and can be accessed. The user who deleted the objects from your bucket likely did so using the “delete all versions” option, which permanently deletes all versions of an object, including previous versions and delete markers.

AWS Support likely told you that the files are gone because they cannot be restored once they have been deleted using the “delete all versions” option. However, it is possible that the data is still stored in S3 Glacier Deep Archive, which is a storage class for infrequently accessed data that is designed to provide a lower-cost storage option for data that is retained for a long period of time.

It is possible to recover data from S3 Glacier Deep Archive, but it is a manual process that can take several hours to complete. You will need to initiate a retrieval request for the data, and the data will need to be restored to the original S3 bucket or to a new bucket.

It is also worth noting that the “delete markers” in your bucket have a null VersionID, which means that they are not actually associated with any version of an object, so deleting them will not bring back the deleted data.

In summary, it is unlikely that you will be able to restore the deleted data in your S3 bucket, as it was deleted using the “delete all versions” option. However, it may be possible to retrieve the data stored in S3 Glacier Deep Archive but it is a manual process and takes several hours to complete.

Sorry for any frustration caused. I found this doc on restoring an archived object that might be helpful: https://amzn.to/3JnuBVv. If that’s not quite what you need, feel free to send a PM with your case ID, so I can take a look for you. :down_arrow::face_with_monocle:

- Marc O.

You get your account compromised or something? Or disgruntled employee?

When a versioned object is deleted, a delete marker is created in its place. This delete marker acts as a tombstone for the deleted object, and all subsequent versions of the object are removed. Deleting a delete marker will permanently delete the object and all of its versions, including versions stored in the Deep Archive storage class.

It’s possible that the files are not recoverable, but you can try the following options:

  • You can try to restore the object from the previous version, before the deletion.
  • If you have enabled versioning lifecycle rules, you can use them to transition older versions to the Deep Archive storage class, where they can be stored at a lower cost and with a longer retrieval time.
  • You can contact AWS Support again and provide them with the Metrics tab information, which shows the objects and storage used in the Deep Archive. They may be able to help you with a recovery solution.

It’s important to note that, if you deleted the delete markers, the objects are permanently deleted and can’t be recovered.

Also, it’s a good practice to enable versioning in your S3 bucket and also to have a backup of your files.

Thanks, I appreciate the detailed response.

These files are actually my backups. The original system wasn’t affected, I was just trying to determine whether or not anything was recoverable in this instance. It’s a good exercise in disaster recovery brought on by a real-world mistake outside of my control.

Funny enough, one of the earlier responses was from a ChatGPT bot (now deleted), which suggested it may possibly be recoverable from Deep Archive. So I went to ChatGPT, asked the questions directly and it advised me to run the following:

aws s3api list-object-versions --bucket my-bucket --query ‘Versions[?StorageClass==DEEP_ARCHIVE]’

Sure enough, the command returned everything still in Deep Archive! Next, I’ll try recovering some of it to verify I can really get it back.

One other thing I hadn’t seen mentioned elsewhere, ChatGPT said after 90 days the Deep Archive content would be deleted as well. So time is of the essence, somewhat, depending on your situation.

I’m pleasantly surprised with the outcome and will apply lessons learned here.

I have a S3 bucket with versioning enabled. Another user’s access key (now suspended) was used to delete everything in my bucket. Every folder now shows 2 delete marker objects inside and nothing else. Also, they were able to set Bucket Versioning to Suspended (now re-enabled).

You need to do a thorough review of your other users’ IAM roles and make sure you didn’t just assign `s3:*` to all of them.

Objects being stored in Glacier Deep Archive is not something that happens by default, it would be something you configured. Likewise with any 90 day expiry - that’s entirely configurable and objects don’t expire by default. If they’re still there, you can restore them. Can you share the lifecycle rules for the bucket?

Yeah that’s good advice and we definitely did that, although after the fact. Not my area, but I think that’s exactly what happened, someone was lazy and just granted *.