Creating a disk snapshot

A disk snapshot is a copy of the disk file system at a certain point in time.

Preparation

A disk snapshot contains only the data written to disk when creating the snapshot. If the disk is attached to a running VM, the cache of the apps and OS will not be included in the snapshot.

To ensure the integrity of the snapshot data:

For Linux systems:

  1. Stop all disk write operations in the apps.
  2. Run one of the following commands:
    • sync to write the OS cache to disk
    • fsfreeze -f to freeze the file system. To unfreeze it, run the fsfreeze --unfreeze command.

For any other systems:

  1. Stop the VM (see Stop).
  2. Wait until the VM's status changes to STOPPED.

Creating a snapshot

To create a disk snapshot:

  1. In the management console, select the folder where the disk is located.

  2. Click on the Compute Cloud tile.

  3. On the Virtual machines page, go to the Disks tab.

  4. In the line with the disk name, click image and select the Create snapshot command.

  5. Enter the snapshot name.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

  6. If necessary, enter an arbitrary text description of the snapshot.

  7. Click Create snapshot.

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.

  1. See the description of the CLI's create snapshot commands:

    $ yc compute snapshot create --help
    
  2. Select the disk to take a snapshot of. To get a list of disks in the default folder, run the command:

    $ yc compute disk list
    +----------------------+--------------+-------------+---------------+--------+----------------------+-------------------------+
    |          ID          |     NAME     |    SIZE     |     ZONE      | STATUS |     INSTANCE IDS     |       DESCRIPTION       |
    +----------------------+--------------+-------------+---------------+--------+----------------------+-------------------------+
    | a7lqgbt0bb9s40tifuhc | first-disk   | 20401094656 | ru-central1-a | READY  | a7lcvu28njbhnkcteb5n |                         |
    | a7lv5j5hm1p1hppprga7 | second-disk  | 21474836480 | ru-central1-a | READY  |                      |                         |
    +----------------------+--------------+-------------+---------------+--------+----------------------+-------------------------+
    
  3. Create a snapshot in the default folder:

    $ yc compute snapshot create \
        --name first-snapshot \
        --description "my first snapshot via CLI" \
        --disk-id fhm4aq4hvq5g3nepvt9b
    

    This command creates a disk snapshot with the name first-snapshot and description my first snapshot via CLI.

    The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.

A snapshot is created asynchronously. The snapshot is created immediately after the create command is run. It gets the CREATING status. From this point on, you can resume writing data to disk, and disk operations will not affect the data in the snapshot.

Once the snapshot has been created, its status changes to READY. From this point on, you can use the snapshot for creating images, filling disks, and so on.