google-compute-engine,automation,snapshot,incremental-backup"/>
  • 7
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

I have created the snapshot schedule policy with label daily,weekly,hourly.But I want an automate way so whenever i create the vm label based policy should be assigned to vm. or

automatically attach my scheduler to vm disks whenver i create new vm and snapshot would save directly to bucket?

Is any one have the automate script for this task??

Thanks in advance !

If you want to attach snapshot schedule policy to all VM's, you can run the below mentioned script:

#!/bin/bash
# loop through all disks within this project  and add snapshot schedule policy to all the VM’s
gcloud compute disks list | tail -n +2 | while read DISK_NAME ZONE c3 c4; do
gcloud compute disks add-resource-policies $DISK_NAME --resource-policies=ss-01 --zone $ZONE
done

However, If you want to automate snapshot schedule and snapshot create operation, you can follow the article here. At this moment, if you want to move the instance boot disk data to Google cloud storage, you can export a boot disk image to Cloud Storage as a tar.gz file that mention here.

  • 0
Reply Report
    • Thanks mahboob it works for me ! But as i get one more requirement for the same task...can we move this snapshots to storage bucket. ? Is it possible to export the snapshot as i read the google documents i only found to export the images to bucket
    • You can export the snapshots to bucket, however, you are not able to export snapshots directly to the gcp bucket. Please follow the below steps to export snapshots to a bucket: 1- create image based on the snapshot 2- create bucket and copy your bucket url then export your image with the following command gcloud alpha compute images export --destination-uri gs://test_buk04/testimage.vmdk --image expo-test-image --export-format vmdk --project yourprojectid

You can export the snapshots to bucket, however, you are not able to export snapshots directly to the gcp bucket. Please follow the below steps to export snapshots to a bucket:

  1. create image based on the snapshot
  2. create bucket and copy your bucket url then export your image with the following command:
gcloud alpha compute images export --destination-uri gs://test_buk04/testimage.vmdk --image expo-test-image --export-format vmdk --project yourprojectid
  • 0
Reply Report

Warm tip !!!

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

Trending Tags