S3 versioning and delete markers, explained
Versioning turns overwrites and deletes into recoverable history. This article explains what a version is, what a delete marker actually does, how to restore, and how lifecycle rules and Object Lock fit in.
By Wow Magic team · · 4 min read

Enabling versioning on a bucket is the single cheapest protection against the two most common ways data is lost: an accidental overwrite and an accidental delete. It is also a source of confusion, mostly because of one feature with an odd name, the delete marker. Let's go through the model.
What versioning does
A bucket without versioning stores one object per key. Upload report.pdf twice and the second upload replaces the first; delete it and it is gone.
With versioning enabled, every write to a key creates a new version with its own version ID. The previous versions are kept. The most recent one is the current version and is what a normal GetObject returns. Older ones are noncurrent and can be fetched by specifying their version ID.
You enable it in the bucket settings in the console or with the S3 API:
aws s3api put-bucket-versioning \
--bucket my-bucket \
--versioning-configuration Status=Enabled \
--endpoint-url https://YOUR_SYNAPSE_HOST/s3
Versioning can be suspended later, which stops creating new versions without deleting the existing ones. It cannot be turned off while Object Lock is enabled on the bucket (more on that below). The versioning documentation lists the exact behaviours.
What a delete marker is
Here is the part that trips people up. When you delete an object in a versioned bucket without naming a version ID, nothing is removed. Instead the bucket writes a delete marker: a special zero-byte version that becomes the current version of the key.
The effects are:
GetObjectandHeadObjectfor that key return404 Not Found, so the object looks deleted.- The key disappears from ordinary
ListObjectsresults. - Every earlier version is still there, and
ListObjectVersionsshows them along with the marker.
Nothing has been destroyed. The marker is simply the newest entry in the key's history and it happens to mean "not here".
aws s3api list-object-versions --bucket my-bucket --prefix report.pdf \
--endpoint-url https://YOUR_SYNAPSE_HOST/s3
The response has two lists, Versions and DeleteMarkers, each entry carrying a VersionId and an IsLatest flag.
Restoring an object
Because the delete marker is itself a version, restoring is just deleting the marker. This time you name the version ID:
aws s3api delete-object --bucket my-bucket --key report.pdf \
--version-id <delete-marker-version-id> \
--endpoint-url https://YOUR_SYNAPSE_HOST/s3
The previous version becomes current again and GetObject works as before. The Wow Magic console offers the same operation from the object's version history without having to copy IDs around.
To roll back an overwrite rather than a delete, copy the older version on top of the key (CopyObject with a versionId in the source). That creates a new current version identical to the old one, keeping the full history intact.
Permanent deletion
A DeleteObject call that specifies a version ID removes exactly that version, permanently, whether it is a data version or a delete marker. To empty a versioned bucket you must delete every version and every marker, which is what the console's "delete all versions" action and aws s3 rm --recursive combined with a versions listing do.
Keeping the history under control with lifecycle rules
Every version occupies storage and is billed like any other object, so an actively rewritten key can accumulate a long tail. Lifecycle rules handle this automatically. A Wow Magic lifecycle rule applies to an optional key prefix and can:
- expire noncurrent versions a number of days after they were superseded, which permanently removes them (versions under an Object Lock retention or legal hold are skipped);
- expire the current version a number of days after it was written, which in a versioned bucket behaves like a normal delete and adds a delete marker rather than destroying data.
Separately from lifecycle rules, the platform aborts multipart uploads that have been abandoned for seven days so that their parts do not linger.
A common configuration for a document store is "keep noncurrent versions for 30 days". Lifecycle rules are edited per bucket in the console (Settings, Lifecycle) or with PutBucketLifecycleConfiguration through the S3 API. Rules are evaluated by a background job, so expiry happens within hours of the cut-off rather than to the second.
Object Lock: when versions must not be deletable
Versioning protects against mistakes; it does not protect against someone with credentials deliberately deleting every version. That is what Object Lock is for. With Object Lock, a version carries a retention date (and optionally a legal hold) and cannot be deleted or overwritten until that date passes, no matter who asks.
Object Lock requires versioning, which is why versioning cannot be suspended once lock is enabled. It is the mechanism to use for backup targets and anything with a compliance retention requirement. Our article on automated backups to S3-compatible storage shows a practical setup.
Summary
- Versioning keeps every write as a new version; nothing is overwritten.
- A delete without a version ID adds a delete marker; the data stays.
- Restore by deleting the marker, or by copying an older version on top.
- Deleting a specific version ID is permanent.
- Lifecycle rules keep the history bounded; Object Lock makes it immutable for a period.
Versioning is available on every plan, including the free tier, and is described in full in the docs.


