Versioning
Bucket versioning is a core S3 feature and it's fully supported by Cubbit. It allows for keeping multiple versions of an object, which protects from unintended overwrites and deletions, providing a safer way to manage your files.
Bucket versioning is a requirement to enable object locking.
Safe uploads
When versioning is enabled, uploading the same file with the same name over and over does not overwrite anything, instead, it creates a new version of the object. Each new version has a unique version ID, which consists of a 128-bit fixed-size UUIDv4.
Download a specific version
By default, downloading an object picks its latest version. But you can also retrieve a very specific version of the object, once you know its version ID.
More details on how to download specific object versions can be found here.
Safe deletes
Moreover, by default deleting an object does not remove any content, but simply marks the object as deleted with a DeleteMarker
on top of it. This means that it's still possible to retrieve or restore any previous version of that object. But of course, if you want to permanently remove a specific version, you can still do it by specifying its version ID.
More details on how to delete object versions can be found here.
Final caveats
There are a few other things that it's worth mentioning.
It's a bucket-level feature
Please keep in mind that versioning can only be enabled on an entire bucket. Thus, it's not possible to enable it on a subset of objects.
More details on how to enable versioning on a bucket can be found here.
Buckets can be suspended
Finally, you can also suspend bucket versioning: this just changes the bucket behavior from this moment, but older versions won't be touched.
Watch out for storage capacity
While versioning a bucket is a great feature and provides a safe way to work with objects, this comes with a cost in terms of storage.
For instance, let's say you are doing a daily backup of a 1 GB file. If you're uploading the file into a versioned bucket, each day you create a new version and increase the used storage by 1 GB. After a month, your object would be made of 30 versions occupying a total of 30 GB.
More details on how to permanently get rid of some versions can be found here.
Usage
The following section explains how to work with this feature, either using the Cubbit Console or the AWS s3api
CLI commands.
Enable bucket versioning
Let's start enabling versioning on a whole bucket.
- Cubbit Console
- AWS S3 API
Currently, the only way to enable versioning on a bucket using the Cubbit Console is during its creation.
- Sign in with the Cubbit Console.
- Click on the "Create bucket" button on the top right.
- Choose a bucket name and move on to the next step.
- When prompted for the bucket versioning, click on the "Enabled" button and finally confirm by clicking on the "Create bucket" button.
You should see a brand new bucket, with versioning enabled.
It's a PutBucketVersiong
API where you also specify Status=Enabled
:
aws s3api put-bucket-versioning --endpoint https://s3.cubbit.eu --bucket my-cubbit-bucket --versioning-configuration Status=Enabled
Download specific object versions
You can then list or download specific versions of an object.
- Cubbit Console
- AWS S3 API
Once you've created your versioned bucket, you should:
- Click on the versioned bucket you created in the previous step.
- Click on the "Show versions" toggle.
You can now see all the different versions of a single object and perform operations on a specific file version.
To list all versions of a bucket you need to use the ListObjectVersions
API:
aws s3api list-object-versions --endpoint https://s3.cubbit.eu --bucket my-cubbit-bucket
While to get object metadata (or to download it) you just need to specify the version-id
, for instance on a HeadObject
:
aws s3api head-object --endpoint https://s3.cubbit.eu --bucket my-cubbit-bucket --key sergio.jpg --version-id d89da4c9-b87a-4af4-a6fc-7f76f1e631be
Permanently delete object versions
Finally, let's see how to delete specific object versions. Please keep in mind that versioned delete operations are irreversible.
- Cubbit Console
- AWS S3 API
Given the previous steps, this is pretty straightforward. Once you can list the versions you can also click on a single one, open the menu by clicking on the three dots icon on the right and click on the "Delete" button. This action deletes a single version, permanently.
If, instead, you want to create a DeleteMarker
, maintaining the old versions, disable the "Show versions" toggle to get back to the old view. At this point, you can safely delete the object.
Try to click once again on the "Show versions" toggle. Your old versions are still there and a DeleteMarker
with size = 0 is on top of them!
It's a DeleteObject
where you also specify a version-id
:
aws s3api delete-object --endpoint https://s3.cubbit.eu --bucket my-cubbit-bucket --key sergio.jpg --version-id d89da4c9-b87a-4af4-a6fc-7f76f1e631be