Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to move instance or snapshot across different projects

I am looking to move GCE instance or snapshot to different project I have access to. Is that something available in GCE?

like image 386
Maulik Dholaria Avatar asked Sep 30 '22 14:09

Maulik Dholaria


1 Answers

There aren't any features by default that would allow you to move them to a different project. However, there are workarounds. The following is probably just one of many ways to do so.

To save a disk across projects you will need to use an image. If you can’t use the standard imagebundle tool, you can use the "dd" command. On a temporary disk that’s bigger than the one you want to image, run this:

$ dd if=/dev/disk/by-id/google-diskname of=disk.img bs=5M

You can then run the following to copy it over to Google Cloud Storage for example:

$ gsutil cp disk.img gs://yourbucket/your-image.img

And later, you can:

$ gsutil cat gs://yourbucket/your-image.img | \
     dd of=/dev/disk/by-id/google-newdisk bs=5M

In summary, you can make an image of your disk, use GCS to send it to over to another project and then use the 'snapshot' on the newly created disk to have a ready image based on which you can create additional instances for that project.

PS: It is also possible to create custom images for use in GCE. If you create a properly configured custom image, you can have it uploaded to any project and create instances directly from it. See this article.

like image 181
Boyan Avatar answered Oct 03 '22 04:10

Boyan