gcloud compute resource-policies create snapshot-schedule Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud compute resource-policies create snapshot-schedule - create a Compute Engine Snapshot Schedule Resource Policy
- SYNOPSIS
gcloud compute resource-policies create snapshot-scheduleNAME--max-retention-days=MAX_RETENTION_DAYS(--weekly-schedule-from-file=PATH_TO_FILE|--start-time=START_TIME(--daily-schedule|--hourly-schedule=HOURS|--weekly-schedule=WEEKLY_CYCLE))[--description=DESCRIPTION][--on-source-disk-delete=ON_SOURCE_DISK_DELETE][--region=REGION][--guest-flush--snapshot-labels=[KEY=VALUE,…]--storage-location=LOCATION][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
- Create a Compute Engine Snapshot Schedule Resource Policy.
- EXAMPLES
- The following command creates a Compute Engine Snapshot Schedule Resource Policywith a daily snapshot taken at 13:00Z and a one day snapshot retention policy.
gcloudcomputeresource-policiescreatesnapshot-schedulemy-resource-policy--region=REGION--start-time=13:00--daily-schedule--max-retention-days=1 - POSITIONAL ARGUMENTS
NAME- Name of the resource policy to operate on.
- REQUIRED FLAGS
--max-retention-days=MAX_RETENTION_DAYS- Maximum number of days snapshot can be retained.
- Cycle Frequency Group.
Exactly one of these must be specified:
- Using a file:
--weekly-schedule-from-file=PATH_TO_FILE- A JSON/YAML file which specifies a weekly schedule. The file should contain thefollowing fields:
day: Day of the week with the same choices as
--weekly-schedule.startTime: Start time of the snapshot schedule with the same format as--start-time.For more information about using a file, seehttps://cloud.google.com/compute/docs/disks/scheduled-snapshots#create_snapshot_schedule.
Use a full or relative path to a local file containing the value ofweekly_schedule.
- Using command flags:
--start-time=START_TIME- Start time for the disk snapshot schedule in UTC. For example,
--start-time="15:00".This flag argument must be specified if any of the other arguments in this groupare specified.
- Exactly one of these must be specified:
--daily-schedule- Snapshot schedule starts daily at START_TIME.
--hourly-schedule=HOURS- Snapshot schedule occurs every n hours starting at START_TIME.
--weekly-schedule=WEEKLY_CYCLE- Snapshot schedule occurs weekly on WEEKLY_SCHEDULE at START_TIME.
WEEKLY_CYCLEmust be one of:monday,tuesday,wednesday,thursday,friday,saturday,sunday.
- OPTIONAL FLAGS
--description=DESCRIPTION- An optional, textual description for the backend.
--on-source-disk-delete=ON_SOURCE_DISK_DELETE- Retention behavior of automatic snapshots in the event of source disk deletion.
ON_SOURCE_DISK_DELETEmust be one of:apply-retention-policy- Continue to apply the retention window to automatically-created snapshots whenthe source disk is deleted.
keep-auto-snapshots- Keep automatically-created snapshots when the source disk is deleted. This isthe default behavior.
--region=REGION- Region of the resource policy to operate on. If not specified, you might beprompted to select a region (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:compute/regiongcloudconfigsetcompute/regionREGIONA list of regions can be fetched by running:
gcloudcomputeregionslistTo unset the property, run:
gcloudconfigunsetcompute/regionAlternatively, the region can be stored in the environment variable
.CLOUDSDK_COMPUTE_REGION - Snapshot properties
--guest-flush- Create an application consistent snapshot by informing the OS to prepare for thesnapshot process.
--snapshot-labels=[KEY=VALUE,…]- List of label KEY=VALUE pairs to add.
Keys must start with a lowercase character and contain only hyphens(
-), underscores (_), lowercase characters, andnumbers. Values must contain only hyphens (-), underscores(_), lowercase characters, and numbers.The label is added to each snapshot created by the schedule.
--storage-location=LOCATION- Google Cloud Storage location, either regional or multi-regional, where snapshotcontent is to be stored. If absent, a nearby regional or multi-regional locationis chosen automatically.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- These variants are also available:
gcloudalphacomputeresource-policiescreatesnapshot-schedulegcloudbetacomputeresource-policiescreatesnapshot-schedule
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-01-21 UTC.