Hi @Hakan AK,
Thanks for reaching out to Microsoft Q&A.
If you've accidentally deleted an Azure SQL Database, recovery depends on several factors, including whether the database was deleted permanently or if backups are available. Here’s what you can do:
- Check the Retention Period for Automated Backups
Azure SQL Database provides automated backups that include:
Point-in-Time Restore (PITR): Can restore the database to a state at any point within the retention period.
Long-Term Retention (LTR): If configured, can restore backups stored for months or years.
Steps:
Log in to the Azure Portal.
Navigate to the SQL Server that hosted your database.
Go to the Deleted databases section under the SQL Server:
Check if the deleted database is listed here. If yes, restore it using the available backups.
- Restore Using Point-in-Time Recovery
If the database is not listed under "Deleted databases," you can still recover it if it's within the PITR retention period.
Steps:
In the Azure Portal, go to the SQL Server that hosted the database.
Click on Backups in the SQL Server menu.
Select Point-in-time restore for the deleted database.
Choose the time to restore the database to and specify a name for the new database.
Confirm and start the restore process.
- Check Long-Term Retention (LTR) Backups
If you had LTR configured, you can restore from an LTR backup.
Steps:
Navigate to the SQL Server in the Azure Portal.
Go to the Manage Backups section.
Check if there are LTR backups for the deleted database.
Select the backup, click Restore, and specify the restore options.
- Contact Microsoft Support (Last Resort)
If no backups are available and the database is critical:
Open a support ticket with Microsoft Azure Support.
Provide them with the database name, server name, and deletion time.
Microsoft may be able to help retrieve the data if recovery is initiated promptly.
- Future Recommendations
To prevent accidental deletion and ensure easier recovery:
Enable Soft Delete for Azure SQL Databases, if available.
Use Long-Term Retention (LTR) for critical databases.
Set up Resource Locks in the Azure Portal to prevent accidental deletion:
Go to the resource (SQL Database or Server).
Click Locks and add a lock with type ReadOnly or Delete.
Let me know if you need help with any of the recovery steps!
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.