This topic describes how to use Alibaba Cloud CLI to call the API operations of Data Disaster Recovery. For example, call the DescribeBackupPlanBilling operation to query the billing information of a backup schedule.
Before you begin
Alibaba Cloud CLI is a general-purpose command-line tool that is developed based on APIs. You can use Alibaba Cloud CLI to automate management and maintenance of Data Disaster Recovery. For more information, see What is Alibaba Cloud CLI?
If you want to use Alibaba Cloud CLI to call API operations for a complex task, we recommend that you compile the commands into a shell script and then run the shell script to improve efficiency.
Step 1: Install Alibaba Cloud CLI
You must install Alibaba Cloud CLI before you can use it. Alibaba Cloud CLI supports Windows, Linux, and macOS. When you install Alibaba Cloud CLI, select the installation package based on the operating system of your device. For more information, see the following topics:
Windows: Install Alibaba Cloud CLI on Windows
Alibaba Cloud CLI is pre-installed in Cloud Shell. Cloud Shell automatically configures an identity credential for you. You can use Cloud Shell to debug the commands that you want to run in Alibaba Cloud CLI. For more information, see What is Cloud Shell?
Step 2: Configure Alibaba Cloud CLI
An Alibaba Cloud account has permissions to manage and access the API operations of all Alibaba Cloud services. If you use an Alibaba Cloud account to call API operations, security risks may arise. We recommend that you create a Resource Access Management (RAM) user, grant the required permissions to the RAM user based on the principle of least privilege, and then use the RAM user to call API operations. For more information about the permission policies that are supported by Data Disaster Recovery, see Predefined system policies supported by Data Disaster Recovery and Custom policies for Data Disaster Recovery.
Before you use Alibaba Cloud CLI, you must specify information, such as identity credentials and a region ID, in Alibaba Cloud CLI. Alibaba Cloud CLI supports various types of identity credentials. For more information, see the "Credential types" section of the Configure credentials topic. Alibaba Cloud CLI allows you to use the AccessKey pair of a RAM user to configure identity credentials. If you want to use the AccessKey pair of a RAM user, perform the following steps:
Create a RAM user and create an AccessKey pair for the RAM user to configure identity credentials. For more information, see Create a RAM user and the "Create an AccessKey pair for a RAM user" section of the Create an AccessKey pair topic.
Grant the required permissions to the RAM user. In this example, the
AliyunDMSFullAccesspolicy is attached to the RAM user. The policy grants the permissions to manage Data Disaster Recovery. For more information, see Grant permissions to a RAM user.Obtain the ID of the region that you want to use to configure identity credentials. Alibaba Cloud CLI uses the region ID that you specify to initiate API operations. For more information about the regions supported by Data Disaster Recovery, see Endpoints.
NoteWhen you use Alibaba Cloud CLI, you can use the
--regionoption to run a command in a specific region. If you use the option, Alibaba Cloud CLI ignores the region information in the default credential configurations and environment variable settings. For more information, see Command line options for API calls.Use the AccessKey pair of the RAM user to configure AccessKey credentials in the configuration file named
AkProfile. For more information, see the "Configuration examples" section of the Configure credentials topic.
Step 3: Generate a CLI command
In OpenAPI Explorer, call the DescribeLiveUserDomains operation.

On the Parameters tab, configure the request parameters. Then, click the CLI Example tab to view the generated sample CLI command.
Copy the CLI command or debug the CLI command in Cloud Shell.
Click the
icon to run the command in Cloud Shell. You can quickly debug the command in the Cloud Shell window. Click the
icon to copy the sample command to the clipboard. Then, paste the sample command into your on-premises shell to run the sample command.
NoteWhen you paste the CLI command into your on-premises shell for debugging, take note of the parameter formats. For more information about the parameter formats of Alibaba Cloud CLI, see Parameter formats.
By default, OpenAPI Explorer adds the
--regionoption to the generated CLI command. When you copy the command to your local shell, Alibaba Cloud CLI ignores the region information in the default identity credential configurations and environment variable settings, and preferentially uses the specified region to run the command. You can delete or retain this option based on your business requirements.
Step 4: Call the API operations of Data Disaster Recovery
Alibaba Cloud CLI integrates the Data Disaster Recovery API operations of version
2019-03-06. If you want to use other versions of the API operations, use the--forceand--versionoptions to initiate a forced call. For more information, see Forcibly call an API operation.When a CLI command is generated in OpenAPI Explorer for the Data Disaster Recovery API operations of version
2021-01-01, the--forceand--versionoptions are automatically appended to the CLI command. You do not need to manually perform this operation.For more information, see List of operations by function and List of operations by function.
Example 1: Query the API operations
The following code provides an example on how to use the --help option to query the Data Disaster Recovery API operations of version 2019-03-06 that can be called in Alibaba Cloud CLI.
Run the following command:
aliyun dbs --helpView the command output.

Example 2: Query the billing information of a backup schedule
The following example shows how to use Alibaba Cloud CLI to call the DescribeBackupPlanBilling operation of Data Disaster Recovery to query the billing information of a backup schedule. For more information, see DescribeBackupPlanBilling.
Run the following command:
aliyun dbs DescribeBackupPlanBilling --BackupPlanId 'dbstooi01ex****' --ShowStorageType trueView the command output.
{ "HttpStatusCode": 200, "RequestId": "DD7BC7F5-4E3A-5DF3-BFF9-831503C4D9E3", "Success": true, "Item": { "BuyCreateTimestamp": 1658372830000, "FullStorageSize": 151, "BuyExpiredTimestamp": 1661097600000, "BuySpec": "micro", "QuotaEndTimestamp": 1659283200000, "IsExpired": true, "QuotaStartTimestamp": 1656604800000, "TotalFreeBytes": 858993459200, "PaiedBytes": 0, "UsedFullBytes": 0, "IsFreeBytesUnlimited": true, "ContStorageSize": 10437039, "BuyChargeType": "PREPAY", "UsedIncrementBytes": 9406734 } }NoteIf an error message is returned after you call an API operation of Data Disaster Recovery, check whether the request parameters and the values of the request parameters are valid based on the error code.
You can also perform self-service diagnostics based on the returned request ID or SDK error information on the OpenAPI Troubleshoot page.