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
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.
4
4
ms.topic: conceptual
5
5
ms.date: 04/30/2024
6
6
ms.assetid: 759ee63f-148b-464c-bfc4-c9e640b7da6b
@@ -10,9 +10,330 @@ ms.author: v-abhmallick
10
10
11
11
# Restore Azure Database for PostgreSQL - Flexible servers using REST API (preview)
12
12
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.
16
14
17
15
## 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. |
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.
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.
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
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.
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.
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
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).
*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.
468
468
It returns two responses: 202 (Accepted) when another operation is created, and 200 (OK) when that operation completes.
0 commit comments