This topic describes how to call the DescribeSnapshots operation by using Alibaba Cloud command-line interface (CLI) to query all snapshots of an ECS instance or a disk.

Background information

You can call the DescribeSnapshots operation to query all snapshots of an ECS instance or a disk. For more information, see DescribeSnapshots.

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.

Example 1: Query the snapshots of an ECS instance

  1. Query the ID of an ECS instance by using Alibaba Cloud CLI. For more information, see Query the details of ECS instances.
  2. Query snapshots of an ECS instance by using its ID.
    In this example, query the manually created snapshots of all types of ECS instance i-bp135vxo2oisz0cx****.
    aliyun ecs DescribeSnapshots --RegionId cn-hangzhou --InstanceId i-bp135vxo2oisz0cx**** --Status all --SnapshotType user --output cols=SnapshotId,SnapshotName,Status rows=Snapshots.Snapshot[]
    Sample response:
    SnapshotId             | SnapshotName   | Status
    ----------             | ------------   | ------
    s-bp15k4ho3tb8phjr**** | namedemo1      | accomplished
    s-bp11y4dhnmouewav**** | namedemo2      | accomplished

Example 2: Query the snapshots of a disk

  1. Call the DescribeDisks operation to query the ID of the disk on which the snapshots you want to query reside.
  2. Query snapshots by disk ID.
    In this example, query the manually created snapshots of all types of disk d-bp1cs71lqlawiyrn****.
    aliyun ecs DescribeSnapshots --RegionId cn-hangzhou --DiskId d-bp1cs71lqlawiyrn**** --Status all --SnapshotType user --output cols=SnapshotId,SnapshotName,Status rows=Snapshots.Snapshot[]
    Sample response:
    SnapshotId             | SnapshotName   | Status
    ----------             | ------------   | ------
    s-bp15k4ho3tb8phjr**** | namedemo1      | accomplished
    s-bp11y4dhnmouewav**** | namedemo2      | accomplished