SYM
SYM

Reputation: 355

Migrate Google compute engine instance to a different region

I am trying to migrate a couple of compute engine instances from Europe to Asia. I need to do this because most of the users for those servers are in Asia and they get faster access to servers in their region. I am trying following command.

gcloud compute instances move asiawindows1 --zone europe-west1-d  --destination-zone asia-east1-c

I get following error when I try this

Instances belonging to subnetworks cannot be moved interregionally.

What is the best way to move these servers without manually setting them up in the Asia zone?

Upvotes: 20

Views: 13730

Answers (4)

honeytechiebee
honeytechiebee

Reputation: 162

GCP Guide says Snapshot the root disk, create an image, and use the image for the new VM root disk.

Upvotes: -1

Arundev
Arundev

Reputation: 1944

If the auto move is not happening, you can try the manual move of vm instance. First list all the disk to choose the right disk to take snapshot.

gcloud compute disks list

Identify the name of disk from the list and create a snapshot of that one

gcloud compute disks snapshot <disk_name> --snapshot-names <snapshot_disk_name> --zone <current_zone>

Now you can delete your instance in you are trying to move.

gcloud compute instances delete <instance_name> --zone <instance_zone>

Next step is to create a disk from the snapshot you have created in the new zone where you want to create the instance.

gcloud compute disks create <disk_name> --source-snapshot <snapshot_disk_name> --zone <new_zone_name>

Now, you have to create an instance with the disk you have just created mounted on it. Please choose the right machine type for your need, here am going to create an instance with f1-micro.

gcloud compute instances create <instance_name> --machine-type f1-micro --zone <new_zone> 
--disk name=<disk_name>,boot=yes,mode=rw

That's it.

Now if you want you can delete the snapshot

gcloud compute snapshots delete <snapshot_name> 

Upvotes: 5

krekto
krekto

Reputation: 1487

Follow steps below in Google Cloud Platform

  1. Create snapshot of your VM instance
  2. Create disk with this snapshot
  3. Create image with disk created
  4. Create a new instance using the image created in steps above and change your zone

Upvotes: 27

Vikki
Vikki

Reputation: 101

The command you are using is for moving across zones of same region and not across regions.

You can create an image of your instance and use the image to create a new instance in different region.

Upvotes: 10

Related Questions