Skip to content

Commit d35631d

Browse files
author
AbhishekMallick-MS
committed
added restore article
1 parent 67e7abf commit d35631d

File tree

2 files changed

+326
-5
lines changed

2 files changed

+326
-5
lines changed
Lines changed: 325 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Restore Azure Database for PostgreSQL - Flexible servers using in Azure Backup
3-
description: Learn how to restore Azure Database for PostgreSQL - Flexible servers using .
3+
description: Learn how to restore Azure Database for PostgreSQL - Flexible servers using REST API.
44
ms.topic: conceptual
55
ms.date: 04/30/2024
66
ms.assetid: 759ee63f-148b-464c-bfc4-c9e640b7da6b
@@ -10,9 +10,330 @@ ms.author: v-abhmallick
1010

1111
# Restore Azure Database for PostgreSQL - Flexible servers using REST API (preview)
1212

13-
This article describes how to manage backups for Azure PostgreSQL flexible servers via REST API.
14-
15-
For information on the Azure PostgreSQL - Flexible servers backup supported scenarios, limitations, and authentication mechanisms, see the overview document.
13+
This article describes how to restore an Azure PostgreSQL flexible server backed-up by Azure Backup.
1614

1715
## Prerequisites
16+
17+
Before you restore:
18+
19+
- [Create a Backup vault](backup-azure-dataprotection-use-rest-api-create-update-backup-vault.md).
20+
- [Create a PostgreSQL flexible server backup policy](backup-azure-database-postgresql-flex-use-rest-api-create-update-policy.md).
21+
- [Configure a PostgreSQL flexible server backup](backup-azure-database-postgresql-flex-use-rest-api.md).
22+
23+
Let's use an existing Backup vault `TestBkpVault`, under the resource group `testBkpVaultRG` in the examples.
24+
25+
## Restore a backed-up PostgreSQL database
26+
27+
### Set up permissions
28+
29+
Backup vault uses Managed Identity to access other Azure resources. To restore from backup, Backup vault’s managed identity requires a set of permissions on the target to be restored to.
30+
To restore the recovery point as files to a storage account, Backup vault's system assigned managed identity needs access on the target storage account as [mentioned here](restore-azure-database-postgresql.md#restore-permissions-on-the-target-storage-account).
31+
32+
### Fetch the relevant recovery point
33+
34+
To list all the available recovery points for a backup instance, use the [list recovery points API](/rest/api/dataprotection/recovery-points/list).
35+
36+
```HTTP
37+
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints?api-version=2021-07-01
38+
```
39+
40+
For example, this API translates to:
41+
42+
```HTTP
43+
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupInstances/pgflextestserver-857d23b1-c679-4c94-ade6-c4d34635e149/recoveryPoints?api-version=2021-07-01
44+
```
45+
46+
**Responses for list of recovery points**:
47+
48+
Once you submit the *GET* request, it returns response as *200* (OK), and the list of all discrete recovery points with all the relevant details.
49+
50+
| Name | Type | Description |
51+
| --- | --- | --- |
52+
| **200 OK** | [AzureBackupRecoveryPointResourceList](/rest/api/dataprotection/recovery-points/list#azurebackuprecoverypointresourcelist) | OK |
53+
| **Other status codes** | [CloudError](/rest/api/dataprotection/recovery-points/list#clouderror) | Error response describes the reason for the operation failure. |
54+
55+
Example response for list of recovery points:
56+
57+
```HTTP
58+
HTTP/1.1 200 OK
59+
Content-Length: 53396
60+
Content-Type: application/json
61+
Expires: -1
62+
Pragma: no-cache
63+
X-Content-Type-Options: nosniff
64+
x-ms-request-id:
65+
Strict-Transport-Security: max-age=31536000; includeSubDomains
66+
x-ms-ratelimit-remaining-subscription-reads: 11999
67+
x-ms-correlation-request-id: 41f7ef85-f31e-4db7-87ef-115e3ca65b93
68+
x-ms-routing-request-id: SOUTHINDIA:20211022T200018Z:ba3bc1ce-c081-4895-a292-beeeb6eb22cc
69+
Cache-Control: no-cache
70+
Date: Fri, 22 Oct 2021 20:00:18 GMT
71+
Server: Microsoft-IIS/10.0
72+
X-Powered-By: ASP.NET
73+
74+
{
75+
"value": [
76+
{
77+
"properties": {
78+
"objectType": "AzureBackupDiscreteRecoveryPoint",
79+
"recoveryPointId": "eb006fde78cb47198be5a320fbe45e9b",
80+
"recoveryPointTime": "2021-10-21T16:31:16.8316716Z",
81+
"recoveryPointType": "Full",
82+
"friendlyName": "794ead7c7661410da03997d210d469e7",
83+
"recoveryPointDataStoresDetails": [
84+
{
85+
"id": "9ea7eaf4-eeb8-4c8f-90a7-7f04b60bf075",
86+
"type": "VaultStore",
87+
"creationTime": "2021-10-21T16:31:16.8316716Z",
88+
"expiryTime": "2022-10-21T16:31:16.8316716Z",
89+
"metaData": null,
90+
"visible": true,
91+
"state": "COMMITTED",
92+
"rehydrationExpiryTime": null,
93+
"rehydrationStatus": null
94+
}
95+
],
96+
"retentionTagName": "Default",
97+
"retentionTagVersion": "637212748405148394",
98+
"policyName": "osspol3",
99+
"policyVersion": null
100+
},
101+
```
102+
103+
Select the relevant recovery points from the above list and proceed to prepare the restore request. We'll choose a recovery point named *794ead7c7661410da03997d210d469e7* from the above list to restore.
104+
105+
## Prepare the restore request
106+
107+
### Restore as files
108+
109+
Fetch the URI of the container, within the storage account to which permissions were assigned as [detailed above](#set-up-permissions). For example, a container named `testcontainerrestore` under a storage account `testossstorageaccount` with a different subscription.
110+
111+
```HTTP
112+
"https://testossstorageaccount.blob.core.windows.net/testcontainerrestore"
113+
{
114+
"objectType": "ValidateRestoreRequestObject",
115+
"restoreRequestObject": {
116+
"objectType": "AzureBackupRecoveryPointBasedRestoreRequest",
117+
"sourceDataStoreType": "VaultStore",
118+
"restoreTargetInfo": {
119+
"targetDetails": {
120+
"url": "https://testossstorageaccount.blob.core.windows.net/testcontainerrestore",
121+
"filePrefix": "testprefix",
122+
"restoreTargetLocationType": "AzureBlobs"
123+
},
124+
"restoreLocation": "westus",
125+
"recoveryOption": "FailIfExists",
126+
"objectType": "RestoreFilesTargetInfo"
127+
},
128+
"recoveryPointId": "eb006fde78cb47198be5a320fbe45e9b"
129+
}
130+
}
131+
132+
```
133+
134+
### Validate restore requests
135+
136+
Once the request body is prepared, validate it using the [validate for restore API](/rest/api/dataprotection/backup-instances/validate-for-restore). Like validate for backup API, this is a *POST* operation.
137+
138+
```HTTP
139+
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore?api-version=2021-07-01
140+
```
141+
142+
For example, this API translates to:
143+
144+
```HTTP
145+
POST "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupInstances/pgflextestserver-857d23b1-c679-4c94-ade6-c4d34635e149/ValidateRestore?api-version=2021-07-01"
146+
```
147+
148+
[Learn more](/rest/api/dataprotection/backup-instances/validate-for-restore#request-body) about the request body for this POST API.
149+
150+
**Response to validate restore requests**:
151+
152+
The validate restore request is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that you need to track separately.
153+
It returns two responses: 202 (Accepted) when another operation is created. Then 200 (OK) when that operation completes.
154+
| Name | Type | Description |
155+
| --- | --- | --- |
156+
| **200 OK** | | Status of validate request |
157+
| **202 Accepted** | | Accepted |
158+
159+
**Example response to restore validate request**:
160+
161+
Once the *POST* operation is submitted, it returns the initial response as *202* (Accepted) with an `Azure-asyncOperation` header.
162+
163+
```HTTP
164+
HTTP/1.1 202 Accepted
165+
Content-Length: 0
166+
Expires: -1
167+
Pragma: no-cache
168+
Retry-After: 10
169+
Azure-AsyncOperation: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzVlNzMxZDBiLTQ3MDQtNDkzNS1hYmNjLWY4YWEzY2UzNTk1ZQ==?api-version=2021-07-01
170+
X-Content-Type-Options: nosniff
171+
x-ms-request-id:
172+
Strict-Transport-Security: max-age=31536000; includeSubDomains
173+
x-ms-ratelimit-remaining-subscription-writes: 1199
174+
x-ms-correlation-request-id: bae60c92-669d-45a4-aed9-8392cca7cc8d
175+
x-ms-routing-request-id: CENTRALUSEUAP:20210708T205935Z:f51db7a4-9826-4084-aa3b-ae640dc78af6
176+
Cache-Control: no-cache
177+
Date: Thu, 08 Jul 2021 20:59:35 GMT
178+
Location: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationResults/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExOzVlNzMxZDBiLTQ3MDQtNDkzNS1hYmNjLWY4YWEzY2UzNTk1ZQ==?api-version=2021-07-01
179+
X-Powered-By: ASP.NET
180+
181+
```
182+
183+
Track the `Azure-AsyncOperation` header with a simple *GET* request. When the request is successful, it returns *200* (OK) with a status response.
184+
185+
```HTTP
186+
GET https://management.azure.com/subscriptions/e3d2d341-4ddb-4c5d-9121-69b7e719485e/providers/Microsoft.DataProtection/locations/westus/operationStatus/YWJjMGRmMzQtNTY1NS00MGMyLTg4YmUtMTUyZDE3ZjdiNzMyOzY4NDNmZWZkLWU4ZTMtNDM4MC04ZTJhLWUzMTNjMmNhNjI1NA==?api-version=2021-07-01
187+
{
188+
"id": "/subscriptions/e3d2d341-4ddb-4c5d-9121-69b7e719485e/providers/Microsoft.DataProtection/locations/westus/operationStatus/YWJjMGRmMzQtNTY1NS00MGMyLTg4YmUtMTUyZDE3ZjdiNzMyOzY4NDNmZWZkLWU4ZTMtNDM4MC04ZTJhLWUzMTNjMmNhNjI1NA==",
189+
"name": "YWJjMGRmMzQtNTY1NS00MGMyLTg4YmUtMTUyZDE3ZjdiNzMyOzY4NDNmZWZkLWU4ZTMtNDM4MC04ZTJhLWUzMTNjMmNhNjI1NA==",
190+
"status": "Inprogress",
191+
"startTime": "2021-10-22T20:22:41.0305623Z",
192+
"endTime": "0001-01-01T00:00:00Z"
193+
}
194+
195+
```
196+
197+
In case of issues, the response indicates errors that have to be solved before submitting the restore request. Once we fix the errors and revalidate the request, the 200 (OK) returns a success response.
198+
199+
```HTTP
200+
HTTP/1.1 200 OK
201+
Content-Length: 443
202+
Content-Type: application/json
203+
Expires: -1
204+
Pragma: no-cache
205+
X-Content-Type-Options: nosniff
206+
x-ms-request-id:
207+
Strict-Transport-Security: max-age=31536000; includeSubDomains
208+
x-ms-ratelimit-remaining-subscription-reads: 11999
209+
x-ms-correlation-request-id: 61d62dd8-8e1a-473c-bcc6-c6a7a19fb035
210+
x-ms-routing-request-id: SOUTHINDIA:20211022T203846Z:89af04a6-4e91-4b64-8998-a369dc763408
211+
Cache-Control: no-cache
212+
Date: Fri, 22 Oct 2021 20:38:46 GMT
213+
Server: Microsoft-IIS/10.0
214+
X-Powered-By: ASP.NET
215+
216+
{
217+
"id": "/subscriptions/e3d2d341-4ddb-4c5d-9121-69b7e719485e/providers/Microsoft.DataProtection/locations/westus/operationStatus/YWJjMGRmMzQtNTY1NS00MGMyLTg4YmUtMTUyZDE3ZjdiNzMyOzU0NDI4YzdhLTJjNWEtNDNiOC05ZjBjLTM2NmQ3ZWVjZDUxOQ==",
218+
"name": "YWJjMGRmMzQtNTY1NS00MGMyLTg4YmUtMTUyZDE3ZjdiNzMyOzU0NDI4YzdhLTJjNWEtNDNiOC05ZjBjLTM2NmQ3ZWVjZDUxOQ==",
219+
"status": "Succeeded",
220+
"startTime": "2021-10-22T20:28:24.3820169Z",
221+
"endTime": "2021-10-22T20:28:49Z"
222+
}
223+
224+
```
225+
226+
## Trigger restore requests
227+
228+
The trigger restore operation is a *POST* API. [Learn more](/rest/api/dataprotection/backup-instances/trigger-restore) about the trigger restore operation.
229+
230+
```HTTP
231+
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore?api-version=2021-07-01
232+
```
233+
234+
For example, the API translates to:
235+
236+
```HTTP
237+
POST "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupInstances/testpostgresql-empdb11-957d23b1-c679-4c94-ade6-c4d34635e149/restore?api-version=2021-07-01"
238+
```
239+
240+
### Create a request body for restore operations
241+
242+
Once the requests are validated, use the same request body to trigger **restore request* with minor changes.
243+
244+
**Response to trigger restore requests**:
245+
246+
The *trigger restore request* is an [asynchronous operation](../azure-resource-manager/management/async-operations.md). So, this operation creates another operation that needs to be tracked separately.
247+
248+
It returns two responses: 202 (Accepted) when another operation is created. Then 200 (OK) when that operation completes.
249+
250+
| Name | Type | Description |
251+
| --- | --- | --- |
252+
| **200 OK** | | Status of restore request |
253+
| **202 Accepted** | | Accepted |
254+
255+
Example response to trigger restore request:
256+
257+
Once the *POST* operation is submitted, it will return the initial response as *202* (Accepted) with an *Azure-asyncOperation* header.
258+
259+
```HTTP
260+
HTTP/1.1 202 Accepted
261+
Content-Length: 0
262+
Expires: -1
263+
Pragma: no-cache
264+
Retry-After: 30
265+
Azure-AsyncOperation: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExO2Q1NDIzY2VjLTczYjYtNDY5ZC1hYmRjLTc1N2Q0ZTJmOGM5OQ==?api-version=2021-07-01
266+
X-Content-Type-Options: nosniff
267+
x-ms-request-id:
268+
Strict-Transport-Security: max-age=31536000; includeSubDomains
269+
x-ms-ratelimit-remaining-subscription-writes: 1197
270+
x-ms-correlation-request-id: 8661209c-5b6a-44fe-b676-4e2b9c296593
271+
x-ms-routing-request-id: CENTRALUSEUAP:20210708T204652Z:69e3fa4b-c5d9-4601-9410-598006ada187
272+
Cache-Control: no-cache
273+
Date: Thu, 08 Jul 2021 20:46:52 GMT
274+
Location: https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationResults/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExO2Q1NDIzY2VjLTczYjYtNDY5ZC1hYmRjLTc1N2Q0ZTJmOGM5OQ==?api-version=2021-07-01
275+
X-Powered-By: ASP.NET
276+
277+
```
278+
279+
Track the `Azure-AsyncOperation` header with a simple *GET* request. When the request is successful, it will return 200 (OK) with a job ID that should be further tracked for completion of restore request.
280+
281+
```HTTP
282+
GET https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExO2Q1NDIzY2VjLTczYjYtNDY5ZC1hYmRjLTc1N2Q0ZTJmOGM5OQ==?api-version=2021-07-01
283+
284+
{
285+
"id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/providers/Microsoft.DataProtection/locations/westus/operationStatus/ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExO2Q1NDIzY2VjLTczYjYtNDY5ZC1hYmRjLTc1N2Q0ZTJmOGM5OQ==",
286+
"name": "ZmMzNDFmYWMtZWJlMS00NGJhLWE4YTgtMDNjYjI4Y2M5OTExO2Q1NDIzY2VjLTczYjYtNDY5ZC1hYmRjLTc1N2Q0ZTJmOGM5OQ==",
287+
"status": "Succeeded",
288+
"startTime": "2021-07-08T20:46:52.4110868Z",
289+
"endTime": "2021-07-08T20:46:56Z",
290+
"properties": {
291+
"jobId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupJobs/c4bd49a1-0645-4eec-b207-feb818962852",
292+
"objectType": "OperationJobExtendedInfo"
293+
}
294+
}
295+
296+
```
297+
298+
## Track jobs
299+
300+
The *trigger restore requests* trigger the restore job. To track the resultant Job ID, use the [GET Jobs API](/rest/api/dataprotection/jobs/get).
301+
302+
Use the *GET* command to track the `JobId` present in the [trigger restore response above](#trigger-restore-requests).
303+
304+
```HTTP
305+
GET /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/TestBkpVaultRG/providers/Microsoft.DataProtection/backupVaults/testBkpVault/backupJobs/c4bd49a1-0645-4eec-b207-feb818962852?api-version=2021-07-01
306+
307+
```
308+
309+
The job status mentioned above indicates that the restore job is complete.
310+
311+
## Next steps
312+
313+
[About Azure Database for PostgreSQL - Flexible server backup (preview)](backup-azure-database-postgresql-flex-overview.md).
314+
315+
316+
317+
318+
319+
320+
321+
322+
323+
324+
325+
326+
327+
328+
329+
330+
331+
332+
333+
334+
335+
336+
337+
338+
18339

articles/backup/backup-azure-database-postgresql-flex-use-rest-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ DELETE "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/Test
464464

465465
**Responses for delete protection**:
466466

467-
*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.
467+
*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.
468468
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
469469

470470
| Name | Type | Description |

0 commit comments

Comments
 (0)