你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
使用 Azure 数据保护通过 REST API 备份 Azure PostgreSQL 数据库
本文介绍如何通过 REST API 管理 Azure PostgreSQL 数据库的备份。
有关 Azure PostgreSQL 数据库备份受支持的场景、限制和身份验证机制的信息,请参阅概述文档。
先决条件
配置备份
创建保管库和策略后,需要考虑 3 个关键点来保护 Azure PostgreSQL 数据库。
所涉关键实体
要保护的 PostgreSQL 数据库
提取需要保护的 PostgreSQL 数据库的 Azure 资源管理器 ID (ARM ID)。 它充当数据库的标识符。 我们将使用 PostgreSQL 服务器“testposgresql”下名为“empdb11”的数据库示例,该数据库位于另一订阅下的资源组“ossdemoRG”中 。 下面的示例使用 bash。
"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx/resourcegroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql/databases/empdb11"
Azure Key Vault
Azure 备份服务不存储用于连接到 PostgreSQL 数据库的用户名和密码。 备份管理员而需将密钥播种到密钥保管库中。 然后 Azure 备份服务将访问密钥保管库、读取密钥并访问数据库。 请注意相关密钥的机密标识符。 下面的示例使用 bash。
"https://testkeyvaulteus.vault.azure.net/secrets/ossdbkey"
备份保管库
备份保管库必须连接到 PostgreSQL 服务器,然后通过密钥保管库中的密钥访问数据库。 因此,它需要访问 PostgreSQL 服务器和密钥保管库。 向备份保管库的托管服务标识 (MSI) 授予访问权限。
需要授予在 PostgreSQL 服务器和 Azure Key Vault(其中存储了数据库密钥)上备份保管库 MSI 的权限。 了解详细信息。
准备配置备份的请求
为保管库和 PostgreSQL 数据库设置相关权限并配置保管库和策略后,请准备配置备份的请求。 请查看下面的请求正文,以便为 Azure PostgreSQL 数据库配置备份。 Azure PostgreSQL 数据库的 Azure 资源管理器 ID (ARM ID) 及其详细信息在 datasourceinfo 节提供。 策略信息位于 policyinfo 节中。
{
"backupInstance": {
"dataSourceInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql/databases/empdb11",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "empdb11",
"resourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceLocation": "westUS",
"objectType": "Datasource"
},
"dataSourceSetInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "testpostgresql",
"resourceType": "Microsoft.DBforPostgreSQL/servers",
"resourceLocation": "westUS",
"objectType": "DatasourceSet"
},
"policyInfo": {
"policyId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupPolicies/osspol3",
"policyVersion": ""
},
"objectType": "BackupInstance"
}
}
验证配置备份的请求
若要验证配置备份的请求是否能成功,请使用验证备份 API。 可以参考响应来执行所需的先决条件,然后提交备份请求的配置。
验证备份请求是 POST 操作,并且统一资源标识符 (URI) 包含 {subscriptionId}
、{vaultName}
和 {vaultresourceGroupName}
参数。
POST https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{vaultresourceGroupname}/providers/Microsoft.DataProtection/backupVaults/{backupVaultName}/validateForBackup?api-version=2021-01-01
例如,此 API 转换为:
POST https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/validateForBackup?api-version=2021-01-01
我们之前准备的请求正文将用于提供要保护的 Azure PostgreSQL 数据库的详细信息。
示例请求正文
{
"backupInstance": {
"dataSourceInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql/databases/empdb11",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "empdb11",
"resourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceLocation": "westUS",
"objectType": "Datasource"
},
"dataSourceSetInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "testpostgresql",
"resourceType": "Microsoft.DBforPostgreSQL/servers",
"resourceLocation": "westUS",
"objectType": "DatasourceSet"
},
"policyInfo": {
"policyId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupPolicies/osspol3",
"policyVersion": ""
},
"objectType": "BackupInstance"
}
}
备份请求验证的响应
备份请求验证是一个异步操作。 因此,此操作会创建另一个需要单独跟踪的操作。
它将返回两个响应:创建另一个操作时为 202(已接受),该操作完成时为 200(确定)。
名称 | Type | 说明 |
---|---|---|
202 已接受 | 该操作将异步完成 | |
200 正常 | OperationJobExtendedInfo | 已接受 |
其他状态代码 | CloudError | 描述操作失败原因的错误响应 |
验证备份请求的响应示例
错误响应
如果给定的磁盘已受到保护,则返回响应 HTTP 400(错误请求),并指出给定磁盘受备份保管库的保护以及详细信息。
HTTP/1.1 400 BadRequest
Content-Length: 1012
Content-Type: application/json
Expires: -1
Pragma: no-cache
X-Content-Type-Options: nosniff
x-ms-request-id:
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id: 0c99ff0f-6c26-4ec7-899f-205435e89894
x-ms-routing-request-id: WESTUS:20210830T142949Z:0be72802-02ad-485d-b91f-4aadd92c059c
Cache-Control: no-cache
Date: Mon, 30 Aug 2021 14:29:49 GMT
X-Powered-By: ASP.NET
{
"error": {
"additionalInfo": [
{
"type": "UserFacingError",
"info": {
"message": "Datasource is already protected under the Backup vault /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault.",
"recommendedAction": [
"Delete the backup instance testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149 from the Backup vault /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault to re-protect the datasource in any other vault."
],
"details": null,
"code": "UserErrorDppDatasourceAlreadyProtected",
"target": "",
"innerError": null,
"isRetryable": false,
"isUserError": false,
"properties": {
"ActivityId": "0c99ff0f-6c26-4ec7-899f-205435e89894"
}
}
}
],
"code": "UserErrorDppDatasourceAlreadyProtected",
"message": "Datasource is already protected under the Backup vault /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault.",
"target": null,
"details": null
}
}
跟踪响应
如果数据源未受保护,API 将继续进一步验证并创建跟踪操作。
HTTP/1.1 202 Accepted
Content-Length: 0
Expires: -1
Pragma: no-cache
Retry-After: 10
Azure-AsyncOperation: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==?api-version=2021-01-01
X-Content-Type-Options: nosniff
x-ms-request-id:
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1197
x-ms-correlation-request-id: 3e7cacb3-65cd-4b3c-8145-71fe90d57327
x-ms-routing-request-id: WESTUS:20210707T124850Z:105f2105-6db1-44bf-8a34-45972a8ba861
Cache-Control: no-cache
Date: Wed, 07 Jul 2021 12:48:50 GMT
Location: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationResults/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==?api-version=2021-01-01
X-Powered-By: ASP.NET
使用带有简单 GET 命令的“Azure-AsyncOperation”标头跟踪生成的操作。
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==?api-version=2021-01-01
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==",
"name": "ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==",
"status": "Inprogress",
"startTime": "2021-07-07T12:48:50.3432229Z",
"endTime": "0001-01-01T00:00:00"
}
完成后,它会返回 200(正常),响应正文会列出需要满足的更多要求,例如权限。
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==?api-version=2021-01-01
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==",
"name": "ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==",
"status": "Failed",
"error": {
"additionalInfo": [
{
"type": "UserFacingError",
"info": {
"message": "Appropriate permissions to perform the operation is missing.",
"recommendedAction": [
"Grant appropriate permissions to perform this operation as mentioned at https://aka.ms/UserErrorMissingRequiredPermissions and retry the operation."
],
"code": "UserErrorMissingRequiredPermissions",
"target": "",
"innerError": {
"code": "UserErrorMissingRequiredPermissions",
"additionalInfo": {
"DetailedNonLocalisedMessage": "Validate for Protection failed. Exception Message: The client '00001111-aaaa-2222-bbbb-3333cccc4444' with object id 'aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb' does not have authorization to perform action 'Microsoft.Authorization/roleAssignments/read' over scope '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql/providers/Microsoft.Authorization' or the scope is invalid. If access was recently granted, please refresh your credentials."
}
},
"isRetryable": false,
"isUserError": false,
"properties": {
"ActivityId": "3e7cacb3-65cd-4b3c-8145-71fe90d57327"
}
}
}
],
"code": "UserErrorMissingRequiredPermissions",
"message": "Appropriate permissions to perform the operation is missing."
},
"startTime": "2021-07-07T12:48:50.3432229Z",
"endTime": "2021-07-07T12:49:22Z"
}
如果授予了所有权限,则重新提交验证请求,跟踪生成的操作。 如果满足所有条件,它会将成功响应返回为 200(正常)。
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzlhMjk2YWM2LWRjNDMtNGRjZS1iZTU2LTRkZDNiMDhjZDlkOA==?api-version=2021-01-01
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzlhMjk2YWM2LWRjNDMtNGRjZS1iZTU2LTRkZDNiMDhjZDlkOA==",
"name": "ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzlhMjk2YWM2LWRjNDMtNGRjZS1iZTU2LTRkZDNiMDhjZDlkOA==",
"status": "Succeeded",
"startTime": "2021-07-07T13:03:54.8627251Z",
"endTime": "2021-07-07T13:04:06Z"
}
配置备份请求
验证请求后,可以将相同内容提交到创建备份实例 API。 Azure 备份数据保护服务之一保护备份保管库中的备份实例。 此处的 Azure PostgreSQL 数据库是备份实例。 使用上面验证的请求正文,只需添加一点内容。
针对备份实例使用唯一名称。 因此,建议组合使用资源名称和唯一标识符。 例如,在以下操作中,我们将使用 testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149 并将其标记为备份实例名称。
若要创建或更新备份实例,请使用以下 PUT 操作。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/{BkpvaultName}/backupInstances/{UniqueBackupInstanceName}?api-version=2021-01-01
例如,此 API 转换为:
PUT https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupInstances/testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149?api-version=2021-01-01
创建配置备份的请求
要创建备份实例,下面是请求正文的组成部分:
名称 | Type | 说明 |
---|---|---|
properties | BackupInstance | BackupInstanceResource 属性 |
配置备份请求示例
我们将使用用于验证备份请求的请求正文,并采用唯一名称。
{
"name": "testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149",
"type": "Microsoft.DataProtection/backupvaults/backupInstances",
"properties": {
"dataSourceInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql/databases/empdb11",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "empdb11",
"resourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceLocation": "westUS",
"objectType": "Datasource"
},
"dataSourceSetInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "testpostgresql",
"resourceType": "Microsoft.DBforPostgreSQL/servers",
"resourceLocation": "westUS",
"objectType": "DatasourceSet"
},
"policyInfo": {
"policyId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupPolicies/osspol3",
"policyVersion": ""
}
},
"objectType": "BackupInstance"
}
}
配置备份请求的响应
创建备份实例请求是一个异步操作。 因此,此操作会创建另一个需要单独跟踪的操作。
它返回两个响应:在创建备份实例并配置保护后,返回“201 (已创建)”; 在配置完成后,返回“200 (正常)”。
名称 | Type | 说明 |
---|---|---|
201 已创建 | 备份实例 | 创建备份实例并配置保护 |
200 正常 | 备份实例 | 已配置保护 |
其他状态代码 | CloudError | 描述操作失败原因的错误响应 |
配置备份请求的响应示例
提交 PUT 请求以创建备份实例后,初始响应是带有 Azure-asyncOperation 标头的 201(已创建)。 请注意,请求正文包含所有备份实例属性。
HTTP/1.1 201 Created
Content-Length: 1149
Content-Type: application/json
Expires: -1
Pragma: no-cache
Retry-After: 15
Azure-AsyncOperation: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzI1NWUwNmFlLTI5MjUtNDBkNy1iMjMxLTM0ZWZlMDA3NjdkYQ==?api-version=2021-01-01
X-Content-Type-Options: nosniff
x-ms-request-id:
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-correlation-request-id: 5d9ccf1b-7ac1-456d-8ae3-36c93c0d2427
x-ms-routing-request-id: WESTUS:20210707T170219Z:9e897266-5d86-4d13-b298-6561c60cf043
Cache-Control: no-cache
Date: Wed, 07 Jul 2021 17:02:18 GMT
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
{
"properties": {
"friendlyName": "testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149",
"dataSourceInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql/databases/empdb11",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "empdb11",
"resourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceLocation": "westUS",
"objectType": "Datasource"
},
"dataSourceSetInfo": {
"resourceID": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ossdemoRG/providers/Microsoft.DBforPostgreSQL/servers/testpostgresql",
"resourceUri": "",
"datasourceType": "Microsoft.DBforPostgreSQL/servers/databases",
"resourceName": "testpostgresql",
"resourceType": "Microsoft.DBforPostgreSQL/servers",
"resourceLocation": "westUS",
"objectType": "DatasourceSet"
},
"policyInfo": {
"policyId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupPolicies/osspol3",
"policyVersion": ""
},
"protectionStatus": {
"status": "ProtectionConfigured"
},
"currentProtectionState": "ProtectionConfigured",
"provisioningState": "Succeeded",
"objectType": "BackupInstance"
},
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupInstances/testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149",
"name": "testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149",
"type": "Microsoft.DataProtection/backupVaults/backupInstances"
}
然后通过简单的 GET 命令使用“Azure-AsyncOperation”标头跟踪生成的操作。
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzI1NWUwNmFlLTI5MjUtNDBkNy1iMjMxLTM0ZWZlMDA3NjdkYQ==?api-version=2021-01-01
操作完成后,它将在响应正文中返回 200(正常)和成功消息。
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzI1NWUwNmFlLTI5MjUtNDBkNy1iMjMxLTM0ZWZlMDA3NjdkYQ==",
"name": "ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzI1NWUwNmFlLTI5MjUtNDBkNy1iMjMxLTM0ZWZlMDA3NjdkYQ==",
"status": "Succeeded",
"startTime": "2021-07-07T17:02:19.0611871Z",
"endTime": "2021-07-07T17:02:20Z"
}
停止保护并删除数据
若要删除对 Azure PostgreSQL 数据库的保护并删除备份数据,请执行删除操作。
停止保护和删除数据是一种 DELETE 操作。
DELETE https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}?api-version=2021-01-01
例如,此 API 转换为:
DELETE "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupInstances/testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149?api-version=2021-01-01"
针对删除保护的响应
DELETE 操作是一种异步操作。 因此,此操作会创建另一个需要单独跟踪的操作。
它将返回两个响应:创建另一个操作时为 202(已接受),该操作完成时为 200(确定)。
名称 | Type | 说明 |
---|---|---|
200 OK | 删除请求的状态 | |
202 已接受 | 已接受 |
删除保护的响应示例
提交 DELETE 请求后,初始响应将为带有 Azure-asyncOperation 标头的 202(已接受)。
HTTP/1.1 202 Accepted
Content-Length: 0
Expires: -1
Pragma: no-cache
Retry-After: 30
Azure-AsyncOperation: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzE1ZjM4YjQ5LWZhMGQtNDMxOC1iYjQ5LTExMDJjNjUzNjM5Zg==?api-version=2021-01-01
X-Content-Type-Options: nosniff
x-ms-request-id:
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-deletes: 14999
x-ms-correlation-request-id: fee7a361-b1b3-496d-b398-60fed030d5a7
x-ms-routing-request-id: WESTUS:20210708T071330Z:5c3a9f3e-53aa-4d5d-bf9a-20de5601b090
Cache-Control: no-cache
Date: Thu, 08 Jul 2021 07:13:29 GMT
Location: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationResults/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzE1ZjM4YjQ5LWZhMGQtNDMxOC1iYjQ5LTExMDJjNjUzNjM5Zg==?api-version=2021-01-01
X-Powered-By: ASP.NET
使用简单的 GET 请求来跟踪 Azure-AsyncOperation 标头。 请求成功后,它会返回“200 (正常)”,并返回成功状态响应。
GET "https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzE1ZjM4YjQ5LWZhMGQtNDMxOC1iYjQ5LTExMDJjNjUzNjM5Zg==?api-version=2021-01-01"
{
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzE1ZjM4YjQ5LWZhMGQtNDMxOC1iYjQ5LTExMDJjNjUzNjM5Zg==",
"name": "ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzE1ZjM4YjQ5LWZhMGQtNDMxOC1iYjQ5LTExMDJjNjUzNjM5Zg==",
"status": "Succeeded",
"startTime": "2021-07-08T07:13:30.23815Z",
"endTime": "2021-07-08T07:13:46Z"
}
后续步骤
有关 Azure 备份 REST API 的详细信息,请参阅以下文章: