Does Object Storage Support Versioning?
Does Object Storage support versioning?
With S3 compatible Object Storage, you can use versioning, which allows you to keep multiple versions of an object, so that when you upload an object/file with the same name the S3 Object Storage system will store a version of the previous contents.
This version is also stored in the bucket and is not be directly visible.
Please keep in mind that this feature is not enabled for a specific file, but for an entire bucket.
How do I enable versioning for my Object Storage?
To enable Bucket Versioning, run the following API:
aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api put-bucket-versioning --bucket bucket-with-versioning --versioning-configuration Status=Enabled
How do I check that versioning is switched on for my Object Storage?
To check if versioning is enabled for your Object Storage, run the following API:
aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api get-bucket-versioning --bucket bucket-with-versioning
If the result is empty, then versioning is disabled.
How do I list all my versioned objects?
To find all the versioned objects, run the following API:
aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api list-object-versions --bucket bucket-with-versioning
How do I find the versions of a specific object?
If you want to find the versions of a specific object, follow the example API below. In this example, we want to find the versions of image003.png:
aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api list-object-versions --bucket bucket-with-versioning --prefix image003.png
The current version, which is also returned in regular file listings, is the one for which "IsLatest" is true.
How do find a specific version of an object?
To access an older version of a file, use the VersionId from the output returned in the example above. Below is an example API where we're using image003.png, which was also used in the example above:
aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api get-object --bucket bucket-with-versioning --version-id 'L-6oXdYnuAF1orfDEAHV3mDIliEoB9.' --key image003.png image003.png
How do I disable bucket versioning?
To disable or suspend the Bucket Versioning, please run the following API:
aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api put-bucket-versioning --bucket bucket-with-versioning --versioning-configuration Status=Suspended
Please Note that turning off bucket versioning doesn't delete old versions, it just means that no new versions are created.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article