Guided Lab: Protecting Data on Cloud Storage Bucket Against Accidental Delete and Overwrite Using Object Versioning
Description
Google Cloud Storage provides Object Versioning, a feature that helps protect data against accidental deletion or overwrites. When enabled, deleted objects are retained as noncurrent versions that remain accessible in your bucket until you explicitly remove them. This capability allows you to track object changes over time and recover specific versions whenever needed.
In this guided lab, you will learn how to enable Object Versioning on a Cloud Storage bucket and test its behavior by overwriting and deleting objects. By the end of the lab, you’ll understand how to recover previous versions of files stored in your bucket
Prerequisites
This lab assumes you have basic knowledge of creating a Cloud Storage Bucket.
If you find any gaps in your knowledge, consider taking this lab:
Objectives
In this lab, you will:
- Create a Cloud Storage bucket.
- Enable Object Versioning on the bucket.
- Upload and overwrite a file to generate multiple versions.
- Delete a file and recover it using Object Versioning.
Lab Steps
Create a Cloud Storage Bucket
1. On the Create a bucket page, enter your desired bucket name (should be unique).
2. Leave other configurations at their default values.
3. Click Create.
Enable Object Versioning
1. Navigate to the created bucket.
2. In the Protection section, enable Object Versioning.

3. Keep the checkbox unchecked and select Confirm.
Note:
- If you check this box, Google Cloud will automatically add lifecycle rules to control storage costs:
- Max. number of versions per object: 1 (only the latest version is kept).
- For overwrite protection, you’d need to increase this to at least 2 versions per object.
- The version count includes both live and noncurrent versions.
- Expire noncurrent versions after: 7 days (recommended for Standard storage class).
- Max. number of versions per object: 1 (only the latest version is kept).
- For the purpose of this lab, you should leave the checkbox unticked so you can observe multiple (unlimited) versions of the same object and practice recovering them manually. This ensures you see the full effect of Object Versioning without lifecycle rules automatically deleting older versions.

You can also enable Object Versioning during bucket creation by expanding the Choose how to protect object data settings before clicking Create.
Upload and Overwrite a File
1. Create a simple text file named notes.txt with the content:
Version 1: Initial content

2. Upload notes.txt to the bucket.

3. Modify the file locally to:
Version 2: Updated content

4. Upload the modified file again with the same name (notes.txt).
Note: You may see a message saying “Resolve object conflict.” This indicates that multiple versions of the same object exist. Confirm the overwrite to proceed.

- Cloud Storage will retain both versions.
Delete and Recover a File
1. In the bucket, delete notes.txt.
2. Click Show versions (or Show Live and noncurrent objects) to display all versions of objects.

3. Click the notes.txt (Noncurrent)

4. Locate the noncurrent version of notes.txt (identified by its generation number).

5. Restore or download the older version to recover the file.

Congratulations! You’ve completed the lab and successfully protected your Cloud Storage bucket against accidental deletes and overwrites using Object Versioning. You now know how to enable versioning, overwrite files safely, and recover deleted objects.