(upbeat music)
- Hi, I'm Sayan, a Cloud support engineer
here at the A.W.S. office in Bangalore.
Today I'm going to show you how to retrieve
an Amazon S3 object that was deleted
in a versioning enabled bucket.
Let's get started.
When versioning is enabled for an S3 bucket
and an object or file is deleted
using a delete object request
then a delete marker is placed on the file.
Basically, if you delete an object
instead of removing it permanently
Amazon S3 inserts a delete marker on the file
which becomes the current version of that object.
Now S3 will behave as if it is deleted
and if you make a simple GET request
for that file or object S3 will return an error.
There are two options you can use
to retrieve the deleted object.
Option one: when the delete marker
becomes the current version
the actual object in your delete request
becomes the older version of the object.
You can retrieve directly this older version
of the object in your GET request
provided you have the necessary
S3 Get Object Version permission.
Option two: You can remove the delete marker
itself of the object.
Then actual object that was previously deleted
becomes the latest version.
This means that a simple Get request
retrieves the actual object.
To delete the delete marker you must have the permission
to delete object versions in the bucket
which is S3 Delete Object Version.
Also, you must do this from the account that owns
or created the bucket.
Note that if the bucket has M.F.A. delete enabled
you must use the designated multi-factor authentication,
M.F.A., to remove the delete marker.
In this video, I'll show you these two options
through A.W.S. management console
and also through A.W.S. C.L.I.
First, let's delete an object from my bucket.
As you can see I'm logged into the A.W.S.
management console.
Go to the S3 management console.
Select the bucket.
Now as you can see this is a versioning enabled bucket.
Let's go to the object example.txt.
Now let's delete the object example.txt.
As you can see the object is removed
from the standard list view of the console.
Now let's try accessing the actual object
which we deleted using option one.
Choose Show and go to the object that you want to retrieve.
The show view shows the delete markers
and the previous versions of all the objects.
You can search for the object in the search bar.
Because the file example.txt was uploaded
after versioning was enabled
it has an alpha numeric version I.D.
Otherwise the version I.D. would be null.
Note the newly placed delete marker.
Now if you just go to Previous Version
which is the actual object and download it
you can get the object.
Let me show you how to access the object
through A.W.S. C.L.I.
I've configured A.W.S. C.L.I
with one of my I.M. users of this account.
To access the object let's make a Get Object command
and specify the version I.D. of the deleted object.
You can get the version I.D. of the actual object
through the S3 console as shown earlier
or you can get it through the output
of the List Object Versions command for the object.
Note that the command lists all the objects
beginning with example.txt
like example.txt one, example.txt two.
Note this fact and filter the output accordingly.
From the versions of the commands output
copy the version I.D. of the object
that we want to retrieve.
Then let's run the Get Object command
for the specific version.
As you can see, the command was successful.
We have downloaded the object.
Now let me explain the option two
that deletes the latest delete marker itself.
Let's do it through console first.
Just as you did earlier choose Show
and then search for your object.
Let's get to the topmost or latest version
which is the delete marker.
Now delete it.
After doing this you can see that the example.txt
has become the latest version
and you can find it in the standard hide view as well.
From there you can simply download it
as you download other objects.
Now let me explain to you how to use this option
which is deleting the delete marker through A.W.S. C.L.I.
I just deleted the object example.txt again
for this demonstration.
So the first step is to find the version I.D.
of the latest delete marker.
You can find that from the console
in a similar way to what I showed you
or you can do that from A.W.S. C.L.I.
by listing all your latest delete markers
through this command.
This shows all the objects
which are currently in the deleted status.
From the commands output, find the object
you want to retrieve which is this case is example.txt.
Note the version I.D. of its delete marker.
Now do a delete object command
specifying this version I.D.
As you can see, the delete object command was successful.
The delete marker is now deleted.
Now run this command to list all the objects in the bucket.
Verify that the previously deleted object
is now included in the list.
Now you can do a simple A.W.S. sc3p
or A.W.S. s3api Get Object
to access the actual object example.txt.
It's now the latest version
after deleting the latest delete marker.
Thanks for watching and happy cloud computing
from all of us here at A.W.S.