This topic describes how to call the CreateSnapshot operation by using Alibaba Cloud CLI to create a snapshot for a disk.

Background information

You can call the CreateSnapshot operation to create a snapshot for a disk. We recommend that you read the description of the operation before you call the operation. 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. For more information, see DescribeDisks.
    In this example, the disk name is used to query the ID of the disk.
    aliyun ecs DescribeDisks --RegionId cn-hangzhou --DiskName demoname --output cols=Disks.Disk[].DiskId
    Sample response:
  2. In this example, a snapshot is created and retained for three days for the d-bp14bjlwo3t3owin**** ultra disk.
    aliyun ecs CreateSnapshot --DiskId d-bp14bjlwo3t3owin**** --SnapshotName demo --Description demo --RetentionDays 3


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