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 s3and 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:
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.