top of page

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.

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.

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.

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


jc_logo.png

Hi, thanks for stopping by!

Welcome! to my “Muse & Learn” blog.

This website will help you to learn useful queries/SQL, Tips to troubleshoot problem and their remediation, perform DB related activities etc... and don't forget to muse with us :)....

It cover few useful information on below topics :

 

MySQL, SQL Server, DB2, Linux/UNIX/AIX, HTML ....

Let the posts
come to you.

Thanks for submitting!

  • Instagram
  • Facebook
  • Twitter
© 2023 By ImJhaChandan
bottom of page