⚠️ Object Storage is currently in Beta test. For more information see this FAQ: Object Storage » Beta test
To protect your objects from getting deleted by accident, you can use Versioning. For more information about the differences between Versioning and Object Lock, see the FAQ entry "What is the difference between versioning and object locking?".
The commands depend on the S3-compatible tool you're using. This getting started explains each step with example commands for the MinIO Client and the AWS CLI.
-
Set versioning
-
For the entire Bucket:
mc version enable <alias_name>/<bucket_name>
-
For the entire Bucket:
aws s3api put-bucket-versioning --versioning-configuration Status=Enabled --bucket <bucket_name>
-
-
Check the versioning status
-
Bucket status:
mc version info <alias_name>/<bucket_name>
-
Bucket status:
aws s3api get-bucket-versioning --bucket <bucket_name>
-
-
List all versions
-
Of all objects in the Bucket:
mc ls --versions <alias_name>/<bucket_name>
Of a single object:
mc ls --versions <alias_name>/<bucket_name>/<object_name> mc stat --versions <alias_name>/<bucket_name>/<object_name>
-
Of all objects in the Bucket:
aws s3api list-object-versions --bucket <bucket_name>
Of a single object:
aws s3api list-object-versions --bucket <bucket_name> --key <object_name>
-
-
View or download a specific version of an object
If you don't specify a version, it will automatically view or download the version that was added most recently (the latest version).
-
MinIO Client
mc cat --version-id <version_id> <alias_name>/<bucket_name>/<object_name> mc cp --version-id <version_id> <alias_name>/<bucket_name>/<object_name> <local_target_location>
-
aws s3api get-object --version-id <version_id> --bucket <bucket_name> --key <object_name> <local_target_location>
-
-
Delete a version or all versions of an object
-
All versions:
OBJECT="<alias_name>/<bucket_name>/<object_name>" for key in $(mc ls --versions "$OBJECT" | awk '{print $6}'); do mc rm --version-id "$key" "$OBJECT"; done
A single version:
mc rm --version-id <version_id> <alias_name>/<bucket_name>/<object_name>
-
All versions:
BUCKET="<bucket_name>" OBJECT="<object_name>" for version in $(aws s3api list-object-versions --bucket "$BUCKET" --prefix $OBJECT --query 'Versions[].VersionId' --output text); do aws s3api delete-object --version-id "$version" --bucket "$BUCKET" --key $OBJECT; done
A single version:
aws s3api delete-object --version-id <version_id> --bucket <bucket_name> --key <object_name>
-
-
Remove versioning
-
For the entire Bucket:
mc version suspend <alias_name>/<bucket_name>
-
For the entire Bucket:
aws s3api put-bucket-versioning --versioning-configuration Status=Suspended --bucket <bucket_name>
-
Next: