How to Restore an Azure SQL Database.
Well! There are several circumstances like human-made or natural disasters, infected database/server, power outages, equipment theft, malfunctions or failures, or firmware corruption that leads to the need for a database restore in our organizations.
Database restore is the process of copying backup data from secondary storage and restoring it to its original location or a new location. A restore is performed to return data that has been lost, stolen or damaged to its original condition or to move data to a new location.
In Azure SQL Database, taking manual backups aren't possible and Azure takes care of the backup and it’s called Automated backups. So, in this blogpost we’ll see how you can restore an automated backup for some older period within the period of backup retention that you have defined during database configuration.
An Azure SQL Database can be restored to the same server or to a different server in a different region (Geo-Restore) using GUI (Azure Portal) or PowerShell for doing this.
![](https://static.wixstatic.com/media/8531b9_897e9bfbae884fcd8fe1daebb9b7cd09~mv2.png/v1/fill/w_500,h_285,al_c,q_85,enc_auto/8531b9_897e9bfbae884fcd8fe1daebb9b7cd09~mv2.png)
Steps to Restore an Azure SQL Database using GUI
To restore Azure SQL Database from an older backup we need to go to the database Overview and click on the “Restore” icon.
![](https://static.wixstatic.com/media/8531b9_349b285609f54c4a898f1caf31f70b82~mv2.png/v1/fill/w_912,h_300,al_c,q_85,enc_auto/8531b9_349b285609f54c4a898f1caf31f70b82~mv2.png)
When you click on the restore button, you'll get the option to select a time of PITR or LTR (Long Term Retention) backup, and just click on the Review + Create.
![](https://static.wixstatic.com/media/8531b9_80b996efe8044029a0dd2abfa3af315d~mv2.png/v1/fill/w_626,h_792,al_c,q_90,enc_auto/8531b9_80b996efe8044029a0dd2abfa3af315d~mv2.png)
Steps to Restore an Azure SQL Database using PowerShell
To restore an Azure SQL Database, you cannot use the T-SQL the reason being you don’t know the location of the Azure SQL Database backups.
For doing it using PowerShell first connect to Azure using Az Login. Once connected to your Azure subscription.
PS C:\>$Database = Get-AzSqlDatabase -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01"
Once you have the details for the database you need to have the time to which you want to restore, target database name, edition and server name.
PS C:\> Restore-AzSqlDatabase -FromPointInTimeBackup -PointInTime UTCDateTime -ResourceGroupName $Database.ResourceGroupName -ServerName $Database.ServerName -TargetDatabaseName "RestoredDatabase" -ResourceId $Database.ResourceID -Edition "Standard" -ServiceObjectiveName "S2"
Please do check out the Microsoft's Restore-AzSqlDatabase Docs to know more about the Az-SqlDatabase commands.
That's all in this post. If you liked this blog and interested in knowing more about Azure, Please Like, Follow, Share & Subscribeto www.ImJhaChandan.com.
Comentários