A snapshot is a backup file of the data on a disk for a specific point in time. A snapshot is used for data backup, data recovery after accidental instance releases, data recovery after network attacks, and to create custom images. You can create snapshots of disks to improve fault tolerance for operations before you roll back a disk, modify key system files, or change the operating system of an instance. This topic describes how to create a snapshot in the ECS console or by calling API operations.

Prerequisites

  • The ECS instance must be in the Running or Stopped state.
  • The disk must be in the In Use or Expired state. If a disk in the Expired state reaches its scheduled release time while a snapshot is being created for the disk, the snapshot in the Creating state will also be released together with the disk.

Background information

The time required to create a snapshot depends on the size of the disk. The first snapshot of a disk is a full snapshot, so creating the first snapshot takes an extended period of time. Creating subsequent snapshots will take less time, but will still depend on the amount of data changed since the last snapshot was taken. The more that has changed, the longer it will take.

Note the following points when creating a snapshot:
  • You must not perform operations that change the state of the ECS instance such as stopping or restarting the instance.
  • Snapshots are billed resources. For more information, see Snapshot billing methods.
  • Do not create snapshots at peak hours because the disk performance and I/O rate may decrease while the snapshots are being created.
  • While snapshots are being created, incremental data generated by operations on disks will not be included in the snapshots.
  • If you create an extended volume from a single multi-partition disk, the snapshot that you created can be used to roll back the disk.
  • When a disk is used to create a dynamic extended volume or RAID array, we recommend that you stop applications from writing data to the dynamic extended volume or RAID array and refresh the cached data to the disk. Stop all I/O operations before you create a snapshot.
  • Created snapshots are permanently stored unless you delete them. We recommend that you delete unnecessary snapshots at regular intervals to prevent extra fees incurred by increasing snapshot storage.

Create a snapshot from the ECS console

The following operations demonstrate how to create a snapshot of an instance from the Instances page in the ECS console:

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select a region.
  4. Find the instance for which you want to create a snapshot and click Manage in the Actions column.
  5. In the left-side navigation pane, click Disks, and then click Create Snapshot in the Actions column corresponding to the disk.
    You can only select one disk at a time. Select All for the Type column corresponding to the disk.
  6. In the Create Snapshot dialog box that appears, enter a snapshot name and click OK.
  7. In the left-side navigation pane, click Instance Snapshots to view your snapshot creation task.

You can also choose Storage & Snapshots > Disks from the left-side navigation pane in the ECS console to create a snapshot for a disk as prompted.

Call API operations to create a snapshot

The following example uses Alibaba Cloud CLI to call the API operation.

  1. Obtain the instance ID.
    • If you have connected to the ECS instance, you can obtain the instance ID from the instance metadata. For more information, see Metadata.
      For example, to query the ID of a Linux instance, run the following command.
      curl http://100.100.100.200/2016-01-01/meta-data/instance-id
    • In your local computer, you can obtain the instance ID by calling DescribeInstances:
      aliyun ecs DescribeInstances --RegionId <TheRegionId> --output cols=InstanceId,InstanceName rows=Instances.Instance[]
  2. Obtain the disk ID by calling DescribeDisks:
    aliyun ecs DescribeDisks --RegionId <TheRegionId> --InstanceId i-bp1afnc98r8k69****** --output cols=DiskId rows=Disks.Disk[]
  3. Call CreateSnapshot to create a snapshot based on a specified disk:
    aliyun ecs CreateSnapshot --DiskId d-bp19pjyf12hebp******
    The snapshot creation task is initiated if the following information is returned:
    {"RequestId":"16B856F6-EFFB-4397-8A8A-CB73FA******","SnapshotId":"s-bp1afnc98r8kjh******"}
  4. Call DescribeSnapshots to query the progress.
    If both "SnapshotId"="s-bp1afnc98r8kjh******" and "Status":"accomplished" are displayed, the snapshot has been created.
    aliyun ecs DescribeSnapshots --RegionId cn-hangzhou --InstanceId i-bp1afnc98r8k69****** --output cols=SnapshotId,Status rows=Snapshots.Snapshot[]

What to do next