• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Cloud

GCP Backup Instance

April 3, 2022

Here’s the script to backup GCP disks.

#!/bin/bash
now=$(date +%s)
disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)")
for disk in $disks
do
  gcloud compute disks snapshot $disk \
  --snapshot-names=$disk-$now \
  --zone=us-central1-a \
  --project=project-id \
  --async
done

#!/bin/bash now=$(date +%s) disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)") for disk in $disks do gcloud compute disks snapshot $disk \ --snapshot-names=$disk-$now \ --zone=us-central1-a \ --project=project-id \ --async done

Filed Under: Cloud, Linux Tagged With: backup, disks, gcp, manual, snapshots

GCP Project Quotas

March 8, 2022

Here’s how to get your project quotas in GCP.

gcloud compute project-info describe --project your-project-id

gcloud compute project-info describe --project your-project-id

Filed Under: Cloud Tagged With: gcloud, gcp, project, quotas

GCP Regional Quotas

March 8, 2022

Here’s how to get Regional Quotas for your project in GCP.

gcloud compute regions describe us-central1 --project your-project-id

gcloud compute regions describe us-central1 --project your-project-id

Filed Under: Cloud Tagged With: gcloud, gcp, project, quotas, regional

GCP Monitor Service Account

February 24, 2022

You can monitor the success or failure of a service account in GCP.

gcloud policy-intelligence query-activity \
--activity-type=ACTIVITY_TYPE \ 
--project=PROJECT_ID \
--limit=LIMIT

gcloud policy-intelligence query-activity \ --activity-type=ACTIVITY_TYPE \ --project=PROJECT_ID \ --limit=LIMIT

The two options you can use for ACTIVITY_TYPE are:

  • serviceAccountKeyLastAuthentication
  • serviceAccountLastAuthentication

Filed Under: Cloud Tagged With: gcp, keys, monitor, service account

GCP Windows Password Reset

February 14, 2022

Instead of the GCP Console, you can reset Windows Server password via gcloud.

gcloud compute reset-windows-password server-name \
--zone us-central1-a \
--project project-id

gcloud compute reset-windows-password server-name \ --zone us-central1-a \ --project project-id

Username and password will generated.

Filed Under: Cloud Tagged With: gcloud, gcp, password, reset, windows

Google SDK SSH Mac Terminal

February 14, 2022

I’m having trouble logging in using Google SDK Compute SSH on a Mac Terminal.

Here’s the fix.

gcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2>&1

gcloud compute ssh USERNAME@SERVER --zone ZONE --project PROJECTID --internal-ip 2>&1

There was an issue with a redirect to another shell.

Filed Under: Cloud, Linux Tagged With: compute, gcp, mac, redirect, sdk, ssh, terminal

GCP Compute Startup Script

February 12, 2022

How to add startup and shutdown scripts on GCP Compute Engine.

Startup Script

gcloud compute instances add-metadata servername \
--project project-id \
--zone us-central1-c \
--metadata=startup-script='#! /bin/bash
sudo -i
echo "Time: $(date)" >> /tmp/date.txt'

gcloud compute instances add-metadata servername \ --project project-id \ --zone us-central1-c \ --metadata=startup-script='#! /bin/bash sudo -i echo "Time: $(date)" >> /tmp/date.txt'

Shutdown Script

gcloud compute instances add-metadata servername \
--project project-id \
--zone us-central1-c \
--metadata=shutdown-script='#! /bin/bash
# Shuts down Apache server
/etc/init.d/apache2 stop'

gcloud compute instances add-metadata servername \ --project project-id \ --zone us-central1-c \ --metadata=shutdown-script='#! /bin/bash # Shuts down Apache server /etc/init.d/apache2 stop'

Filed Under: Cloud Tagged With: compute, gcloud, metadata, script, startup

Set Terminal Browser to Firefox

February 7, 2022

Every time I log in to Google Cloud, it’s using the Chromium.

Set BROWSER env to Firefox instead.

export BROWSER=/usr/bin/firefox

export BROWSER=/usr/bin/firefox

Login to GCP. It should open up Firefox browser instead of Chromium.

gcloud auth login

gcloud auth login

Add it your .bashrc or .bashprofile if you want it to be permanent.

Filed Under: Cloud Tagged With: auth, browser, chromium, firefox, gcloud, login, terminal

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 45
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023