This topic describes how to call the CreateSnapshot operation by using Alibaba Cloud command-line interface (CLI) to create a snapshot for a disk.

Background information

You can call the CreateSnapshot operation to create a snapshot for a disk. For more information, see CreateSnapshot.

When you call an API operation through Alibaba Cloud CLI, make sure that request parameter values of different data types are in required formats. For more information, see Parameter format overview.

Request examples

  1. Call the DescribeDisks operation to query the ID of the disk for which you want to create a snapshot.
    In this example, query the ID of the disk by using its name.
    aliyun ecs DescribeDisks --RegionId cn-hangzhou --DiskName demoname --output cols=Disks.Disk[].DiskId
    Sample response:
    Disks.Disk[].DiskId
    -------------------
    [d-bp14bjlwo3t3owin****]
  2. In this example, create a snapshot that is retained for three days for ultra disk d-bp14bjlwo3t3owin****.
    aliyun ecs CreateSnapshot --DiskId d-bp14bjlwo3t3owin**** --SnapshotName demo --Description demo --RetentionDays 3

Result

{
        "RequestId": "DFB0B01F-420D-4932-911E-7328920C2012",
        "SnapshotId": "s-bp1eyr9nxxoo9icj****"
}