Back to Course

GCP PlayCloud Labs

0% Complete
0/0 Steps
  1. GCP PlayCloud Labs
  2. Guided Lab: Creating a Cloud Storage Bucket
  3. Guided Lab: How to Launch a GCP Compute Engine Linux Instance
  4. Guided Lab: Creating a Cloud SQL Instance
  5. Guided Lab: Creating a Cloud NAT Gateway
  6. Guided Lab: Running SQL Commands in Cloud SQL Studio
  7. Guided Lab: Hosting a Static Website in Google Cloud Storage Bucket
  8. Guided Lab: Creating and Restoring Cloud SQL Backups
  9. Guided Lab: Vertically Scaling a VM Instance
  10. Guided Lab: Creating a Custom Image from a VM Instance with Web Server in Google Cloud
  11. Guided Lab: Setting up a Web Server on a VM Instance
  12. Guided Lab: Creating a Spot VM Instance
  13. Guided Lab: Exploring Instance Metadata in Google Cloud
  14. Guided Lab: Setting Up and Managing a Database on a VM Instance
  15. Guided Lab: Integrating Cloud SQL Database instance with a VM instance
  16. Guided Lab: Connecting Cloud SQL Database with MySQL Workbench (Local)
  17. Guided Lab: Creating a VM Using Instance Templates
  18. Guided Lab: Installing WordPress on an Ubuntu VM Instance with LEMP Stack
  19. Guided Lab: Reserving or Promoting a Static IP Address for a VM Instance
  20. Guided Lab: Creating a Google Kubernetes Engine (GKE) Cluster
  21. Guided Lab: Protecting Data on Cloud Storage Bucket Against Accidental Delete and Overwrite Using Object Versioning
  22. Guided Lab: Connecting to a Kubernetes Engine Cluster
  23. Guided Lab: Creating and Managing Instance Groups in Compute Engine
  24. Guided Lab: Configuring Shielded VM Options
  25. Guided Lab: SSH Access to GCP VM Instance from Local Machine using SSH Key Pair
  26. Guided Lab: Deploying a Simple Web Application on GKE
  27. Guided Lab: Configuring Firewall Rules to Secure and Access a VM
  28. Guided Lab: Establishing VPC Peering for Secure Cross‑Network Communication
  29. Guided Lab: Creating a Custom Virtual Private Cloud (VPC)
  30. Guided Lab: Using Startup Scripts in GCP VM Instances
  31. Guided Lab: Deploying a LAMP Stack on a Compute Engine VM
  32. Guided Lab: Managing Cloud Storage Buckets via SSH Commands
  33. Guided Lab: Guarding Your VM with Deletion Protection
  34. Guided Lab: Using Cloud Storage Lifecycle Rules to Automate Object Management
  35. Guided Lab: Guarding Your Cloud SQL Instances with Deletion Protection
  36. Guided Lab: Exploring Google Cloud Storage Classes
  37. Guided Lab: Setting Up a Linux Bastion Host on GCP
  38. Guided Lab: Uploading, Organizing, and Managing Objects in Cloud Storage
  39. Guided Lab: Creating an Application Load Balancer
  40. Guided Lab: Creating a Network Load Balancer
  41. Guided Lab: Creating VM Snapshots and Restoring a VM from a Snapshot
Lesson 21 of 41
In Progress

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).
  • 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.

Skip to content