In this blog post, we are going to discuss versioning in S3. We are also going to enable versioning in S3 bucket.
Versioning in S3:
Before we look into S3 bucket versioning let us look into what an Amazon S3 bucket is, a leading provider of scalability, data availability, security, and performance in the object storage space is Amazon Simple Storage Service (Amazon S3). For practically any use scenario, including data lakes, cloud-native applications, and mobile apps, customers of all sizes and sectors can store and protect any quantity of data.
Coming to what versioning of S3 buckets is, AWS S3 provides versioning to keep multiple version of an object in the same bucket. You can store numerous versions of the same object in your S3 bucket by using versioning. For instance, two items with the same key but different version IDs, such as sample.txt (version 1) and sample.txt, can coexist in the same bucket (version 2).
Versioning enables you to save, retrieve, and restore any previous iterations of any object that is kept in your Amazon S3 bucket. Versioning makes it simple to recover from errors in applications as well as from unintentional user actions.
Buckets can be in one of three states: un-versioned (the default), versioning-enabled, or versioning-suspended. Once versioning is enabled for a bucket, it can never be un-versioned again. You can, however, suspend versioning on that bucket. Selective versioning is not supported by AWS S3, and once enabled, it applies to all the objects in the bucket. Each new object added to a bucket receives a special ID when versioning is enabled. Before setting the versioning state, objects that were saved in your bucket had a version ID of null.
Next, we are going to enable versioning to an existing S3 bucket and upload multiple version of the same object. We are also going to delete a versioned object and recover it.
Let’s look at the two most popular methods for enabling versioning in an S3 bucket:
The uses of Versioning-enabled buckets are:
- Amazon S3 inserts a delete marker, which becomes the most recent version of the object, rather than permanently destroying it when you delete it. The old version is always recoverable.
- A new object version is created in the bucket when you overwrite an existing object. The previous version can always be restored.
Restoring deleted object after Versioning:
Step 1: Select one object first in the bucket, then press the delete button.
Step 2: Enter the phrase “permanently delete” in the dialog box and select delete objects button. It says deleted successfully as shown below.
Step 3: After versioning, When we delete an object. It appears to be deleted, but actually not.
Step 4: When the show versions button is toggled, the delete marker and all object versions become visible.
Step 5: When we delete the delete marker, then the current position will be occupied by the previous version so that we can retrieve the required object.