16

I created a snapshot of a VM instance via cloud console. I would like to know how I can restore an instance using a snapshot. The documentation for compute engine is not very helpful. The instance runs on Ubuntu. Thanks.

4 Answers 4

27

To restore an instance from a snapshot without deleting/re-creating the instance:

  1. Shut down the instance and detach the boot disk: gcloud beta compute instances detach-disk INSTANCE_NAME --disk BOOT_DISK_NAME

  2. Create a new disk from the snapshot: gcloud compute disks create DISK_NAME --source-snapshot SNAPSHOT_NAME

  3. Attach the disk created from step 2 as the boot disk: gcloud beta compute instances attach-disk INSTANCE_NAME --disk DISK_NAME --boot

Restoring the instance without deleting/re-creating the instance means that after restore, the instance will keep its IP address and other properties like tags, labels, etc.

5
  • 1
    consider delete the old disk if you want the new disk to have the same name
    – laviex
    Dec 22, 2018 at 6:44
  • 7
    This is unbelievable that this is the way to restore the snapshot on the machine, I feel like I have to be doing something wrong. This can't be the right solution to such simple task as snapshot restore.
    – pagep
    Feb 28, 2019 at 22:36
  • These three commands were enormously useful to me tonight. A thousand times, thank you.
    – GrantJ
    Aug 21, 2020 at 6:34
  • Thank you! :) Stack Overflow > GCP documentation :D
    – m4n0
    Sep 29, 2020 at 12:13
  • There is a way to do this with a Persistent disk snapshot? Oct 27, 2020 at 17:38
5

In Console, you can go to VM Instances from Compute Engine tab. There you click on '+Create Instance' and there in section of boot-disk, you can navigate to 'snapshots' tab and select the snapshot you took.

Like this from console, you can Restore your instance.

Let me know, if this doesn't work for you!

0
4

Try using:

gcloud compute disks \
create <NEW_INSTANCE_NAME> \
--source-snapshot <SNAPSHOT_NAME> \
--type pd-ssd \
--zone <ZONE>

You could find useful instruction here.

1

If you want to do it in the web interface, it's pretty easy. Edit your VM instance. Scroll down to your boot disk and click "x" next to the boot volume, then click create button. In the next window give your new volume a meaningful name, set up your snapshot schedule, and then under "source type" select "Snapshot". Choose your snapshot from the dropdown. If you have a customer managed/supplied key (not recommended) select it, otherwise leave it as google-managed key. Click create. Depending on disk size it might take a while. Be patient and let it finish the setup and then start your instance once it is al complete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.