You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Object versioning and retention policies are two complementary data protection features in Cloud Storage. Versioning preserves historical copies of objects, while retention policies prevent objects from being deleted before a specified time. Together, they provide robust protection against accidental deletion, ransomware, and regulatory compliance requirements.
When versioning is enabled on a bucket, Cloud Storage keeps every version of every object. Overwriting or deleting an object creates a non-current version instead of permanently removing the data.
# Enable versioning
gsutil versioning set on gs://my-bucket
# Check versioning status
gsutil versioning get gs://my-bucket
| Action | Result |
|---|---|
| Upload new object | Creates a live (current) version with a generation number |
| Overwrite object | Previous version becomes non-current; new version becomes live |
| Delete object | Live version becomes non-current (data is preserved) |
| Delete non-current version | Permanently removes that specific version |
Every object version has a unique generation number (a timestamp-based integer). You can reference specific versions:
# List all versions of all objects
gsutil ls -a gs://my-bucket/
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.