Transferring files from Cloud Storage to VM

3,487 views
Skip to first unread message

Matt Weitzman

unread,
Dec 9, 2017, 12:10:48 PM12/9/17
to gce-discussion
Is there an easy way to transfer files from a google cloud storage bucket to a new instance?

Or to easier answer - i'm migrating files from one boot disk- VM machine to another. Whats the best solution for this? The new boot disk is smaller in size, so i'm not able to simply use it on the new VM machine...

 I've already pushed all the files over to storage thinking I can transfer them over to the new disk:

I attempted to flop the directories, but it doesn't seem to work.

gsutil cp -r gs://my-bucket dir

Thanks.

Taher (Cloud Platform Support)

unread,
Dec 11, 2017, 4:03:58 PM12/11/17
to gce-discussion

I understand you have already pushed your desired files into a bucket and need to know how to download those into the destination VM.


To answer your question, you can ssh into your destination VM either by clicking the SSH icon or by running gcloud compute ssh command from cloud shell; and then run the gsutil cp command from the VM to download the files. I have tried with the below command and it was successful.


gsutil cp -r gs://[bucket name] [directory in VM]

Hope this helps.

Taher (Cloud Platform Support)

unread,
Dec 14, 2017, 4:46:39 PM12/14/17
to gce-discussion

If your goal is to copy files from one instance to another, there are several ways to do that.


  1. You can use gcloud compute scp with the recursive option to transfer all the files in a directory.

  2. You can also follow the below steps

    1. Stop the instance

    2. Detach the disk from older instance

    3. Create a snapshot from the old instance’s disk

    4. Spin up a new VM with the snapshot.

Reply all
Reply to author
Forward
0 new messages