Restore Azure Database for PostgreSQL backups

This article explains how to restore a database to an Azure PostgreSQL server backed up by Azure Backup.

You can restore a database to any Azure PostgreSQL server of a different/same subscription but within the same region of the vault, if the service has the appropriate set of permissions on the target server.

Restore Azure PostgreSQL database

  1. Go to Backup vault -> Backup Instances. Select a database and click Restore.

    Screenshot showing the process to select and restore a database.

    Alternatively, you can navigate to this page from the Backup center.

  2. On the Select restore point page, select a recovery point from the list of all full backups available for the selected backup instance. By default, the latest recovery point is selected.

    Screenshot showing the process to select a recovery point.

    If the restore point is in the archive tier, you must rehydrate the recovery point before restoring. Provide the following additional parameters required for rehydration:

    • Rehydration priority: Default is Standard.
    • Rehydration duration: The maximum rehydration duration is 30 days, and the minimum rehydration duration is 10 days. Default value is 15 days. The recovery point is stored in the Backup data store for this duration.
  3. On the Restore parameters page, select one of the following restore types: Restore as Database or Restore as Files.

    • Restore as Database

      The target server can be same as the source server. However, overwriting the original database isn't supported. You can choose from the server across all subscriptions, but in the same region as that of the vault.

      1. In the Select key vault and the secret drop-down list, select a vault that stores the credentials to connect to the target server.

      2. Select Review + Restore to trigger validation to check if the service has restore permissions on the target server. These permissions must be granted manually.

      Screenshot showing the selected restore type as Restore as Database.

    • Restore as Files: Dump the backup files to the target storage account (blobs).

      You can choose from the storage accounts across all subscriptions, but in the same region as that of the vault.

      1. In the Select the target container drop-down list, select one of the containers filtered for the selected storage account.
      2. Select Review + Restore to trigger validation to check if the backup service has the restore permissions on the target storage account.

      Screenshot showing the selected restore type as Restore as Files.

  4. Submit the Restore operation and track the triggered job under Backup jobs.

    Screenshot showing the tracked triggered job under Backup jobs.

Note

Archive support for Azure Database for PostgreSQL is in limited public preview.

Restore permissions on the target storage account

Assign the Backup vault MSI the permission to access the storage account containers using the Azure portal.

  1. Go to Storage Account -> Access Control -> Add role assignment.

  2. Select the Storage Blob Data Contributor role in the Role drop-down list to the Backup vault MSI.

    Screenshot showing the process to assign Backup vault M S I the permission to access the storage account containers using the Azure portal.

Alternatively, give granular permissions to the specific container you're restoring to by using the Azure CLI az role assignment create command.

az role assignment create --assignee $VaultMSI_AppId  --role "Storage Blob Data Contributor"   --scope $id

Replace the assignee parameter with the Application ID of the vault's MSI and the scope parameter to refer to your specific container. To get the Application ID of the vault MSI, select All applications under Application type. Search for the vault name and copy the Application ID.

Screenshot showing the process to get the Application I D of the vault MSI.

Screenshot showing the process to copy  the Application I D of the vault.

Next steps

Troubleshoot PostgreSQL database backup by using Azure Backup