Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restore instance using snapshot in Google Compute Engine?

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.

like image 545
MisterAverageDeveloper Avatar asked Feb 27 '17 02:02

MisterAverageDeveloper


People also ask

How do I restore a snapshot from a backup?

Under the Backups tab, check the box next the back up you'd like to use. WARNING: This will wipe the current content of your server and replace it with the backup content. Click the Restore Virtual Environment button. You will receive a confirmation message that your restoration has been scheduled.

What is snapshot in compute engine?

Snapshot deletionCompute Engine uses incremental snapshots so that each snapshot contains only the data that has changed since the previous snapshot. For unchanged data, snapshots reference the data in previous snapshots. Storage costs for persistent disk snapshots charge only for the total size of the snapshot.


4 Answers

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.

like image 75
Sirui Sun Avatar answered Oct 24 '22 04:10

Sirui Sun


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.

like image 27
mike.Datavici Avatar answered Oct 24 '22 02:10

mike.Datavici


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!

like image 5
amitam Avatar answered Oct 24 '22 04:10

amitam


Try using:

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

You could find useful instruction here.

like image 4
Davide Biraghi Avatar answered Oct 24 '22 04:10

Davide Biraghi