Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1891

Long Term Backup Retention [LTR] On Azure SQL Managed Instance

$
0
0

In this blog, I have covered the overview of Long-Term Backup Retention [LTR] On Azure SQL Managed Instance. Also how to create, configure, restore a backup, and many more things which are essential to learn as a database administrator.

Topics we’ll cover

What Is Long-Term Backup Retention

Most of the applications have regulatory, consistency or other business purposes that expect you to hold database backups beyond the 7-35 days given by Azure SQL Managed Instance Automated Backups.

By using the long-term retention (LTR) feature, you can store the predefined full backups of a SQL Managed Instance database in Azure Blob storage with configured redundancy for as long as 10 years.

You can then restore any backup as a new database. Long-term retention is accessible in Public Preview for Azure SQL Managed Instance.

Long Term Backup Retention On Azure SQL Managed InstanceHow Long Term Retention Works

Long-term backup retention (LTR) uses the full database backups that are consequently made to empower point-time restore (PITR).

On the off chance that an LTR policy is configured, these backups are too different for long-term storage. The LTR policy for every database can likewise indicate how regularly the LTR backups are created.

To enable LTR, you can characterize a policy using a combination of four parameters: yearly backup retention (Y), Monthly backup retention (M), weekly backup retention (W), and week of the year(WeekOfYear).

Configuring Backup Storage Redundancy

By Default, SQL Managed Instance stores information in geo-redundant storage blobs that are replicated according to the paired region.
At the point when an Azure area is inaccessible, geo-restore can be utilized to recuperate the database in a different Azure region. Geo-restore is accessible in case of backups are geo-redundant.

In any case, to meet data residency prerequisites, then managed instance backups can now be configured as zone and local redundant. This guarantees that the database backups stay inside in the same region. The configured backup storage redundancy for a given managed instance applies to both Point in time restore (PITR) backups and long-term retention backups (LTR).

Long-Term Retention Using Azure Portal

Here you need to configure long-term retention for your SQL Managed Instance database using the Azure portal. When you set up long-term retention for a database, you may perform the following operations on your backups.

  • Update the long-term retention policy for your database.
  • View or get a list of available long-term retention backups.
  • Delete a long-term retention backup.
  • Restore from a long-term retention backup of a deleted database.
  • Monitor the long-term retention backup costs.

Steps to Create Or Update LTR  Policy For A Managed Instance Database

1. The first thing required to perform Long-Term Backup Retention [LTR] On Azure SQL Managed Instance is to get a Trial Account of Microsoft Azure. (You get 200 USD FREE Credit from Microsoft to practice).

You can Check out our blog to know more about how to create a free Azure account.

2. After creating an azure account, open a browser and log in to the Azure portal using your Azure credentials: https://portal.azure.com.

3. Navigate to the Azure Portal and then go to the managed instance.

4. Open the Backup tab. Then, Click on the retention policies and select the database for which you want to set the long-term retention policy.
5. Then, Click on configure the policies. And change the long-term retention policies for the selected database.
6. Apply the settings Yearly, Monthly, Weekly that you would like to keep for Long term Retention and Click on the apply button.

View Backups And Restore From A Backup

1. Go to the Azure portal and navigate to the server and then select backups. to view the long-term retention backup for a specific database then, select manage under the available LTR backup column. An LTR backup for the selected database pane will appear.

2. In the available long-term retention backups pane that appears, review the available backups. you may select a backup to restore from or to delete.

3. Then select the backup from which you want to restore, and then select Restore.

4. Then choose a name for your new database, then click on Review +Create to review the details of your restore. Select create to restore your database from the chosen backup.

5. On the toolbar pane, click on the notification icon to view the status of the restore job.

6. When the restore job is completed, open the SQL Database page to view the newly restored database.

Analyze Long-Term Retention Costs

To analyze backup costs, you can use the cost analysis tool available at the subscription level on the Azure portal.
follow these steps to analyze your cost
1. Navigate to your Subscription on the Azure Portal > Click on Cost Analysis > Click on add filter > Add a service name filter with value SQL Database then.
2. Add another filter for the Meter subcategory with value backup storage
3. In the charts displayed, you can see the long-term retention backup listed from your resources.

Long-Term Retention Using Powershell

1. Create An Long-Term Retention Policy.

# get the SQL server
$subId = "<subscriptionId>"
$serverName = "<serverName>"
$resourceGroup = "<resourceGroupName>"
$dbName = "<databaseName>"

Connect-AzAccount
Select-AzSubscription -SubscriptionId $subId

$server = Get-AzSqlServer -ServerName $serverName -ResourceGroupName $resourceGroup

# create LTR policy with WeeklyRetention = 12 weeks. MonthlyRetention and YearlyRetention = 0 by default.
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
    -ResourceGroupName $resourceGroup -WeeklyRetention P12W

# create LTR policy with WeeklyRetention = 12 weeks, YearlyRetention = 5 years and WeekOfYear = 16 (week of April 15). MonthlyRetention = 0 by default.
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
    -ResourceGroupName $resourceGroup -WeeklyRetention P12W -YearlyRetention P5Y -WeekOfYear 16

2. View Long-Term Retention Policies.

# get all LTR policies within a server
$ltrPolicies = Get-AzSqlDatabase -ResourceGroupName $resourceGroup -ServerName $serverName | `
    Get-AzSqlDatabaseLongTermRetentionPolicy

# get the LTR policy of a specific database
$ltrPolicies = Get-AzSqlDatabaseBackupLongTermRetentionPolicy -ServerName $serverName -DatabaseName $dbName `
    -ResourceGroupName $resourceGroup

3. View Long-Term Retention Backups.

# get the list of all LTR backups in a specific Azure region
# backups are grouped by the logical database id, within each group they are ordered by the timestamp, the earliest backup first
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location

# get the list of LTR backups from the Azure region under the named server
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -ServerName $serverName

# get the LTR backups for a specific database from the Azure region under the named server
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -ServerName $serverName -DatabaseName $dbName

# list LTR backups only from live databases (you have option to choose All/Live/Deleted)
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -DatabaseState Live

# only list the latest LTR backup for each database
$ltrBackups = Get-AzSqlDatabaseLongTermRetentionBackup -Location $server.Location -ServerName $serverName -OnlyLatestPerDatabase

4. Delete Long-Term Retention Backups.

# remove the earliest backup
$ltrBackup = $ltrBackups[0]
Remove-AzSqlDatabaseLongTermRetentionBackup -ResourceId $ltrBackup.ResourceId

Conclusion

To meet the organization’s regulatory needs or compliance. You can now easily configure long-term retention backups for up to 10 years for Azure SQL Managed Instance Database. You can do this process by the Azure Portal and Powershell.

Wanna Try Something Related

Next Task For You

We will cover all the exam objectives related to how to perform migrations, Hands-On Labs, and practice tests in our Azure Database Administrator training program. If you want to begin your journey towards becoming a Microsoft Certified: Azure Database Administrator Associate by checking our FREE CLASS.DBAdmin_CU

The post Long Term Backup Retention [LTR] On Azure SQL Managed Instance appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1891

Trending Articles