Hi Shobhit Joshi,
Thanks for approaching on Microsoft Q&A!
You trying to restore a database in Azure SQL Database that was deleted quite a while ago. Unfortunately, the ability to restore a deleted database depends heavily on the backup retention policies in place when the database was deleted.
Here’s what you can try:
- Check Retention Period: The Azure SQL Database service automatically backs up databases, but the retention period varies by service tier. The default is usually 7 to 35 days. If your database was deleted more than that, unfortunately, it cannot be restored.
- Restore from Deleted Databases:
- Go to the Azure portal and navigate to the Azure SQL Server where the database used to be.
- Select the Deleted databases blade.
- If you see your database listed, select it and follow the prompts to create a new database:
- Specify whether it's a Point-in-Time or Long-term backup retention restore.
- Choose the restore point or backup you need.
- Give a unique name for the new database and click Create.
- Use PowerShell or Azure CLI: If you prefer scripting:
- With PowerShell, use:
Get-AzSqlDeletedDatabaseBackup -ResourceGroupName "YourResourceGroup" -ServerName "YourServer"
- After confirming it is in the list, restore with:
Restore-AzSqlDatabase -FromDeletedDatabaseBackup -DeletionDate "DeletationDate" -ResourceGroupName "YourResourceGroup" -ServerName "YourServer" -TargetDatabaseName "NewDatabaseName".
- For Azure CLI, check:
az sql db list-deleted --subscription [subscription ID] --resource-group [Resource Group Name] --server [Server Name]
- Long-Term Retention (LTR): If you had LTR configured before the database was deleted, you might be able to restore from those backups.
Please refer the Microsoft document for more details.
https://learn.microsoft.com/en-us/azure/azure-sql/database/recovery-using-backups?view=azuresql&tabs=azure-portal
I hope this help, let us know if you have any further queries on this.
Thanks!
Kalyani