skip to Main Content

I accidentally deleted a table manually from my Azure SQL Server database in an ASP.NET Web API & Entity Framework project.

How can I restore it?

Migrations won’t update because it thinks the database is up to date, unaware of the deleted table.

2

Answers


  1. Agreed with @T N Azure SQL databases are backed up automatically. store it for some retaintion period in which you can restore it further if you need.

    Azure SQL databases creates below backups:.

    • Full backups every week.
    • Differential backups every 12 or 24 hours.

    You can get it in your Azure SQL databases >> Data Management >> Backups >> automatically created database backup you will see here:

    enter image description here

    You can restore it to another database and you can generate the script for table using SSMS or Azure Data studio (ADS) check this document or you can use Data factory to create and move data to table from this backed up database.

    Login or Signup to reply.
  2. The way I have done this before, I perform point-in-time restores to new databases selecting different point in time close to the time the table was deleted. You can do that using Azure Portal or PowerShell.

    $subscription = "Subscription1"
    Login-AzureRmAccount -Subscription $subscription
    Get-AzureRmSubscription
    Select-AzureRmSubscription -Subscription $subscription
    
    $resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName
    $server = Get-AzureRmSqlServer -ResourceGroupName $resourceGroup.ResourceGroupName -ServerName $serverName
    $database = Get-AzureRmSqlDatabase -ServerName $server.ServerName -ResourceGroupName $resourceGroup.ResourceGroupName -DatabaseName $databaseName
    
    New-AzureRmSqlDatabaseRestorePoint -RestorePointLabel $restorePointName -ResourceGroupName $resourceGroup.ResourceGroupName -ServerName $server.ServerName -DatabaseName $database.DatabaseName
    

    Once you find the table on one of the newly created databases as result of the restore operations, you can use Azure Elastic Queries or Azure Data Factory to move the data in the table to the Production or original database.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search