Skip to content

Versioning

Enable versioning, read old versions and work with delete markers.
Note

Bucket versioning is a Supported MVP feature. Lifecycle rules, Object Lock and hard bucket quotas described in the second half of this page are Preview features.

This tutorial enables bucket versioning, writes multiple versions of an object, reads a historical version by VersionId, and configures lifecycle expiration and a hard bucket quota. Use the silo-admin profile and mcli_pg alias from the Quick start and Use an S3 SDK.

Retain and read historical versions

Create a dedicated version-demo bucket, enable versioning, write two versions of note.txt, and fetch the first version by its VersionId:

aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api create-bucket --bucket version-demo
aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api put-bucket-versioning \
  --bucket version-demo --versioning-configuration Status=Enabled
printf 'version one\n' > "$SILO_TUTORIAL_DIR/version-one.txt"
printf 'version two\n' > "$SILO_TUTORIAL_DIR/version-two.txt"
SILO_VERSION_1="$(aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api put-object \
  --bucket version-demo --key note.txt --body "$SILO_TUTORIAL_DIR/version-one.txt" --query VersionId --output text)"
aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api put-object \
  --bucket version-demo --key note.txt --body "$SILO_TUTORIAL_DIR/version-two.txt"
aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api list-object-versions --bucket version-demo
aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api get-object \
  --bucket version-demo --key note.txt --version-id "$SILO_VERSION_1" "$SILO_TUTORIAL_DIR/version-one.download.txt"
cmp "$SILO_TUTORIAL_DIR/version-one.txt" "$SILO_TUTORIAL_DIR/version-one.download.txt"

In a versioned bucket, calling delete-object without --version-id inserts a delete marker while preserving prior versions. Permanently deleting a specific version requires passing --version-id and holding s3:DeleteObjectVersion. Reading a historical version requires s3:GetObjectVersion.

Suspending versioning (Status=Suspended) switches new writes to null-version semantics without deleting existing historical versions.

Lifecycle rules and bucket quotas

Create a lifecycle-demo bucket and apply a lifecycle rule that expires current objects under tmp/ after 7 days and aborts incomplete multipart uploads after 1 day:

aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api create-bucket --bucket lifecycle-demo
aws --profile silo-admin --endpoint-url "$SILO_ENDPOINT" --region us-east-1 s3api put-bucket-lifecycle-configuration \
  --bucket lifecycle-demo \
  --lifecycle-configuration '{"Rules":[{"ID":"temporary-files","Status":"Enabled","Filter":{"Prefix":"tmp/"},"Expiration":{"Days":7},"AbortIncompleteMultipartUpload":{"DaysAfterInitiation":1}}]}'

A background worker on a writable gateway scans for eligible objects under a database lease. Expiring historical versions requires a NoncurrentVersionExpiration rule. Remote storage-class transition rules (Transition / NoncurrentVersionTransition) are not supported and are rejected.

Hard bucket quotas count the committed object bodies and annotations of all live and historical versions (excluding delete markers). Unfinished multipart parts consume physical table space immediately, but count toward the logical bucket quota only when CompleteMultipartUpload publishes the object:

mcli_pg quota set pg-admin/attachments --size 1GiB
mcli_pg quota info pg-admin/attachments

Deleting versions releases logical quota immediately, whereas physical disk space is reclaimed and reused asynchronously by PostgreSQL VACUUM. See Storage layout for details.

Scan to open this page
https://mimus.pgsty.com/docs/s3/tutorial/versioning/