Skip to content

Object Versioning

Estimated time to read: 2 minutes

With the Object Versioning feature, you can preserve, retrieve, and restore every version of an object. This feature helps protect against accidental overwrites or deletions, allowing you to recover previous versions of your data whenever needed. It is commonly used for data protection, auditing, and ensuring data integrity.

Object Operations

Key features of Object Versioning

Object Versioning allows you to preserve, retrieve, and restore every version of an object in your bucket. It helps prevent accidental deletions and overwrites, and provides a way to recover previous versions of objects.

With Object Versioning enabled, every time an object is uploaded or modified, a new version is created. You can then retrieve any previous version or restore the current version if needed. This feature is critical for data recovery, historical record-keeping, and protecting against unintended changes.

Feature With Versioning Without Versioning
Data Recovery Can recover deleted/modified objects. No recovery once an object is deleted.
Storage Uses more storage (multiple versions). Uses less storage (only the current version).
Deletion Soft delete with markers (can be undone). Hard delete (permanent removal).
Complexity More complex (managing versions). Simpler to manage (no versioning).

Enable Object Versioning

Enable Object Versioning for a bucket:

aws s3api put-bucket-versioning --bucket <bucket_name> \
    --versioning Status=Enabled

See the Object Versioning status of a bucket:

aws s3api get-bucket-versioning --bucket <bucket_name>
---
{
    "Status": "Enabled"
}

For all Object Versioning operations see:

Object Operations

Disable Object Versioning

Disable Object Versioning for a bucket:

aws s3api put-bucket-versioning --bucket <bucket_name> \
    --versioning Status=Suspended

Note

This will stop creating new versions, but previous versions will still be available.

Delete a bucket with Object Lock enabled

To delete the bucket, you must first delete all object versions and delete markers manually.