Object Versioning: A Safety Net for Cloud Files
Object Versioning treats every file change as a new version, not a replacement. It's used in cloud storage to recover from accidental overwrites or deletions. The footgun: you pay for all versions, so costs can multiply without cleanup policies.
WHY IT EXISTS Object Versioning was created to prevent irreversible data loss in cloud storage. In a standard bucket, overwriting or deleting a file is a permanent action. Versioning provides a crucial safety net to recover from application bugs or human error that might otherwise destroy critical data.
THE MENTAL MODEL Think of it as a simplified Git for individual files in a cloud storage bucket. Every time you 'overwrite' an object with a PUT request, you're not replacing it; you're creating a new version, like a new commit. The old version is still there, just not the 'current' one. Similarly, deleting an object just adds a 'delete marker' on top, which can also be reverted.
HOW IT WORKS Versioning is a setting you enable on an entire bucket. Once on, every object in the bucket is given a unique version ID upon creation or modification. By default, GET requests retrieve the latest (current) version. To access a previous state of an object, you must explicitly request it using its unique version ID. Deleting an object without specifying a version ID simply creates a delete marker. This marker becomes the new current version and causes future GETs to return a 404 Not Found. To permanently delete data and stop paying for storage, you must explicitly delete specific versions or the delete marker itself.
WHEN TO USE IT Enable versioning for buckets containing critical data that must be recoverable. This includes application backups, legal documents, important configuration files, and any data subject to compliance rules that mandate retention and audit trails. It is a powerful tool for disaster recovery at the object level.
WHEN NOT TO USE IT Avoid versioning for buckets used as scratch space or for storing transient, easily reproducible data. The primary footgun is cost. You are billed for the storage of every single version of an object. For frequently updated, large objects, this can lead to massive, unexpected bills if old versions are not actively managed and deleted, typically via automated lifecycle policies.
ONE CANONICAL EXAMPLE A content management system stores its primary settings.json file in a versioned bucket. A developer accidentally pushes a bad configuration, breaking the production site. Instead of a frantic search for a backup, the team can simply list the object's versions, identify the last known good version ID, and restore it immediately, minimizing downtime.
Read the original → docs.cloud.google.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.