Sync a folder to a bucket

Mirror a local folder to GCS, -d deletes extra files in the bucket; this is the newer replacement for gsutil rsync.

gcloud storage rsync -r -d ./build gs://<name>/site

tool
gcloud8 commands
tags
gclouddiskcloud

More gcloud commands

  • gcloud auth activate-service-account --key-file=key.json && gcloud config set project <id>

    Log in as a service account in CI and set the project; workload identity is safer than long-lived key files.

  • gcloud container clusters get-credentials <cluster> --region <id> --project <id>

    Add a GKE cluster to kubeconfig; since Kubernetes 1.26 you need gke-gcloud-auth-plugin in PATH.

  • gcloud compute instances list --format="table(name,status,EXTERNAL_IP)" --filter="status=RUNNING"

    Print your own table of running VMs and their public IPs using --format and --filter.

  • gcloud projects get-iam-policy <id> --flatten="bindings[].members" --format="table(bindings.role,bindings.members)"

    Check who has which role; --flatten turns nested bindings into one row per member.

  • gcloud logging read 'severity>=ERROR' --limit 20 --freshness=1h --format='value(timestamp,resource.type,textPayload)'

    Get errors from the last hour across the project; --freshness keeps the query from scanning old logs.

all 8 gcloud commands