Rajendra Gupta
Geo-restore in Azure SQL Database

Exploring Azure SQL Database Geo-Restore

September 2, 2022 by

This article explains Azure SQL Database Geo Restore using geo-replicated backups for disaster recovery.

Introduction

Any business continuity and disaster recovery plan must include database backups to protect your data from corruption and loss. Azure database backups allow point-in-time recovery within the configured window. By default, it has 35 days retention period, but you can extend up to 10 years using long-term retention for single and pooled databases.

The backup frequency for Azure SQL Database and Managed Instance (MI) is as below.

  • Full back up every week
  • Differential backup every 12-24 hours
  • Transaction log backup every 5-10 mins

Once you deploy an Azure SQL Database, it asks you to specify backup storage redundancy.

backup storage redundancy

The supported values for backup storage redundancy are below.

  • Locally redundant backup storage
  • Zone-redundant backup storage
  • Geo-redundant backup storage

Before we explore the storage redundancy, let’s understand the term – Paired Region.

Paired Region

Azure regions are set of multiple datacenters grouped in the geographic region. These data centers connect with low latency networks and high throughput to ensure high performance and security.

The regional pair contains two regions within the same geography. Azure ensures that at least one region is available during any planned maintenance.

Azure Geography

Note: All diagrams in the article are references from Microsoft docs.

Few specific Azure Services use the paired region for business continuity and protecting data loss. For example, Azure Geo-Redundant Storage (GRS) replicates data from a primary to a secondary region. It ensures that you don’t lose data if the primary region is not recoverable.

To get a list of Azure paired regions, refer to the article https://docs.microsoft.com/en-us/azure/best-practices-availability-paired-regions.

Azure paired region

The following diagram shows a representation of the hypothetical Azure regional pair.

Overview of Paired Region Benefits

Backup storage redundancy

In the default configuration, the Azure SQL Database configuration stores data in the geo-redundant storage blobs. These storage blogs replicate data to the paired region. Therefore, if an outage occurs in the primary region, you can restore the backups in a different region.

Let’s explore the different options available for backup storage redundancy.

Locally-redundant storage

The locally redundant storage replicates data three times in the primary region within the data center. It provides 99.999999999%(11 nines) durability of objects in the given year. It protects data from server rack and drives failures. It writes data synchronously among the three replicas. The locally redundant storage provides owest-cost redundancy and durability.

Locally-redundant storage

Zone-redundant storage

The Zone redundant storage (ZRS) replicates data across three availability zones in the primary region. These availability zones consist of separate physical locations, power, cooling, networking. Azure provides 99.9999999999(12 9’s) durability over a given year.

The ZRS writes data to the availability zone storage copies synchronously. It means that once the data is written to all data copies across availability zones, the write operation is successful.

The ZRS is suitable for high availability with excellent performance, low latency.

Note: The Zone redundant storage is not available across all regions. You can navigate to https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy for a list of supported regions.

Zone-redundant storage

Geo-redundant storage

Geo-redundant storage

As shown in the diagram above, the Geo-redundant storage(GRS) does the following:

  • It uses locally-redundant copies (LRS) and synchronizes data three times in the primary region
  • It copies data to a secondary physical region asynchronously, and the secondary region is situated hundreds of miles away from the primary region
  • The secondary region also uses LRS and maintains three copies of data

The Geo-redundant storage allows you to read or write data even if the entire region is unavailable. If the entire primary region has an outage or disaster, you can retrieve data from the secondary region. It provides 99.99999999999999% (16 9’s) durability over a given year.

Geo-restore in Azure SQL Database

Azure SQL Database enables users to restore a database to another(any) Azure region using geo-replicated backups. You can restore the backups to another region if the Azure SQL DB is configured with the Geo-redundant backup storage.

The geo-restore is the default recovery method if the database is unavailable in the primary (hosting) region. As sown in the below image, due to region outage in US East, you can restore the last geo-replicated backup to any existing or new Azure server.

Geo-restore in Azure SQL Database

The above image reflects the restoration of the Azure database in the secondary region due to an outage in the hosting replica.

Note:

  1. The geo-restore works even if the data center or database in the hosting region is unavailable
  2. There might delay(up to 1 hr.) between a database backup and its replication to the secondary region

Use Azure portal for Geo-restore

This section uses the Azure portal and specifies the steps for geo restore database in a region apart from the hosting region.

In my demo environment, the Azure database is in Central India.

Geo-restore backups

For testing the geo-restore, I create a new Azure SQL Database in the US (East) region. In the Azure portal, search for SQL Database and launch Create SQL Database page.

In the database details, select or create a new Azure Server in East US.

Database Details

Navigate to the additional settings page and choose backup in the use of existing data.

Data source

Once you click on the backup option, it gives you a list of databases available for restores. As you can see, in my case, it displays [azuredemosqldemo] database hosted in Central India, and we want to restore it in East US.

It displays the latest backup available for the geo-restore.

Select the geo replicated backup

Select the backup, and you get a prompt stating that selecting this backup will modify the compute+ storage in basics. It sets the compute and storage equivalent to the source Azure database. You can scale up the resource post-restoration. Select the database backup

Click OK, review your configurations, and click on deploy to proceed with geo restore in the Azure region.

Review the deployment

Use Azure PowerShell script for geo-redundant backup of a database

We can use the Azure PowerShell command – Get-AzSqlDatabaseGeoBackup – to get details of geo-redundant backup of Azure SQL Database.

Launch Azure Cloud Shell in Azure portal and configure for your local server using the article https://www.sqlshack.com/an-overview-of-azure-cloud-shell/

The Get-AzSqlDatabaseGeoBackup requires resource name and Azure server name, and it returns information about all databases present in the Azure server.

Get-AzSqlDatabaseGeoBackup  -ResourceGroupName “MyAzureLabSQL” -ServerName “azuredemosqldemo”

As shown below, it returns the Azure database, edition, and last available backup for geo restore. You can note that it is impossible to specify a backup other than the last available backup (recent) for geo restore.

Use Azure PowerShell for database backup

To perform the geo restore using Azure PowerShell, use the command – Restore-AzSqlDatabase.

  • The Get-AzSQLDatabaseGeoBackup returns the information of geo-redundant backup for the database – Database01.
  • The second command, Restore-AzSqlDatabase, restores geo backup in the target Azure server with the database name – RestoredDatabase.

$GeoBackup = Get-AzSqlDatabaseGeoBackup -ResourceGroupName “ResourceGroup01” -ServerName “Server01” -DatabaseName “Database01”
Restore-AzSqlDatabase -FromGeoBackup -ResourceGroupName “TargetResourceGroup” -ServerName “TargetServer” -TargetDatabaseName “RestoredDatabase” -ResourceId $GeoBackup.ResourceID -Edition “Standard” -ServiceObjectiveName “S2”

Geo-Restore limitations

The geo-restore feature in Azure SQL Database and Managed Instance has the following limitations.

  • It does not support performing a point-in-time recovery on the secondary Azure region.
  • The Geo-Restore provides a basic disaster recovery mechanism and relies on geo-replicated backups.
  • The geo-replicated backups have a recovery point objective (RPO) of up to 1 hour and a recovery time of up to 12 hours.
  • IN case of a region outage, it does not guarantee to restore capability due to a sharp increase in demand for resource deployment in the secondary region.
  • It is suitable for relatively small and less critical databases that can afford data loss from the last geo-replicated backups.
  • It is always recommended to use Auto Failover Groups for business-critical applications. It offers lower RPO and RTO with guaranteed data availability.

Conclusion

The article explores Azure SQL Database Geo Restore that can restore the latest backup in any Azure region. Therefore, if your instance is not available due to an incident, you may choose to recover database and application connectivity.

Rajendra Gupta
216 Views