How to Restore the Azure SQL Managed instance DB using Azure CLI/Poratl

https://docs.microsoft.com/en-us/azure/sql-database/scripts/sql-database-restore-database-cli

Limitations

Point in time restore to a managed instance has the following limitations:

  • When you’re restoring from one managed instance to another, both instances must be in the same subscription and region. Cross-region and cross-subscription restore aren’t currently supported.
  • Point-in-time restore of a whole managed instance is not possible. This article explains only what’s possible: point-in-time restore of a database that’s hosted on a managed instance.

$subscriptionId = “”
Get-AzSubscription -SubscriptionId $subscriptionId
Select-AzSubscription -SubscriptionId $subscriptionId

$resourceGroupName = “”
$managedInstanceName = “”
$deletedDatabaseName = “”
$targetDatabaseName = “”

$deletedDatabase = Get-AzSqlDeletedInstanceDatabaseBackup -ResourceGroupName $resourceGroupName `
-InstanceName $managedInstanceName -DatabaseName $deletedDatabaseName

Restore-AzSqlinstanceDatabase -Name $deletedDatabase.Name -InstanceName $deletedDatabase.ManagedInstanceName
-ResourceGroupName $deletedDatabase.ResourceGroupName -DeletionDate $deletedDatabase.DeletionDate
-PointInTime UTCDateTime `
-TargetInstanceDatabaseName $targetDatabaseName

Published by Santhosh Reddy

I am working as a SQL Server DBA.

Leave a comment