You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/backup/backup-azure-data-protection-use-rest-api-backup-postgresql.md
+51-61Lines changed: 51 additions & 61 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ After you create the vault and policy, you need to consider three critical point
28
28
29
29
#### PostgreSQL database to be backed up
30
30
31
-
Fetch the Resource Manager ID of the PostgreSQL database to be backed up. This ID serves as the identifier of the database. The following example uses a database named `empdb11` under the PostgreSQL server `testposgresql`, which is present in the resource group `ossrg` under a different subscription. The example uses Bash.
31
+
Fetch the Azure Resource Manager ID of the PostgreSQL database to be backed up. This ID serves as the identifier of the database. The following example uses a database named `empdb11` under the PostgreSQL server `testposgresql`, which is present in the resource group `ossrg` under a different subscription. The example uses Bash.
@@ -46,13 +46,13 @@ The following example uses Bash. Note the secret identifier of the relevant key.
46
46
47
47
#### Backup vault
48
48
49
-
A backup vault has to connect to the PostgreSQL server, and then access the database via the keys present in the key vault. So, it requires access to PostgreSQL server and the key vault. Access is granted to the backup vault's managed identity.
49
+
A backup vault has to connect to the PostgreSQL server and then access the database via the keys present in the key vault. So, it requires access to the PostgreSQL server and the key vault. Access is granted to the backup vault's managed identity.
50
50
51
-
You need to grant permissions to the backup vault's managed identity on the PostgreSQL server and the key vault, where the keys to the database are stored. [Learn more](./backup-azure-database-postgresql-overview.md#set-of-permissions-needed-for-azure-postgresql-database-backup).
51
+
You need to grant permissions to the backup vault's managed identity on the PostgreSQL server and the key vault that stores the keys to the database. [Learn more](./backup-azure-database-postgresql-overview.md#set-of-permissions-needed-for-azure-postgresql-database-backup).
52
52
53
53
### Prepare the request
54
54
55
-
After you set the relevant permissions to the vault and PostgreSQL database, and configure the vault and policy, prepare the request to configure backup. See the following request body to configure backup for a PostgreSQL database. The Azure Resource Manager ID (ARM ID) of the PostgreSQL database and its details are present in the _datasourceinfo_ section. The policy information is present in the _policyinfo_ section.
55
+
After you set the relevant permissions to the vault and the PostgreSQL database, and you configure the vault and the policy, prepare the request to configure backup. Use the following request body to configure backup for a PostgreSQL database. The Resource Manager ID of the PostgreSQL database and its details are in the `dataSourceInfo` section. The policy information is in the `policyInfo` section.
56
56
57
57
```json
58
58
{
@@ -86,21 +86,21 @@ After you set the relevant permissions to the vault and PostgreSQL database, and
86
86
87
87
### Validate the request to configure backup
88
88
89
-
To validate if the request to configure backup will be successful, use the [validate for backup API](/rest/api/dataprotection/backup-instances/validate-for-backup). You can use the response to perform the required prerequisites, and then submit the configuration for the backup request.
89
+
To validate if the request to configure backup will be successful, use the [Validate For Backup API](/rest/api/dataprotection/backup-instances/validate-for-backup). You can use the response to perform the required prerequisites, and then submit the configuration for the backup request.
90
90
91
-
Validate for backup request is a _POST_ operation and the Uniform Resource Identifier (URI) contains `{subscriptionId}`, `{vaultName}`, `{vaultresourceGroupName}` parameters.
91
+
Validation of a backup request is a `POST` operation. The URI contains `{subscriptionId}`, `{vaultName}`, and `{vaultresourceGroupName}` parameters:
92
92
93
93
```http
94
94
POST https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{vaultresourceGroupname}/providers/Microsoft.DataProtection/backupVaults/{backupVaultName}/validateForBackup?api-version=2021-01-01
95
95
```
96
96
97
-
For example, this API translates to:
97
+
For example, the preceding API translates to:
98
98
99
99
```http
100
100
POST https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/validateForBackup?api-version=2021-01-01
101
101
```
102
102
103
-
The [request body](#prepare-the-request-to-configure-backup) that we prepared earlier will be used to provide details of the PostgreSQL database to be protected.
103
+
The [request body](#prepare-the-request) that you prepared earlier provides details about the PostgreSQL database to be backed up.
104
104
105
105
#### Example request body
106
106
@@ -138,19 +138,17 @@ The [request body](#prepare-the-request-to-configure-backup) that we prepared ea
138
138
139
139
Backup request validation is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that needs to be tracked separately.
140
140
141
-
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
141
+
The operation returns these responses:
142
142
143
143
|Name |Type |Description |
144
144
|---------|---------|---------|
145
-
|202 Accepted || The operation will be completed asynchronously |
146
-
|200 OK |[OperationJobExtendedInfo](/rest/api/dataprotection/backup-instances/validate-for-backup#operationjobextendedinfo)|Accepted|
147
-
| Other Status codes |[CloudError](/rest/api/dataprotection/backup-instances/validate-for-backup#clouderror)|Error response describing why the operation failed |
145
+
|`202 Accepted`||Another operation is created. The operation will be completed asynchronously.|
146
+
|`200 OK`|[`OperationJobExtendedInfo`](/rest/api/dataprotection/backup-instances/validate-for-backup#operationjobextendedinfo)|The operation is completed.|
147
+
| Other status codes |[`CloudError`](/rest/api/dataprotection/backup-instances/validate-for-backup#clouderror)|The error response describes why the operation failed.|
148
148
149
-
##### Example responses for validate backup request
149
+
##### Example error response
150
150
151
-
###### Error response
152
-
153
-
If the given disk is already protected, it returns the response as HTTP 400 (Bad request) and states that the given disk is protected to a backup vault along with details.
151
+
If the disk is already configured for backup, it returns the response as HTTP `400 Bad request`. The response states that the disk is backed up to a vault, along with details:
154
152
155
153
```http
156
154
HTTP/1.1 400 BadRequest
@@ -198,9 +196,9 @@ X-Powered-By: ASP.NET
198
196
}
199
197
```
200
198
201
-
###### Track response
199
+
#####Example tracking response
202
200
203
-
If the datasource is unprotected, then the API proceeds for further validations and creates a tracking operation.
201
+
If the data source is unprotected, the API proceeds for further validations and creates a tracking operation:
Track the resulting operation using the _Azure-AsyncOperation_ header with a simple *GET* command.
222
+
Track the resulting operation by using the `Azure-AsyncOperation` header with a simple `GET` command:
225
223
226
224
```http
227
225
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==?api-version=2021-01-01
@@ -235,7 +233,7 @@ GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
235
233
}
236
234
```
237
235
238
-
It returns 200 (OK) once it completes and the response body lists further requirements to be fulfilled, such as permissions.
236
+
The operation returns `200 OK` when it finishes. The response body then lists further requirements to be fulfilled, such as permissions:
239
237
240
238
```http
241
239
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzM2NDdhZDNjLTFiNGEtNDU4YS05MGJkLTQ4NThiYjRhMWFkYg==?api-version=2021-01-01
@@ -277,7 +275,7 @@ GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
277
275
}
278
276
```
279
277
280
-
If you grant all permissions, then resubmit the validate request, track the resulting operation. It'll return the success response as 200 (OK) if all the conditions are met.
278
+
If you grant all permissions, then resubmit the validation request and track the resulting operation. It returns the success response `200 OK` if all the conditions are met.
281
279
282
280
```http
283
281
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzlhMjk2YWM2LWRjNDMtNGRjZS1iZTU2LTRkZDNiMDhjZDlkOA==?api-version=2021-01-01
@@ -291,35 +289,33 @@ GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
291
289
}
292
290
```
293
291
294
-
### Configure backup request
292
+
### Configure a backup request
295
293
296
-
Once the request is validated, you can submit the same to the [create backup instance API](/rest/api/dataprotection/backup-instances/create-or-update). One of the Azure Backup data protection services protects the Backup instance within the backup vault. Here, the PostgreSQL database is the backup instance. Use the above-validated request body with minor additions.
294
+
After the request is validated, you can submit the request to the [Create Backup Instance API](/rest/api/dataprotection/backup-instances/create-or-update). One of the Azure Backup data protection services helps protect the backup instance within the backup vault. Here, the PostgreSQL database is the backup instance. Use the previously validated request body with minor additions.
297
295
298
-
Use a unique name for the backup instance. So, we recommend you use a combination of the resource name and a unique identifier. For example, in the following operation, we'll use _testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149_ and mark it as the backup instance name.
296
+
Use a unique name for the backup instance. We recommend that you use a combination of the resource name and a unique identifier. For example, the following operation uses `testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149` and marks it as the name of the backup instance.
299
297
300
-
To create or update the backup instance, use the following ***PUT*** operation.
298
+
To create or update the backup instance, use the following `PUT` operation:
301
299
302
300
```http
303
301
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/{BkpvaultName}/backupInstances/{UniqueBackupInstanceName}?api-version=2021-01-01
304
302
```
305
303
306
-
For example, this API translates to:
304
+
For example, the preceding API translates to:
307
305
308
306
```http
309
-
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
307
+
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
310
308
```
311
309
312
-
#### Create the request for configure backup
310
+
#### Request for configuring a backup
313
311
314
-
To create a backup instance, following are the components of the request body:
312
+
To create a backup instance, use the following components in the request body:
We'll use the [same request body that we used to validate the backup request](#configure-backup) with a unique name.
318
+
The following example request uses the [same request body that you used to validate the backup request](#configure-backup), with a unique name:
323
319
324
320
```json
325
321
{
@@ -354,21 +350,19 @@ We'll use the [same request body that we used to validate the backup request](#c
354
350
}
355
351
```
356
352
357
-
#### Responses to configure backup request
353
+
#### Responses to configuring a backup request
358
354
359
-
_Create backup instance request_ is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that needs to be tracked separately.
355
+
Creating a backup instance request is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that needs to be tracked separately.
360
356
361
-
It returns two responses: 201 (Created) when backup instance is created and the protection is configured. 200 (OK) when that configuration completes.
357
+
The operation returns these responses:
362
358
363
359
|Name |Type |Description |
364
360
|---------|---------|---------|
365
-
|201 Created |[Backup instance](/rest/api/dataprotection/backup-instances/create-or-update#backupinstanceresource)| Backup instance is created and protection is being configured |
366
-
|200 OK |[Backup instance](/rest/api/dataprotection/backup-instances/create-or-update#backupinstanceresource)| Protection is configured |
367
-
| Other Status codes |[CloudError](/rest/api/dataprotection/backup-instances/validate-for-backup#clouderror)| Error response describing why the operation failed |
368
-
369
-
##### Example responses to configure backup request
361
+
|`201 Created`|[Backup instance](/rest/api/dataprotection/backup-instances/create-or-update#backupinstanceresource)| The backup instance is created, and protection is configured. |
362
+
|`200 OK`|[Backup instance](/rest/api/dataprotection/backup-instances/create-or-update#backupinstanceresource)| Protection is configured. |
363
+
| Other status codes |[CloudError](/rest/api/dataprotection/backup-instances/validate-for-backup#clouderror)| The error responses describe why the operation failed. |
370
364
371
-
Once you submit the *PUT* request to create a backup instance, the initial response is 201 (Created) with an _Azure-asyncOperation_ header. Note that the request body contains all the backup instance properties.
365
+
After you submit the `PUT` request to create a backup instance, the initial response is `201 Created` with an `Azure-asyncOperation` header. In the following example, note that the request body contains all the backup instance properties:
372
366
373
367
```http
374
368
HTTP/1.1 201 Created
@@ -427,13 +421,13 @@ X-Powered-By: ASP.NET
427
421
}
428
422
```
429
423
430
-
Then track the resulting operation using the _Azure-AsyncOperation_ header with a simple *GET* command.
424
+
Track the resulting operation by using the `Azure-AsyncOperation` header with a simple `GET` command:
431
425
432
426
```http
433
427
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzI1NWUwNmFlLTI5MjUtNDBkNy1iMjMxLTM0ZWZlMDA3NjdkYQ==?api-version=2021-01-01
434
428
```
435
429
436
-
Once the operation completes, it returns 200 (OK) with the success message in the response body.
430
+
When the operation finishes, it returns `200 OK` with the `Succeeded` message in the response body:
437
431
438
432
```json
439
433
{
@@ -447,34 +441,30 @@ Once the operation completes, it returns 200 (OK) with the success message in th
447
441
448
442
### Stop protection and delete data
449
443
450
-
To remove the protection on a PostgreSQL database and delete the backup data as well, perform a [delete operation](/rest/api/dataprotection/backup-instances/delete).
451
-
452
-
Stopping protection and deleting data is a *DELETE* operation.
444
+
To remove the protection on a PostgreSQL database and delete the backup data, perform a [DELETE operation](/rest/api/dataprotection/backup-instances/delete):
#### Responses for stopping protection and deleting data
465
457
466
-
*DELETE* protection is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that needs to be tracked separately.
458
+
`DELETE` is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that needs to be tracked separately.
467
459
468
-
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
460
+
The operation returns these responses:
469
461
470
462
|Name |Type |Description |
471
463
|---------|---------|---------|
472
-
|200 OK || Status of delete request |
473
-
|202 Accepted || Accepted |
474
-
475
-
##### Example responses for delete protection
464
+
|`200 OK`|| The operation finished. |
465
+
|`202 Accepted`|| The operation is accepted. Another operation is created. |
476
466
477
-
Once you submit the *DELETE* request, the initial response will be 202 (Accepted) with an _Azure-asyncOperation_ header.
467
+
After you submit the `DELETE` request, the initial response is `202 Accepted` with an `Azure-asyncOperation` header, as shown in this example response:
Track the _Azure-AsyncOperation_ header with a simple *GET* request. When the request is successful, it returns 200 (OK) with a success status response.
488
+
Track the `Azure-AsyncOperation` header with a simple `GET` request. When the request is successful, it returns a `200 OK` status response.
499
489
500
490
```http
501
491
GET "https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzE1ZjM4YjQ5LWZhMGQtNDMxOC1iYjQ5LTExMDJjNjUzNjM5Zg==?api-version=2021-01-01"
@@ -511,7 +501,7 @@ GET "https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
511
501
512
502
## Related content
513
503
514
-
-[Restore data from a PostGreSQL database backup](restore-postgresql-database-use-rest-api.md)
515
-
-[Get started with Azure Data Protection Provider REST API](/rest/api/dataprotection/)
516
-
-[Get started with Azure REST API](/rest/api/azure/)
517
-
-[Manage backup jobs using REST API](backup-azure-arm-userestapi-managejobs.md).
504
+
-[Restore PostgreSQL databases by using the Azure Data Protection REST API](restore-postgresql-database-use-rest-api.md)
505
+
-[Azure Backup Data Protection REST API](/rest/api/dataprotection/)
506
+
-[Azure REST API reference](/rest/api/azure/)
507
+
-[Track backup and restore jobs by using the REST API in Azure Backup](backup-azure-arm-userestapi-managejobs.md)
0 commit comments