Automatic backups for Azure SQL Managed Instance
Azure SQL Managed Instance provides built‑in automatic backups that protect your data without any additional configuration. This tutorial explains the backup model, how to configure retention, and how to restore from an automatic backup.
How automatic backups work
Microsoft Azure continuously takes full, differential, and transaction log backups. The schedule is:
- Full backups: weekly (default) – stored in RA‑GRS storage.
- Differential backups: every 12‑24 hours.
- Transaction log backups: every 5‑10 minutes.
All backups are encrypted at rest with your Managed Instance's service‑level encryption key.
Retention policies
The default retention period is 7 days for short‑term backups and up to 35 days for long‑term retention (LTR) if configured. You can modify these settings through the Azure portal or Azure CLI.
Example: Extend short‑term retention to 30 days
az sql mi update \
--resource-group MyResourceGroup \
--name myManagedInstance \
--backup-storage-redundancy Geo \
--maintenance-window 30
Restoring a database
You can restore a database to a point in time within the retention window.
Portal restore steps
- Navigate to SQL managed instances > your instance.
- Select Backups in the left menu.
- Choose the database and click Restore.
- Pick a point‑in‑time and provide a new database name.
- Click OK to start the restore operation.
CLI restore example
az sql db restore \
--resource-group MyResourceGroup \
--server myManagedInstance \
--name MyDatabase \
--dest-name MyDatabase_Restore \
--time "2024-09-01T10:30:00Z"
Monitoring backups
Use Azure Monitor and the SQLBackup metric to track backup status.
resource "azurerm_monitor_metric_alert" "backup_failure" {
name = "BackupFailureAlert"
resource_group_name = "MyResourceGroup"
scopes = [azurerm_sql_managed_instance.my_instance.id]
criteria {
metric_namespace = "Microsoft.Sql/managedInstances"
metric_name = "BackupFailureCount"
aggregation = "Total"
operator = "GreaterThan"
threshold = 0
}
action {
action_group_id = azurerm_monitor_action_group.my_ag.id
}
}
FAQ
| Question | Answer |
|---|---|
| Can I disable automatic backups? | No, automatic backups are mandatory for managed instances. |
| Where are the backups stored? | In a storage account managed by Azure, encrypted with service‑level encryption. |
| How much does backup storage cost? | Backup storage is billed separately; details are in the Azure pricing page. |