Home Google CloudHow to Back Up Google Cloud VMs with Snapshots and Machine Images

How to Back Up Google Cloud VMs with Snapshots and Machine Images

by Knowledge Base Linux
How to Back Up Google Cloud — How to Back Up Google Cloud VMs with Snapshots and Machine Images

Backing up production virtual machines is not optional, and on Google Cloud the foundation of that strategy is compute engine snapshots. Compute engine snapshots capture the state of a persistent disk at a point in time, letting you roll back a failed upgrade, clone a server, or recover from accidental deletion in minutes. In this guide you will create compute engine snapshots manually, automate them with snapshot schedules, restore a disk and a full VM from a snapshot, use machine images for complete instance backups, and archive old snapshots for cheap long-term storage.

First, understand the three related tools. Snapshots back up a single persistent disk and are incremental: the first snapshot is a full copy, later snapshots store only changed blocks. Machine images back up an entire instance — all its disks, configuration, metadata, and permissions — and are ideal when you need to recreate an identical VM. Archive snapshots use a cheaper storage class designed for backups you rarely restore, similar to cold storage. Most teams combine all three: frequent compute engine snapshots for operational recovery, machine images before major changes, and archives for compliance retention.

Prerequisites for Compute Engine Snapshots – How to Back Up Google Cloud

  • A Google Cloud project with billing enabled and at least one Compute Engine instance running.
  • The gcloud CLI installed, authenticated, and configured with your project: gcloud config set project YOUR_PROJECT_ID.
  • Permissions to create snapshots, disks, and images — typically the Compute Admin role for the project.
  • Knowledge of your instance name, zone, and boot disk name, which you can list with gcloud compute instances list and gcloud compute disks list.

Compute engine snapshots schedule for automated daily backups of a cloud VM disk

Step 1: Create a Snapshot of a Boot Disk – How to Back Up Google Cloud

Creating compute engine snapshots takes one command. Replace the disk name and zone with your own values:

gcloud compute disks snapshot my-instance \
  --zone us-central1-a \
  --snapshot-names my-instance-backup-001 \
  --description "Backup before system upgrade"

For consistency, stop or quiesce applications that write heavily to disk before snapshotting, or at least schedule snapshots during low-traffic periods. A snapshot of a running system is crash-consistent, which is fine for most Linux servers, but databases benefit from a brief write pause or a pre-snapshot dump. Check progress and list your compute engine snapshots at any time:

gcloud compute snapshots list
gcloud compute snapshots describe my-instance-backup-001

Wait until the status shows READY before relying on the backup. If you keep regular Linux backups on other platforms too, our guide to automate Linux backups with rsync and cron covers the file-level side of the same strategy.

Step 2: Automate Backups with Snapshot Schedules

Manual backups get forgotten. Snapshot schedules create compute engine snapshots automatically according to a resource policy. First create a policy that takes daily snapshots and keeps them for seven days:

gcloud compute resource-policies create snapshot-schedule daily-backup \
  --region us-central1 \
  --daily-schedule \
  --start-time 02:00 \
  --retention-days 7 \
  --on-source-disk-delete keep-snapshots

Then attach the policy to each disk you want protected:

gcloud compute disks add-resource-policies my-instance \
  --zone us-central1-a \
  --resource-policies daily-backup

From now on, Google Cloud creates a snapshot every night and deletes snapshots older than the retention window automatically. Review the schedule periodically: retention that is too short leaves no recovery point after a slow-moving incident, while retention that is too long quietly inflates storage costs.

Step 3: Restore a Disk and VM from a Snapshot

A backup is only useful if restoring works. To recover, create a new disk from a snapshot, then create a new VM using that disk:

gcloud compute disks create my-instance-restored \
  --zone us-central1-a \
  --source-snapshot my-instance-backup-001

gcloud compute instances create my-instance-restored \
  --zone us-central1-a \
  --disk name=my-instance-restored,boot=yes,auto-delete=yes

Boot the restored instance, verify your applications and data, and update DNS or load balancer targets when you are satisfied. Keep the original instance stopped but intact until the restore is fully verified — never delete your only working copy during a recovery.

Step 4: Use Machine Images for Full Instance Backups

When a VM has multiple disks or complex configuration, a machine image is the better tool. Create one from a running or stopped instance:

gcloud compute machine-images create my-instance-image-001 \
  --source-instance my-instance \
  --source-instance-zone us-central1-a \
  --description "Full image before migration"

Later, recreate the complete instance — disks, machine type, labels, and network settings — from the image:

gcloud compute instances create my-instance-from-image \
  --zone us-central1-a \
  --source-machine-image my-instance-image-001

Use machine images before major OS upgrades, application migrations, or configuration overhauls, where rolling back a single disk would not restore the whole system state.

Step 5: Archive Snapshots and Understand Costs

Compute engine snapshots are incremental, so storage costs are lower than many administrators expect: after the first full snapshot, you pay only for blocks that changed between snapshots. Deleting an old snapshot does not delete data needed by newer ones — Google Cloud merges the required blocks automatically.

For backups you must keep for months or years but rarely restore, use the archive storage location when creating a snapshot:

gcloud compute disks snapshot my-instance \
  --zone us-central1-a \
  --snapshot-names my-instance-archive-001 \
  --storage-location us \
  --snapshot-type ARCHIVE

Archive snapshots cost significantly less per gigabyte than standard snapshots, in exchange for slower, less frequent access patterns. A practical tiering strategy is standard snapshots for the last seven to thirty days, then archive snapshots for monthly recovery points.

Best Practices for Compute Engine Snapshots

  • Test restores regularly. An untested backup is a hope, not a backup. Restore to a throwaway VM at least monthly and verify the application actually runs.
  • Label snapshots clearly. Apply labels such as env=prod and app=web so you can find, audit, and clean up backups by purpose and owner.
  • Store snapshots across regions. For critical systems, use multi-regional storage locations so a regional outage cannot take both your VMs and your backups offline.
  • Combine tools. Use compute engine snapshots for disks, machine images for whole instances, and file-level backups for databases and application data.
  • Monitor failures. Alert on failed scheduled snapshots; a silent failure discovered during an incident is the worst possible outcome.

Troubleshooting Compute Engine Snapshots

Snapshot Creation Is Slow or Fails

Large disks and busy systems take longer because the first snapshot copies all used blocks. If creation fails, check the disk state with gcloud compute disks describe, confirm the disk is attached or was properly detached, and retry during a quieter period. Application-consistent backups may also fail if a guest agent or script times out.

Quota Limits

Snapshot storage counts against regional persistent disk snapshot quotas. If you hit a limit, delete expired snapshots, shorten retention, or request a quota increase in the Cloud Console under IAM & Admin > Quotas.

Restoring to a Different Zone

Snapshots are global resources, so you can create a disk from a snapshot in any zone. However, the new disk’s type must be available in the target zone, and machine types differ between zones. Always specify the target zone explicitly on the disk and instance creation commands, and expect a new external IP unless you reserve and attach a static one.

Conclusion

With compute engine snapshots, snapshot schedules, and machine images, you have a complete, automated backup system for Google Cloud VMs: nightly incremental snapshots for fast recovery, machine images before risky changes, and archive snapshots for inexpensive long-term retention. Set up the schedule today, label everything, and schedule your first test restore — recovery you have practiced is recovery you can trust. For full technical details, see the official Compute Engine snapshots documentation.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.