How to download GCP instance to your local machine

You may have a reason to download a VM instance from GCP to your local machine. here is how …

The basic workflow is

Convert your instance disk to image file

Save your image file to Object Storage bucket

Download from your bucket

  1. Assume you already installed gcloud SDK (CLI)

the disk that want to convert is “client”

export mydisk=client
exportzone=asia-east2-c
gcloud compute images create my-image \
— source-disk ${mydisk} \
— source-disk-zone ${zone}

2. create bucket and export images to bucket

3. copy image file to your local compute.

gsutil cp gs://my-bucket-yagosys/my-image-file.tar.gz .

if your compute is behind firewall. you may configure proxy for your gcloud. here is how

gcloud config set proxy/type http

gcloud config set proxy/address 127.0.0.1

gcloud config set proxy/port 8123