A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.microsoft.com/en-us/azure/backup/restore-azure-database-postgresql-flex below:

Restore Azure PostgreSQL-Flexible server as Files using Azure portal - Azure Backup

This article describes how to restore an Azure PostgreSQL-Flexible server as Files backed up using Azure portal.

Prerequisites

Before you restore from Azure Database for PostgreSQL Flexible server backups, review the following prerequisites:

Restore Azure PostgreSQL - Flexible server backups as files

Note

Restore operation is a two step process:

  1. Restore the backup from Backup vault to a storage container.
  2. Restore the backup files from storage container to a new or existing flexible server.

To restore Azure PostgreSQL-Flexible database, Follow these steps:

  1. Go to Backup vault > Backup Instances. Select the PostgreSQL - Flexible server to be restored and select Restore.

    Alternatively, go to Backup center and select Restore.

  2. Select the point in time you would like to restore by using Select restore point. Change the date range by selecting Time period.

  3. Choose the target storage account and container in Restore parameters tab. Select Validate to check the restore parameters permissions before the final review and restore.

  4. Once the validation is successful, select Review + restore.

  5. After final review of the parameters, select Restore to restore the selected PostgreSQL - Flexible server backup in target storage account.

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

After the restore job is completed successfully, go to the storage account container to view the restored databases as files (.sql files) from your PostgreSQL – Flexible server. Azure Backup also generates the following backup files:

Restore the backup files from storage container to a new or existing PostgreSQL – Flexible server

To restore the backup files from storage container to a new or existing PostgreSQL – Flexible server, follow these steps:

  1. Ensure that all required extensions are enabled on the new target Flexible server.

  2. Match the server parameter values from the source PostgreSQL database to the Azure Database for PostgreSQL by accessing the Server parameters section in the Azure portal and manually updating the values accordingly. Save the parameter changes, and then restart the Azure Database for PostgreSQL - Flexible server to apply the new configuration.

  3. If Microsoft Entra Authentication is required on the new server, enable it and create the relevant Microsoft Entra admins.

  4. Create a new database for restoration.

    Note

    Before the database restoration, you must create a new, empty database. Ensure that your user account has the CREATEDB permission.

    To create the database, use the CREATE DATABASE Database_name command.

  5. Restore the database using the database.sql file as the target admin user. 1.After the target database is created, restore the data in this database (from the dump file) from an Azure storage account by running the following command:

    az storage blob download --container-name <container-name> --name <blob-name> --account-name <storage-account-name> --account-key <storage-account-key> --file - | pg_restore -h <postgres-server-url> -p <port> -U <username> -d <database-name> --no-owner -v – 
    

    Alternatively, you can download the backup file and run the restore directly.

  6. Restore only the required roles and privileges, and ignore the common errors. Skip this step if you're performing the restoration for compliance requirements and data retrieval, as a local admin.

Restore roles and users for the restored databases

Vaulted backups are primarily restored for compliance needs such as, testing and audits. You can sign in as a local admin and restore using the database.sql file; no other roles are needed for data retrieval.

For other uses like accidental deletion protection or disaster recovery, ensure necessary roles are created as per your organization needs. Avoid duplications between roles.sql and database.sql.

When you restore from roles.sql, some roles or attributes might not be valid for the new target server.

For environments with superuser access (on-premises or VMs), you can run all commands seamlessly.

Key considerations for the Flexible server scenario

Here are the key considerations:

Before you restore the database objects, ensure that you properly dump and clean up the roles. To perform this action, download the roles.sqlscript from your storage container and create all required logins.

You can download the roles script from your storage account as shown in the following screenshot:

When you migrate the output file, roles.sql might include certain roles and attributes that aren't applicable in the new environment. You must consider the following:

Use the following sed command to clean up your roles dump:

sed -i '/azure_superuser/d; /azure_pg_admin/d; /azuresu/d; /^CREATE ROLE replication/d; /^ALTER ROLE replication/d; /^ALTER ROLE/ {s/NOSUPERUSER//; s/NOBYPASSRLS//;}' roles.sql

This command deletes the lines containing azure_superuser, azure_pg_admin, azuresu, lines starting with CREATE ROLE replication and ALTER ROLE replication, and removes the NOSUPERUSER and NOBYPASSRLS attributes from ALTER ROLE statements.

Next steps

Manage backup of Azure PostgreSQL - Flexible Server using Azure portal.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4