Manage versioning in Bucket

By default, Object Storage Service does not provide backup capabilities. That means that if you delete an object incidentally, it is not possible to restore it.

Versioning means of keeping multiple variants of an object in the same Bucket. You can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your Bucket.

With versioning you can recover more easily from both unintended user actions and application failures.

Versioning-enabled Buckets can help you recover objects from accidental deletion or overwrite. For example, if you delete an object, a delete marker is created instead of removing the object permanently.

The delete marker becomes the current object version. If you overwrite an object, it results in a new object version in the Bucket.

By default, S3 Versioning is disabled on buckets, and you must explicitly enable it. To manage Bucket and Object versioning, you can you can use the AWS CLI or any compatible tools or SDK.

Billing

You will be charged of space being used by older versions of your objects.

Limitation

We suggest keep the object version less than 50k. You can use a lifecycle configuration to delete versions of your objects.

Get current versioning state of a bucket

We use aws s3 and aws s3api command line tools from AWSCLIv2 on Linux.

${S3_ENDPOINT} and ${S3_PROFILE} are environment variables

If the versioning state has never been set on a Bucket, it has no versioning state. Using aws s3api AWS CLI, get-bucket-versioning, will return nothing:

For a Bucket with versioning enabled:

For a Bucket with versioning suspended:

Enable versioning on buckets

Suspend versioning on buckets

Once versioning enable on a bucket it can't be remove. But you have the possibility to suspend it.

Manage Objects versions

List Objects versions

You can use the list-object-versions from s3 api from AWSCLI:

To get a specific version of an object using get-object and --version-id <Version ID>

Delete an Object in a versioning Bucket

When you delete an object in a versioning Bucket, a delete marker is created and become the current version of the object:

Restore Objects

The delete marker has a version id too, you can delete it using its version ID in order to restore your object.

Delete a specific version of an Object

You can delete a specific version on an object. If the specified version is not the current version, the object version is deleted and no delete marker is created.

Last updated