DEV Community

Ajit Singh for This is Learning

Posted on

S3 file versioning hands On

We studied about S3 file versioning in the last part . In this part we will see how to start file versioning in S3 and what are its advantages.

  • Go to your S3 dashboard

  • Select the bucket that we used in last exercise while deploying a static site in S3
    S3 versioning

  • Go to the properties tag. The first setting is bucket versioning.
    S3 versioning

  • Click on edit in bucket versioning

S3 versioning

  • Select enable and save changes
    S3 versioning

  • Bucket versioning is enabled now in the bucket

Now let us see what it affects and how it can be useful

  • Change the contents of the index.html file and upload it again I've changes the contents to the following.
        <title>Test s3</title>
        <h1>Ajit Singh</h1>
        <p>Hello world new!</p>

Enter fullscreen mode Exit fullscreen mode
  • Upload the new file again S3 versioning
  • Enable show versions from bucket dashboard you will see that you have two versions of the file
    S3 versioning

  • Now on checking the website link you will see the contents changes
    S3 versioning

Now let us see how to recover our old file

  • To recover the old file we can select a specific version on the dashboard and delete it then we will recover our old file S3 versioning S3 versioning
  • Now let us again go to our website link. we will see that our file is reverted back.

S3 versioning

  • Let us now try to delete the last index.html file but turn off show versions. S3 versioning
  • You will see that this is not an option of permanently delete but a delete S3 versioning
  • After you delete the object you will see you bucket is empty S3 versioning
  • Enable show versions you will see that it is not actually deleted but S3 adds a delete marker on it
    S3 versioning

  • We can now recover the object by deleting the delete marker on the object same way we deleted the other version
    S3 versioning
    S3 versioning
    S3 versioning

  • Voila we have recover the version

So here we see why bucket versioning is so important in S3 and why this should definitely be enabled for important buckets. We have already created a S3 bucket but how to see logs if retrieval of file is failing. Next time we will study how to enable logging in S3 buckets.

Discussion (0)