• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

add

GCP Adding Labels To Snapshots

July 1, 2023

Here’s how to add labels to snapshots. It will cycle through from a list of disks.

#!/bin/bash
ts=$(date +%Y%m%d-%H%M%S)
log="add-labels-logs-$ts"
>$log
disks='manual-disks.txt'
now=$(date +%s)
epoch=$(date +%s -d "+14 days")
while read -r project snapshot; do
   echo "Project: $project"
   gcloud compute snapshots add-labels $snapshot --labels=delete-after=$epoch --project $project
done < $disks

#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log="add-labels-logs-$ts" >$log disks='manual-disks.txt' now=$(date +%s) epoch=$(date +%s -d "+14 days") while read -r project snapshot; do echo "Project: $project" gcloud compute snapshots add-labels $snapshot --labels=delete-after=$epoch --project $project done < $disks

Filed Under: Cloud Tagged With: add, gcp, labels, snapshots

GCP Add Labels To Snapshots

June 20, 2023

Here’s the command to add labels to a snapshot.

gcloud compute snapshots add-labels SNAPSHOTNAME --labels=KEY=VALUE --project PROJECT

gcloud compute snapshots add-labels SNAPSHOTNAME --labels=KEY=VALUE --project PROJECT

Filed Under: Cloud Tagged With: add, gcp, labels, snapshots

Add Snapshot Schedules to Disks

May 24, 2023

How to add Snapshot Schedules to disks in Terraform. Add this to your existing VM.

resource "google_compute_disk_resource_policy_attachment" "hourly_attachment" {
  name = "hourly-snapshots"
  disk = google_compute_instance.test.name
  zone = "us-central1-c"
}
 
resource "google_compute_disk_resource_policy_attachment" "daily_attachment" {
  name = "daily-snapshots"
  disk = google_compute_instance.test.name
  zone = "us-central1-c"
}

resource "google_compute_disk_resource_policy_attachment" "hourly_attachment" { name = "hourly-snapshots" disk = google_compute_instance.test.name zone = "us-central1-c" } resource "google_compute_disk_resource_policy_attachment" "daily_attachment" { name = "daily-snapshots" disk = google_compute_instance.test.name zone = "us-central1-c" }

Filed Under: Cloud Tagged With: add, policy, resource, schedules, snapshot, terraform

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 10
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023