GCP PlayCloud Labs
-
GCP PlayCloud Labs
-
Guided Lab: Creating a Cloud Storage Bucket
-
Guided Lab: How to Launch a GCP Compute Engine Linux Instance
-
Guided Lab: Creating a Cloud SQL Instance
-
Guided Lab: Creating a Cloud NAT Gateway
-
Guided Lab: Running SQL Commands in Cloud SQL Studio
-
Guided Lab: Hosting a Static Website in Google Cloud Storage Bucket
-
Guided Lab: Creating and Restoring Cloud SQL Backups
-
Guided Lab: Vertically Scaling a VM Instance
-
Guided Lab: Creating a Custom Image from a VM Instance with Web Server in Google Cloud
-
Guided Lab: Setting up a Web Server on a VM Instance
-
Guided Lab: Creating a Spot VM Instance
-
Guided Lab: Exploring Instance Metadata in Google Cloud
-
Guided Lab: Setting Up and Managing a Database on a VM Instance
-
Guided Lab: Integrating Cloud SQL Database instance with a VM instance
-
Guided Lab: Connecting Cloud SQL Database with MySQL Workbench (Local)
-
Guided Lab: Creating a VM Using Instance Templates
-
Guided Lab: Installing WordPress on an Ubuntu VM Instance with LEMP Stack
-
Guided Lab: Reserving or Promoting a Static IP Address for a VM Instance
-
Guided Lab: Creating a Google Kubernetes Engine (GKE) Cluster
-
Guided Lab: Protecting Data on Cloud Storage Bucket Against Accidental Delete and Overwrite Using Object Versioning
-
Guided Lab: Connecting to a Kubernetes Engine Cluster
-
Guided Lab: Creating and Managing Instance Groups in Compute Engine
-
Guided Lab: Configuring Shielded VM Options
-
Guided Lab: SSH Access to GCP VM Instance from Local Machine using SSH Key Pair
-
Guided Lab: Deploying a Simple Web Application on GKE
-
Guided Lab: Configuring Firewall Rules to Secure and Access a VM
-
Guided Lab: Establishing VPC Peering for Secure Cross‑Network Communication
-
Guided Lab: Creating a Custom Virtual Private Cloud (VPC)
-
Guided Lab: Using Startup Scripts in GCP VM Instances
-
Guided Lab: Deploying a LAMP Stack on a Compute Engine VM
-
Guided Lab: Managing Cloud Storage Buckets via SSH Commands
-
Guided Lab: Guarding Your VM with Deletion Protection
-
Guided Lab: Using Cloud Storage Lifecycle Rules to Automate Object Management
-
Guided Lab: Guarding Your Cloud SQL Instances with Deletion Protection
-
Guided Lab: Exploring Google Cloud Storage Classes
-
Guided Lab: Setting Up a Linux Bastion Host on GCP
-
Guided Lab: Uploading, Organizing, and Managing Objects in Cloud Storage
-
Guided Lab: Creating an Application Load Balancer
-
Guided Lab: Creating a Network Load Balancer
-
Guided Lab: Creating VM Snapshots and Restoring a VM from a Snapshot
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.