This topic describes how to use Data Disaster Recovery SDK for Python to call the DescribeBackupPlanList operation to query the details of a backup schedule.
View API documentation
Before you call the DescribeBackupPlanList operation, we recommend that you read the documentation about the API operation to learn about the parameters and permissions that are required to call the API operation. For more information, see List of operations by function or List of operations by function.
Create a RAM user and grant permissions to the RAM user
If you have created a Resource Access Management (RAM) user and granted permissions to the RAM user, skip this step.
Create a RAM user.
Go to the Users page in the RAM console and click Create User.
Set Logon Name to dbs-openapi-operator and Access Mode to Using permanent AccessKey to access.
Click OK. On the page that appears, save the AccessKey ID and AccessKey secret of the RAM user that you created.
Grant permissions to the RAM user.
On the Users page, find the RAM user and click Add Permissions in the Actions column.
Enter
AliyunDBS
in the search box and select the AliyunDBSFullAccess policy.The AliyunDBSFullAccess policy contains the read and write permissions on Data Disaster Recovery. The RAM user to whom the policy is attached can perform multiple operations on Data Disaster Recovery. For example, the RAM user can purchase, configure, and manage Data Disaster Recovery backup schedules. The AliyunDBSReadOnlyAccess policy contains the read permissions on Data Disaster Recovery. The RAM user to whom the policy is attached can view the information about all Data Disaster Recovery tasks within the Alibaba Cloud account, including task details and configurations. However, the RAM user cannot perform changes on the tasks.
You can also create custom policies based on your business requirements. For more information, see Custom policies for Data Disaster Recovery.
Click Grant permissions to complete the authorization.
Call the API operations
This section describes how to use Data Disaster Recovery SDK for Python to call API operations. You can use SDKs for other programming languages in a similar way. For more information, see Data Disaster Recovery.
Install Python
Download and install Python 3. If you have installed Python, you can view the Python version by running the following command: python --version
.
Configure environment variables
This section describes how to configure the ALIBABA_CLOUD_ACCESS_KEY_ID
and ALIBABA_CLOUD_ACCESS_KEY_SECRET
environment variables.
If you use a Linux or macOS operating system, replace
<ACCESS_KEY_ID>
and<ACCESS_KEY_SECRET>
in the following commands with your AccessKey ID and AccessKey secret. Then, run the commands in sequence on your device.export ALIBABA_CLOUD_ACCESS_KEY_ID=<ACCESS_KEY_ID> export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET>
If you use a Windows operating system, create a file to add the
ALIBABA_CLOUD_ACCESS_KEY_ID
andALIBABA_CLOUD_ACCESS_KEY_SECRET
environment variables and specify your AccessKey ID and AccessKey secret by using the environment variables. Then, restart the Windows operating system.
Install dependencies
Run the following commands on your terminal device to install dependencies:
pip install alibabacloud_dbs20190306
Download the sample code
Go to the debugging page of the DescribeBackupPlanList operation in OpenAPI Explorer.
On the Parameters tab on the left side, configure the request parameters. In this example, the Region parameter is set to cn-hangzhou.
On the SDK Sample Code tab on the right side, select Python and then click Download Project to download the sample code package.
Decompress the package on your device and go to the alibabacloud_sample directory.
Run the sample code
Run the following command:
python sample.py
Sample response:
{
"headers": {
"date": "Mon, 17 Jun 2024 07:22:04 GMT",
"content-type": "application/json;charset=utf-8",
"content-length": "1064",
"connection": "keep-alive",
"keep-alive": "timeout=25",
"vary": "Accept-Encoding",
"access-control-allow-origin": "*",
"access-control-expose-headers": "*",
"x-acs-request-id": "4C4073F2-35A9-5819-88F1-C018A871****",
"x-acs-trace-id": "3c79c1be14f6f17be6aaa9af0f02****",
"etag": "1Jukbw3tBgZiZxgb8TVR****"
},
"statusCode": 200,
"body": {
"HttpStatusCode": 200,
"Items": {
"BackupPlanDetail": [
{
"BackupGatewayId": 16****,
"BackupMethod": "physical",
"BackupObjects": "[]",
"BackupPeriod": "SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY",
"BackupPlanCreateTime": 1718606018000,
"BackupPlanId": "dbsqe3w3vxq****",
"BackupPlanName": "DBS-csyl-L-3",
"BackupPlanStatus": "init",
"BackupRetentionPeriod": 730,
"BackupStartTime": "12:00",
"BackupStorageType": "system",
"DuplicationArchivePeriod": 0,
"DuplicationInfrequentAccessPeriod": 0,
"EnableBackupLog": true,
"InstanceClass": "medium",
"OSSBucketName": "dbs-backup-137383785969****-cn-hangzhou-qxl0qf4g****",
"OSSBucketRegion": "cn-hangzhou",
"OpenBackupSetAutoDownload": false,
"ResourceGroupId": "rg-acfmz7u4zzr****",
"SourceEndpointDatabaseName": "",
"SourceEndpointInstanceID": "",
"SourceEndpointInstanceType": "agent",
"SourceEndpointIpPort": "121.XX.XXX.171:3306",
"SourceEndpointRegion": "cn-hangzhou",
"SourceEndpointUserName": "root"
}
]
},
"PageNum": 0,
"PageSize": 30,
"RequestId": "4C4073F2-35A9-5819-88F1-C018A871****",
"Success": true,
"TotalElements": 1,
"TotalPages": 1
}
}