Bucket Versioning
Diese Seite ist noch nicht in deiner Sprache verfügbar. Englische Seite aufrufen
Using AWS client
Section titled “Using AWS client”See the official AWS client documentation for further information.
Put Object Versioning
Section titled “Put Object Versioning”You can enable versioning on a bucket using aws cli s3api using the argument “put-bucket-versioning”:
aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api put-bucket-versioning --bucket $BUCKET\_NAME --versioning-configuration Status=Enabled for example: aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api put-bucket-versioning --bucket versioning-testbucket --versioning-configuration Status=EnabledGet Versioning status
Section titled “Get Versioning status”If you want to know if bucket versioning is enabled on a bucket you can simply use aws cli s3api using the argument “get-bucket-versioning”
aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api get-bucket-versioning --bucket $BUCKET\_NAME for example: aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api get-bucket-versioning --bucket versioning-testbucket { "Status": "Enabled" }Suspend Bucket Versioning
Section titled “Suspend Bucket Versioning”Once the bucket versioning has been enabled, it cannot be disabled completely. It can only be suspended.
If you want to suspend versioning on a bucket you can use aws cli s3api with the argument “put-bucket-versioning —versioning-configuration Status=Suspended”
aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api put-bucket-versioning --bucket $BUCKET\_NAME --versioning-configuration Status=Suspended for example: aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api put-bucket-versioning --bucket versioning-testbucket --versioning-configuration Status=Suspended check the status: aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api get-bucket-versioning --bucket versioning-testbucket { "Status": "Suspended" }List Object Versions
Section titled “List Object Versions”You can list object versions within a given bucket using the “list-object-versions” argument.
This will return all versions of all objects within your bucket.
Each object version gets it´s own unique ID displayed as “VersionID”
aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api list-object-versions --bucket $BUCKETNAME for example: aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api list-object-versions --bucket versioning-testbucket { "Versions": [ { "ETag": "\\"1a6fcf50c1eafb9db3b1916c80131a8c\\"", "Size": 56, "StorageClass": "STANDARD", "Key": "testfile.txt", "VersionId": "NDM0ODQ5NEEtQTU0OC0xMUVDLTkyNEItOTFFRTAwQkU0RTEw", "IsLatest": true, "LastModified": "2022-03-16T16:43:52.668000+00:00", "Owner": { "DisplayName": "f1ba3206-eaf2-4f1d-b01a-5679c5e82dfd", "ID": "88612969136594181457" } }, { "ETag": "\\"1a6fcf50c1eafb9db3b1916c80131a8c\\"", "Size": 56, "StorageClass": "STANDARD", "Key": "testfile.txt", "VersionId": "NDBBRjA1NUMtQTU0OC0xMUVDLTk4MzMtNzM2NzAwQzEyQ0Yx", "IsLatest": false, "LastModified": "2022-03-16T16:43:48.308000+00:00", "Owner": { "DisplayName": "f1ba3206-eaf2-4f1d-b01a-5679c5e82dfd", "ID": "88612969136594181457" } }, { "ETag": "\\"caf69a19c1017882a0e33a22d72b30df\\"", "Size": 40, "StorageClass": "STANDARD", "Key": "testfile.txt", "VersionId": "MkQxQjY3MDYtQTU0OC0xMUVDLTlEOEMtMTU3QzAwQkU0RTEw", "IsLatest": false, "LastModified": "2022-03-16T16:43:15.464000+00:00", "Owner": { "DisplayName": "f1ba3206-eaf2-4f1d-b01a-5679c5e82dfd", "ID": "88612969136594181457" } } ] }Get a specific Object Version
Section titled “Get a specific Object Version”You can download a specific Object Version by specifying the object version on the get request. The object version ID is shown if you list the object versions (see: “List Object Versions”)
aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api get-object --bucket $BUCKET\_NAME --key $OBJECT\_KEY --version-id $VERSION\_ID for example: aws --endpoint-url https://object.storage.eu01.onstackit.cloud s3api get-object --bucket versioning-test --key testfile.txt --version-id MkQxQjY3MDYtQTU0OC0xMUVDLTlEOEMtMTU3QzAw QkU0RTEw testfile\_new { "AcceptRanges": "bytes", "LastModified": "2022-03-16T16:43:15+00:00", "ContentLength": 40, "ETag": "\\"caf69a19c1017882a0e33a22d72b30df\\"", "VersionId": "MkQxQjY3MDYtQTU0OC0xMUVDLTlEOEMtMTU3QzAwQkU0RTEw", "ContentType": "binary/octet-stream", "ServerSideEncryption": "AES256", "Metadata": {} }Using s5cmd CLI tool
Section titled “Using s5cmd CLI tool”To enable versioning on an Object storage bucket using s5cmd, you can follow these steps:
- Install s5cmd: If you haven’t already installed s5cmd, you can do so by following the tutorialHow to setup s5cmd CLI object storage client.
Get bucket versioning status of a bucket:
Section titled “Get bucket versioning status of a bucket:”s5cmd bucket-version s3://bucketnameEnable bucket versioning for the bucket
Section titled “Enable bucket versioning for the bucket”s5cmd bucket-version --set Enabled s3://bucketnameSuspend bucket versioning for the bucket
Section titled “Suspend bucket versioning for the bucket”s5cmd bucket-version --set Suspended s3://bucketnameList all versions of an object in the bucket
Section titled “List all versions of an object in the bucket”s5cmd ls --all-versions s3://bucket/objectList all versions of all objects that starts with a prefix in the bucket
Section titled “List all versions of all objects that starts with a prefix in the bucket”s5cmd ls --all-versions "s3://bucket/prefix*"List all versions of all objects in the bucket
Section titled “List all versions of all objects in the bucket”s5cmd ls --all-versions "s3://bucket/*"Download the specific version of a remote object to working directory
Section titled “Download the specific version of a remote object to working directory”s5cmd cp --version-id VERSION\_ID s3://bucket/prefix/object.Delete the specific version of a remote object’s content to stdout
Section titled “Delete the specific version of a remote object’s content to stdout”s5cmd rm --version-id VERSION\_ID s3://bucket/prefix/objectDelete all versions of an object in the bucket
Section titled “Delete all versions of an object in the bucket”s5cmd rm --all-versions s3://bucket/objectSee the official s5cmd client documentationfor further information.