google-compute-engine,snapshot"/>
  • 8
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

Trying to fire off a gcloud snapshot from a cron job on a ubuntu compute-engine. When executed from an ssh session:

gcloud compute disks snapshot disk-1 --zone=us-west1-b --snapshot-names=${snapshot-name}

creates a snapshot with the given name in zone "us-west1-b"

However, the same statement issued from a cron job creates the snapshot in region "us"

Can anyone explain this and how to get the snapshot created in the desired zone?

Not sure if this matters or not, but the vm is in us-west1-b (Oregon), so the cron job executes from that zone. I am in Montana, so probably am considered in us-west3 (Utah) when executing the command from ssh.

As per the documentation, a disk snapshot can be created in a Region or a Multi-region. It can't be created in a Zone.

By default the snapshot location is chosen automatically based on the source disk location: it is created in a nearby multi-regional location closest to the region of the source disk. Neither the VM location nor account location affect the default location of the snapshot. gcloud command line parameters --region=REGION and --zone=ZONE define a region and a zone of the source disk, and don't influence the snapshot location too.

In the initial question the snapshot location is not specified. The source disk disk-1 is located in the region us-west1. Therefore its snapshot is created in the default location that is a Multi-region us.

You can specify the snapshot location with the gcloud command line parameter --storage-location=LOCATION that is the Cloud Storage multi-region (us, eu, asia) or the Cloud Storage region (like us-central1, us-east1, europe-west1, asia-west1, etc).

  • 0
Reply Report
      • 1
    • ok, now I still don't understand; it complains about the --region and --storage-location arguments: gcloud compute disks snapshot my-disk --region us-west1 --storage-location us-west1 --snapshot-names=snap-01 --csek-key-file=/home/me/keyfile.json produces the errors: unrecognized arguments: --region us-west1 --storage-location us-west1
      • 2
    • apparently the documentation is wrong. It accepts --zone as an argument, but not --region; and it does not accept --storage-location.
      • 2
    • If the disk disk-1 was created as Zonal (with the GCP Console option Replicate this disk within region unset), the command gcloud compute disks snapshot needs the --zone parameter to specify the source disk location.

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags