Created
August 1, 2021 20:10
-
-
Save TomTasche/886d7034d1cc875c4536c6850c6f6e1c to your computer and use it in GitHub Desktop.
Recreating boot disk of a live instance from last snapshot on Google Cloud Platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stop instance | |
gcloud compute instances stop YOURINSTANCE --zone=YOURZONE | |
# remove boot disk from instance | |
gcloud compute instances detach-disk YOURINSTANCE --zone=YOURZONE --disk YOURDISK | |
# delete old boot disk | |
gcloud compute disks delete YOURDISK --zone=YOURZONE | |
# find last snapshot | |
gcloud compute snapshots list --sort-by=~creationTimestamp --limit=1 | |
# create disk from last snapshot | |
gcloud beta compute disks create YOURDISK --type=pd-balanced --size=100GB --zone=YOURZONE --source-YOURSNAPSHOT | |
# attach new disk to instance | |
gcloud compute instances attach-disk YOURINSTANCE --zone=YOURZONE --disk YOURDISK --boot | |
# start instance | |
gcloud compute instances start YOURINSTANCE --zone=YOURZONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment