Hi @farzher ,
Welcome to Google Cloud Community!
Here’s a common ways to achieve a local backup of your machine image:
Exporting to a Cloud Storage Bucket:
This is the most recommended and reliable method. You export your Machine Image to a storage bucket, which creates a raw disk image file you can then download locally.
Steps:
1. Create a Google Cloud Storage (GCS) Bucket:
- If you don’t already have one, create a GCS bucket in the same region as your Machine Image. You can do this through the Google Cloud Console, the gsutil command-line tool, or the Cloud SDK.
- Example using gsutil:
gsutil mb -l <REGION_OF_YOUR_MACHINE_IMAGE> gs://<YOUR_BUCKET_NAME>
2. Export the Machine Image:
- Use the gcloud compute images export command:
gcloud compute images export \
--destination-uri="gs://<YOUR_BUCKET_NAME>/<YOUR_EXPORTED_IMAGE_NAME>.tar.gz" \
--image="<YOUR_MACHINE_IMAGE_NAME>"
\
--project="<YOUR_PROJECT_ID>" \
--export-format=tar.gz
- <YOUR_BUCKET_NAME>: The name of the bucket you created.
- <YOUR_EXPORTED_IMAGE_NAME>: The desired name for the exported file (e.g., my-image-backup).
- <YOUR_MACHINE_IMAGE_NAME>: The name of the Machine Image you want to back up.
- <YOUR_PROJECT_ID>: Your Google Cloud Project ID.
- –export-format=tar.gz: Specifies that the export should be a compressed TAR archive of the raw disk image.
3. Download the Exported File:
- Use gsutil cp to copy the file to your local machine:
gsutil cp gs://<YOUR_BUCKET_NAME>/<YOUR_EXPORTED_IMAGE_NAME>.tar.gz /path/to/your/local/directory
- /path/to/your/local/directory: The directory on your local machine where you want to save the file.
4. Extract the RAW disk image (Optional):
- If you want to access the raw disk image, extract the tar.gz file using a tool like tar:
tar -xvzf <YOUR_EXPORTED_IMAGE_NAME>
tar.gz
- This will give you a .raw or .img file.
For additional reference, you may check the documentation below:
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.