Managing delete markers
Configuring lifecycle to clean up expired delete markers automatically
An expired object delete marker is one where all object versions are deleted
and only a single delete marker remains. If the lifecycle configuration is set to
delete current versions, or the ExpiredObjectDeleteMarker
action is
explicitly set, Amazon S3 removes the expired object’s delete marker. For an example,
see Removing expired object delete markers in a versioning-enabled bucket.
Removing delete markers to make an older version current
When you delete an object in a versioning-enabled bucket, all versions remain in the bucket, and Amazon S3 creates a delete marker for the object. To undelete the object, you must delete this delete marker. For more information about versioning and delete markers, see Retaining multiple versions of objects with S3 Versioning.
To delete a delete marker permanently, you must include its version ID in a
DeleteObject versionId
request. The following figure shows how
a DeleteObject versionId
request permanently removes a delete
marker.
The effect of removing the delete marker is that a simple GET
request will now retrieve the current version ID (121212) of the object.
Note
If you use a DeleteObject
request where the current version
is a delete marker (without specifying the version ID of the delete marker),
Amazon S3 does not delete the delete marker, but instead PUTs
another delete marker.
To delete a delete marker with a NULL
version ID, you must pass
the NULL
as the version ID in the DeleteObject
request. The following figure shows how a simple DeleteObject
request made without a version ID where the current version is a delete marker,
removes nothing, but instead adds an additional delete marker with a unique
version ID (7498372).
Use the following steps to recover deleted objects that are not folders from your S3 bucket, including objects that are within those folders.
-
Sign in to the Amazon Web Services Management Console and open the Amazon S3 console at https://console.amazonaws.cn/s3/
. -
In the Buckets list, choose the name of the bucket that you want.
-
To see a list of the versions of the objects in the bucket, choose the List versions switch. You'll be able to see the delete markers for deleted objects.
-
To undelete an object, you must delete the delete marker. Select the check box next to the delete marker of the object to recover, and then choose Delete.
-
Confirm the deletion on the Delete objects page.
-
For Permanently delete objects? enter
permanently delete
. -
Choose Delete objects.
-
Note
You can't use the Amazon S3 console to undelete folders. You must use the Amazon CLI or SDK. For
examples, see How can I retrieve an
Amazon S3 object that was deleted in a versioning-enabled bucket?
To permanently remove a delete marker
-
Set
versionId
to the ID of the version to the delete marker you want to remove. -
Send a
DELETE Object versionId
request.
Example — Removing a delete marker
The following example removes the delete marker for
photo.gif
version 4857693.
DELETE /photo.gif?versionId=4857693 HTTP/1.1 Host: bucket.s3.amazonaws.com Date: Wed, 28 Oct 2009 22:32:00 GMT Authorization: AWS AKIAIOSFODNN7EXAMPLE:0RQf4/cRonhpaBX5sCYVf1bNRuU=
When you delete a delete marker, Amazon S3 includes the following in the response.
204 NoContent x-amz-version-id:
versionID
x-amz-delete-marker: true
For information about using other Amazon SDKs, see the AmazonDeveloper Center