What Is Object Versioning? Recover Data After an Overwrite or Deletion
Object versioning keeps earlier states of an object when the same object name is written again or deleted, so you can recover from an accidental overwrite or deletion.
Object versioning keeps earlier states of an object when the same object name is written again or deleted, so you can recover from an accidental overwrite or deletion. It is often enabled at the bucket or storage-account level, but version IDs, deletion behavior, and retention differ by service. Enabling versioning alone does not create a complete backup. Plan how to restore, retain, and delete versions, who can do so, and what the added storage will cost.
What happens to versions when you write or delete an object?
Object storage usually finds data by a key in a bucket. If an application uploads new content to reports/monthly.csv, a versioning-enabled service can retain the prior content as an older version under the same key. Each version generally has its own identifier, and a read that does not specify one returns the current version.
The exact workflow is provider-specific. In Amazon S3, a PUT to the same key creates a new version ID and keeps the prior version. A simple DELETE usually adds a delete marker as the current version instead of immediately erasing the data. A normal GET can therefore look as though the object is gone, while a GET with the old version ID can still retrieve it. Deleting a specific version ID can permanently remove that version.
Google Cloud Storage retains a prior version as noncurrent when a live object is replaced or deleted, provided the request does not specify the live generation number. Versions are identified by generation numbers and may not appear in a normal listing. In Azure Blob Storage, writes and deletes move the current version into previous-version history, while a subsequent write creates a new current version. Check which write operations create versions and which account types support the feature. The label “versioning” does not imply identical recovery steps across providers.
How do you restore an object that was overwritten by mistake?
Suppose an application accidentally overwrites reports/monthly.csv. A cautious recovery can follow these steps:
Find the intended earlier version by key, upload time, version ID, or generation number. You may need a version-aware listing rather than the default list of current objects.
Check its size, modification time, metadata, and, if available, an application checksum to select the right copy.
Before making it current, copy it to a separate key or isolated bucket and verify that it can be read and processed. Some restore operations create a new current version, so check the destination and permissions to avoid overwriting useful state.
After validation, use the provider’s documented restore procedure and confirm the application reads the expected content from the original key.
Deletion recovery is not the same as taking an item out of a universal recycle bin. In S3, you can remove a delete marker or select an earlier version. In Cloud Storage, you can copy a generation-specific earlier version to create a current object. Azure Blob Storage has its own copy-to-current and soft-delete behavior. Verify the procedure in the product documentation and a test account before relying on it.
How is versioning different from backup or delete protection?
Versioning is useful for recovering prior object states that remain in the same account or bucket, but it is not an independent backup by itself. An administrator or attacker who can change retention and delete permissions may remove all versions. An object-level feature may also fail to protect against deletion of the entire bucket, container, or storage account.
Object versioning and soft delete are also distinct. Google Cloud says soft delete may be more appropriate for preventing permanent loss from accidental or malicious deletion, and bucket deletion needs separate protection. Azure Blob soft delete retains deleted blobs, versions, or snapshots for a set period and can be combined with versioning. An S3 delete marker is a version state that makes normal reads treat the object as deleted; it is not equivalent to a backup in another account or an immutable retention policy.
Depending on the risk, combine versioning with cross-account copies, a separate administration account, object lock or immutable retention, soft delete, or a backup service. For example, you might keep versions in the production account, copy data on a schedule to a separate account, and give backup administrators credentials separate from the application’s production access. This guide does not determine whether a specific regulatory requirement is met; check the applicable rules and product capabilities.
How should you manage retention and cost?
Versions continue to use storage, and products that retain a full new object on each upload can accumulate substantial data when overwrites are frequent. AWS says each S3 version is stored and transferred as a complete object rather than as a difference from the previous one. Other services may calculate charges differently because of shared blocks or tiering, so do not apply one provider’s pricing model to another.
After versioning is enabled, a simple delete may not reclaim storage. In S3, for example, it adds a delete marker and leaves earlier versions as noncurrent. A lifecycle rule that permanently removes noncurrent versions reduces the available recovery history, so set its timing against your recovery objective. Check whether each rule targets current versions, noncurrent versions, or delete markers.
Decide these controls together:
**Required history:** Determine how many prior versions or days of history are useful, and whether long-term retention belongs in a separate backup.
**Automatic expiration:** Choose when old versions and delete markers should be removed, and confirm the period still meets recovery needs.
**Cost monitoring:** Track version counts, growth, read/copy requests, and retrieval charges for colder tiers. Frequently overwritten keys may be easier to manage in a separate bucket or account.
**Deletion permissions:** Restrict who can permanently delete versions, change versioning, or edit lifecycle policies, and keep an audit record.
What should you check and test before enabling it?
First, find out how often the application overwrites each key and whether it expects deletion to free storage. Providers also differ in how versioning affects objects that already exist. For example, AWS S3 leaves existing objects unchanged when versioning is enabled and assigns version IDs to subsequently added objects. Review storage growth and lifecycle rules before enabling the feature on a busy production bucket.
In a small test bucket, enable versioning, upload two contents to the same key, and retrieve both the current and previous versions. Then delete the object and compare the default listing with a version-aware listing. Restore the earlier content as a new current object. Finally, test which versions and delete markers the lifecycle rule removes, and verify that a person with separate recovery permissions can complete the restore. These are recommended checks; no test was performed for this article.
Versioning creates a chance to recover from overwrites and individual object deletions, but its protection boundary and deletion semantics vary by provider. It can increase storage costs, and a misconfigured permanent-deletion rule can erase the history. Operate it together with restore drills and a reviewed retention policy.
References
[AWS S3: How versioning works](https://docs.aws.amazon.com/AmazonS3/latest/userguide/versioning-workflows.html)
[AWS S3: Deleting object versions and lifecycle rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html)
[Google Cloud Storage: Object Versioning](https://docs.cloud.google.com/storage/docs/object-versioning)
[Google Cloud Storage: Versioning considerations and soft delete](https://docs.cloud.google.com/storage/docs/object-versioning#considerations)
[Microsoft Learn: Azure Blob Storage versioning](https://learn.microsoft.com/en-us/azure/storage/blobs/versioning-overview)
[Microsoft Learn: Blob soft-delete behavior and scope](https://learn.microsoft.com/en-us/azure/storage/blobs/soft-delete-blob-overview)
Provider behavior is described from official documentation reviewed on 2026-11-19. Supported operations, restore APIs, storage and deletion charges, and lifecycle behavior can vary by product settings and account type. Test restoration and expiration in the service you use before protecting production data.