Recently I had to clone an existing VM in Google Cloud. Unfortunately there's no built-in functionality for this and the suggestion/documentation has some pitfalls. The basic process is:
- Prepare your instance for cloning (In case of Windows machine run gcesysprep utility)
- Create a snapshot of OS disk and all other disks
- Create a new instance by selecting the snapshot of the OS disk and adding snapshots from other disks
- Start the new instances
The above is supposed to be the safest way, instead of doing a snapshot "on the fly" when the instance is running. However I found out that gcesysprep actually did break:
- Installed SSL certificate. Any installed certificate in the old server will not work in the new instance. If you're hosting HTTPS sites that's a big issue. You will need to export the certificates first and reinstall them again.
- Timezone was not restored correctly. Easy to fix, but if you don't pay attention you may run into issue.
I did some other tests using "on the fly" snapshots and didn't have any issue. So my recommendation is to take "on the fly" snapshots of all disks (Enable VSS), create a new instance from the snapshots and you're fine to go :)