Recovering a disk from a snapshot
Note
You cannot recover a boot disk of an existing VM from a snapshot or image. However, you can create a new VM to recover a boot disk from a snapshot. To recover a boot disk on an existing VM, use Yandex Cloud Backup.
To create a disk from a snapshot:
-
In the management console
, select the folder where you want to create a disk. -
Select Compute Cloud.
-
In the left-hand panel, select
Disks. -
Click Create disk.
-
Enter a name for the disk. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
Provide a description for the disk, if required.
-
Select the availability zone the disk will be in.
-
Set the disk parameters: disk type, block size, and disk size.
-
In the Contents field, select
Snapshot
and then select the snapshot you need from the list below. Use the filter to find the snapshot. -
Optionally, under Encryption:
- Select Encrypted disk.
- In the KMS key field, select the key you created earlier. To create a new key, click Create new key.
Warning
You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption.
If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.
Alert
If you destroy the key or its version used to encrypt a disk, image, or snapshot, access to the data will be irrevocably lost. Learn more in Destroying key versions.
-
If required, select a schedule for automatic snapshot creation, or set up a new schedule. For more information about setting up schedules, see this guide.
You can create snapshots of network drives, such as HDDs, SSDs, and non-replicated SSDs, as well as ultra-high performance network storages with three replicas (SSD).
For non-replicated SSDs and ultra-high performance network storages with three replicas (SSD), the snapshot time is not determined.
To take snapshots of local disks residing on dedicated hosts, use Yandex Cloud Backup. This service supports Ubuntu, CentOS, CentOS Stream, and Windows Server.
When creating a disk, you can select only one snapshot schedule. Once the disk is created, you can add a few more schedules by following the instructions.
-
Click Create disk.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the CLI commands for managing disks and their snapshots:
yc compute disk create --help yc compute snapshot --help
-
Get a list of snapshots in the default folder:
yc compute snapshot list
Result:
+----------------------+----------------------+----------------------+----------+ | ID | NAME | PRODUCT IDS | STATUS | +----------------------+----------------------+----------------------+----------+ | fd84hanhvjql******** | disk-1-1668075122980 | f2ef3frbftr2******** | READY | | fd85mc22cosp******** | disk-2-1669114692462 | f2ef3frbftr2******** | READY | +----------------------+----------------------+----------------------+----------+
-
Select
ID
orNAME
of the snapshot you need. -
Create a disk from the selected snapshot.
yc compute disk create <disk_name> \ --source-snapshot-name <snapshot_name> \ --description <text_description_of_disk>
You can use the
--source-snapshot-name
or--source-snapshot-id
parameter to specify the snapshot.For more information about the
yc compute disk create
command, see the CLI reference. -
Get a list of disks in the default folder:
yc compute disk list
Result:
+----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | ID | NAME | SIZE | ZONE | STATUS | INSTANCE IDS | PLACEMENT GROUP | DESCRIPTION | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | a7lqgbt0bb9s******** | first-disk | 20401094656 | ru-central1-a | READY | a7lcvu28njbh******** | | | | a7lv5j5hm1p1******** | second-disk | 21474836480 | ru-central1-a | READY | | | | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
Get the same list with more details in YAML format:
yc compute disk list --format yaml
Result:
- id: fhm4aq4hvq5g******** folder_id: b1gm3og7ei7a******** created_at: "2018-10-29T07:43:06Z" name: first-disk description: my first disk via yc type_id: network-hdd zone_id: ru-central1-a size: "10737418240" status: READY - id: fhmo6rdqg5fo******** folder_id: b1gm3og7ei7a******** created_at: "2018-10-29T07:33:04Z" name: second-disk description: my second disk via yc type_id: network-hdd zone_id: ru-central1-a size: "8589934592" product_ids: - f2en2dtd08b5******** status: READY source_image_id: fdvk34al8k5n******** instance_ids: - fhm5b617fjnj********
- Get a list of snapshots using the SnapshotService/List gRPC API call or the list REST API method for the
Snapshot
resource. - Create a disk using the DiskService/Create gRPC API call or the create REST API method for the
Disk
resource. Specify the snapshot ID in your request.
Once created, the disk will get the CREATING
status. Wait until the disk status changes to READY
before using it.