Overview and What You Will Learn
In this lab, you will configure a snapshot schedule for a Persistent Disk, enable automated backups on a Cloud SQL instance, and perform an actual test restore - the step most teams skip, and the one that genuinely proves the backup works.
Why This Matters in Production
A team configures nightly backups for their production database, sees the backup job report success every single night for a year, and only discovers during a real data-loss incident that the backup had actually been silently failing to capture a critical table for months. A completed backup job only proves data was written somewhere - it says nothing about whether that data can actually be restored into a working state.
Core Principles
Backup and disaster recovery in GCP spans several service-specific mechanisms, each protecting a different type of resource, and each needing its own actual restore test to be genuinely trustworthy.
+------------------------------------------+| Persistent Disk Snapshots || Point-in-time copies of a disk's data || Can be scheduled automatically |+------------------------------------------+| Cloud SQL Automated Backups || Daily backups plus point-in-time recovery || within the retention window |+------------------------------------------+| Restore Testing || The step that actually proves either of the || above genuinely works |+------------------------------------------+Detailed Step-by-Step Practical Lab
- Create a project, a disk, and a VM to demonstrate snapshot scheduling:
gcloud projects create gcp-backup-lab-2026 --name="Backup and DR Lab"gcloud config set project gcp-backup-lab-2026gcloud services enable compute.googleapis.com sqladmin.googleapis.com gcloud compute disks create disk-app-data-backup-test \ --zone=asia-south1-a \ --size=20GB \ --type=pd-ssd- Create a Snapshot Schedule defining daily automated snapshots with a retention period:
gcloud compute resource-policies create snapshot-schedule daily-snapshot-policy \ --region=asia-south1 \ --daily-schedule \ --start-time=03:00 \ --max-retention-days=14- Attach that schedule to the disk:
gcloud compute disks add-resource-policies disk-app-data-backup-test \ --zone=asia-south1-a \ --resource-policies=daily-snapshot-policy- Trigger a manual snapshot immediately, rather than waiting for the next scheduled run, to have something concrete to restore in this lab:
gcloud compute disks snapshot disk-app-data-backup-test \ --zone=asia-south1-a \ --snapshot-names=snapshot-manual-test- Perform an actual test restore - create a new disk from that snapshot, proving the backup genuinely works:
gcloud compute disks create disk-restored-from-snapshot \ --zone=asia-south1-a \ --source-snapshot=snapshot-manual-testNoteThis restored disk is a completely new, independent disk created from the snapshot's data - attaching it to a test VM and verifying the actual file contents match what was expected is what genuinely proves the backup works, not just the fact that the create-disk-from-snapshot command completed without an error.
- Create a Cloud SQL instance with automated backups enabled:
gcloud sql instances create pg-backup-test \ --database-version=POSTGRES_15 \ --tier=db-f1-micro \ --region=asia-south1 \ --backup-start-time=03:00 \ --enable-bin-log- Trigger an on-demand backup rather than waiting for the scheduled run:
gcloud sql backups create --instance=pg-backup-test- List available backups and restore to a new instance to test the restore process:
gcloud sql backups list --instance=pg-backup-test gcloud sql instances clone pg-backup-test pg-backup-test-restored- Clean up:
gcloud compute disks delete disk-app-data-backup-test disk-restored-from-snapshot --zone=asia-south1-a --quietgcloud compute snapshots delete snapshot-manual-test --quietgcloud compute resource-policies delete daily-snapshot-policy --region=asia-south1 --quietgcloud sql instances delete pg-backup-test pg-backup-test-restored --quietgcloud projects delete gcp-backup-lab-2026 --quietProduction Best Practices & Common Pitfalls
Common MistakeConfiguring backups and never actually performing a test restore. A backup job completing successfully only proves data was written to a snapshot or backup somewhere - it does not prove that data can actually be restored into a working state when it's genuinely needed.
TipSchedule a real restore test periodically - quarterly is a reasonable starting cadence for most production workloads - rather than treating backup configuration as a one-time setup task that never needs revisiting.
- Snapshot Schedules and retention policies should match actual business and compliance requirements, not an arbitrary default. A workload with a 7-year regulatory retention requirement needs a policy configured for that, not the default short retention window shown in this lab.
- Cloud SQL's point-in-time recovery only works within the configured retention window, and requires binary logging (
--enable-bin-log) to be enabled - without it, only the daily backup snapshots themselves are available for restore, not recovery to an arbitrary point in time between them.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
gcloud compute resource-policies create snapshot-schedule |
Define an automated snapshot schedule |
gcloud compute disks snapshot |
Trigger a manual, on-demand disk snapshot |
gcloud compute disks create --source-snapshot= |
Restore a disk from a snapshot |
gcloud sql instances clone |
Restore a Cloud SQL instance from a backup |