Cloning is an art!

Duplicating your VM is the excellent way to fast track your project without human error. There are some reasons you may want to clone your VM for quick application setup.

Update: Google has made it lot easier now to clone the VM.

  • Login to GCP and go to VM instances under Compute Engine
  • Click on respective VM to be cloned
  • On top, you will see a clone button

  • Adjust the necessary (name, machine type, etc.) according to the requirement
  • Click on create

Much easy!

The following I wrote when “CLONE” button didn’t exist.

Lately, I set up my tools website on one Google Cloud VM and had to set up another one for high-availability and cloning was life-saver.

Not only it was faster but also I didn’t have to go through all the configuration, installation manually which has excellent room for missing/human error.

You may want to consider cloning VM if:

  • You want to save time
  • You should setup replica for another reason
  • Have to set up multiple instances for high-availability
  • Want to avoid manual work/human error

If you are in a situation to duplicate the Google Cloud Virtual Machine, then here is how you can do it.

This is two steps process. First where you create a snapshot and next you use that snapshot to create a VM instance.

You can do this while VM is running. This will ensure you don’t have any downtime and have the same replica of existing VM.

  • Go to VM instances under Computer Engine
  • Click on Snapshots at left navigation

  • Click Create Snapshot
  • Enter the name and select the source disk of the VM which you want to get it cloned.

It will take few seconds (based on the disk size), and you will get a confirmation on completion. You can see the newly created snapshot in the list.

Now, it’s time to create the instance from the snapshot.

  • Go inside the snapshot from the list and click “Create Instance.”

  • Enter the new instance details

Note: Google will not show you the existing VM instance configuration like CPU/Memory, so you got to ensure they are at your needs level.

You may also need to select firewall configuration like if you want to allow HTTP or HTTPS traffic.

  • Click create once you have changed the configuration settings

It will take few seconds based on the disk size and once done you will see the newly created VM in the list.

To confirm the VM is cloned with the data, log into newly created VM and verify.

I found this is the quickest way to ensure VM on Google Cloud Platform is duplicated.

If you are interested in learning GCP, then I would recommend taking this Architecting with Google Cloud course.