| title | Change automated backup settings | |||
|---|---|---|---|---|
| titleSuffix | Azure SQL Managed Instance | |||
| description | Change point-in-time restore and backup redundancy options for automatic backups in Azure SQL Managed Instance by using the Azure portal, the Azure CLI, Azure PowerShell, and the REST API. | |||
| author | dinethi | |||
| ms.author | dinethi | |||
| ms.reviewer | wiassaf, mathoma, strrodic, mlandzic | |||
| ms.date | 07/08/2025 | |||
| ms.service | azure-sql-managed-instance | |||
| ms.subservice | backup-restore | |||
| ms.topic | how-to | |||
| ms.custom |
|
|||
| monikerRange | = azuresql || = azuresql-mi |
[!INCLUDEappliesto-sqlmi]
[!div class="op_single_selector"]
This article provides examples to modify automated backup settings for Azure SQL Managed Instance, such as the short-term retention policy and the backup storage redundancy option that's used for backups. For Azure SQL Database, see Change automated backup settings for Azure SQL Database.
[!INCLUDE GDPR-related guidance]
You can change the default point-in-time recovery (PITR) backup retention period by using the Azure portal, PowerShell, or the REST API. The following examples illustrate how to change the PITR retention to 28 days.
Warning
If you reduce the current retention period, you lose the ability to restore to points in time older than the new retention period. Backups that are no longer needed to provide PITR within the new retention period are deleted.
If you increase the current retention period, you don't immediately gain the ability to restore to older points in time within the new retention period. You gain that ability over time, as the system starts to retain backups for longer periods.
Note
These APIs will affect only the PITR retention period. If you configured long-term retention (LTR) for your database, it won't be affected. For information about how to change long-term retention periods, see Long-term retention.
To change the PITR backup retention period for active databases by using the Azure portal:
- Go to the managed instance with the databases whose retention period you want to change.
- Select Backups on the left pane, and then select the Retention policies tab.
- Select the databases for which you want to change the PITR backup retention.
- Select Configure policies from the action bar.
:::image type="content" source="../database/media/automated-backups-overview/configure-backup-retention-sqlmi.png" alt-text="Screenshot of the Azure portal backup settings to change PITR retention for the managed instance.":::
Prepare your environment for the Azure CLI:
[!INCLUDEazure-cli-prepare-your-environment-no-header]
Use the following example to change the PITR backup retention of a single active database in a managed instance:
# Set a new PITR backup retention period on an active individual database
# Valid backup retention must be 1 to 35 days
az sql midb short-term-retention-policy set \
--resource-group myresourcegroup \
--managed-instance myinstance \
--name mymanageddb \
--retention-days 1 \
Use the following example to change the PITR backup retention for all active databases in a managed instance:
# Set a new PITR backup retention period for all active databases
# Valid backup retention must be 1 to 35 days
az sql midb short-term-retention-policy set \
--resource-group myresourcegroup \
--managed-instance myinstance \
--retention-days 1 \
For more information, see the Backup retention Azure CLI command.
To change the PITR backup retention for a single active database in a managed instance, use the following PowerShell example:
# Set a new PITR backup retention period on an active individual database
# Valid backup retention must be 1 to 35 days
Set-AzSqlInstanceDatabaseBackupShortTermRetentionPolicy -ResourceGroupName resourceGroup -InstanceName testserver -DatabaseName testDatabase -RetentionDays 1To change the PITR backup retention for all active databases in a managed instance, use the following PowerShell example:
# Set a new PITR backup retention period for all active databases
# Valid backup retention must be 1 to 35 days
Get-AzSqlInstanceDatabase -ResourceGroupName resourceGroup -InstanceName testserver | Set-AzSqlInstanceDatabaseBackupShortTermRetentionPolicy -RetentionDays 1To change the PITR backup retention for a single deleted database in a managed instance, use the following PowerShell example:
# Set a new PITR backup retention on an individual deleted database
# Valid backup retention must be 0 (no retention) to 35 days. Valid retention rate can only be lower than the retention period when database was active, or the remaining backup days of a deleted database.
Get-AzSqlDeletedInstanceDatabaseBackup -ResourceGroupName resourceGroup -InstanceName testserver -DatabaseName testDatabase | Set-AzSqlInstanceDatabaseBackupShortTermRetentionPolicy -RetentionDays 0To change the PITR backup retention for all deleted databases in a managed instance, use the following PowerShell example:
# Set a new PITR backup retention for all deleted databases
# Valid backup retention must be 0 (no retention) to 35 days. Valid retention rate can only be lower than the retention period when database was active, or the remaining backup days of a deleted database
Get-AzSqlDeletedInstanceDatabaseBackup -ResourceGroupName resourceGroup -InstanceName testserver | Set-AzSqlInstanceDatabaseBackupShortTermRetentionPolicy -RetentionDays 0Zero days of retention would denote that a backup is immediately deleted and no longer kept for a deleted database. After you reduce PITR backup retention for a deleted database, you can no longer increase it.
For more information, see the Backup retention PowerShell command.
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/resourceGroup/providers/Microsoft.Sql/managedInstances/testManagedInstance/databases/testDatabase/backupShortTermRetentionPolicies/default?api-version=2017-10-01-preview{
"properties":{
"retentionDays":28
}
}Status code: 200
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Sql/resourceGroups/resourceGroup/managedInstances/testserver/databases/testDatabase/backupShortTermRetentionPolicies/default",
"name": "default",
"type": "Microsoft.Sql/resourceGroups/managedInstances/databases/backupShortTermRetentionPolicies",
"properties": {
"retentionDays": 28
}
}For more information, see the Backup retention REST API.
Configure backup storage redundancy for SQL Managed Instance by using the Azure portal, the Azure CLI, and Azure PowerShell.
In the Azure portal, during instance creation, the default option for the backup storage redundancy is geo-redundancy. To change it:
-
Go to the Basics tab and select Configure Managed Instance.
:::image type="content" source="../database/media/automated-backups-overview/open-configuration-blade-managed-instance.png" alt-text="Screenshot of the pane for configuring backup storage redundancy in the Azure portal for a managed instance.":::
-
On the Compute + storage pane, select the option for the type of backup storage redundancy that you want.
:::image type="content" source="../database/media/automated-backups-overview/select-backup-storage-redundancy-managed-instance.png" alt-text="Screenshot of selecting backup storage redundancy in the Azure portal for a managed instance.":::
-
Select Apply. For now, this change will be applied only for PITR backups. Long-term retention backups will retain the old storage redundancy type.
The time it takes to perform the backup redundancy change depends on the size of the all the databases within a single managed instance. Changing the backup redundancy will take more time for instances that have large databases. It's possible to combine the backup storage redundancy change with the operation to update the service-level objective (SLO).
Use the Notification pane of the Azure portal to view the status of the change operation.
:::image type="content" source="../database/media/automated-backups-overview/change-backup-storage-redundancy-managed-instance-notification.png" alt-text="Screenshot of the status of ongoing operations in the Azure portal.":::
To change the backup storage redundancy after you create a managed instance by using the Azure CLI, specify the -BackupStorageRedundancy parameter with the az sql mi update cmdlet. View the update mi backup storage redundancy example.
Possible values for -BackupStorageRedundancy are Geo for geo-redundant, Zone for zone-redundant, Local for locally redundant, and GeoZone for geo-zone redundant backup storage.
To configure backup storage redundancy when you create a managed instance, specify the -BackupStorageRedundancy parameter with the New-AzSqlInstance cmdlet. To change the backup storage redundancy for an existing managed instance, specify the -BackupStorageRedundancy parameter with the Set-AzSqlInstance cmdlet. To learn more, review the Update an existing instance to be zone-redundant example.
Possible values for -BackupStorageRedundancy are Geo for geo-redundant, Zone for zone-redundant, Local for locally redundant, and GeoZone for geo-zone redundant backup storage.
It's not currently possible to change the backup storage redundancy option by using the REST API.
- Database backups are an essential part of any business continuity and disaster recovery strategy because they help protect your data from accidental corruption or deletion. To learn about the other business continuity solutions for SQL Managed Instance, see Business continuity overview.
- For information about how to configure, manage, and restore from long-term retention of automated backups in Azure Blob Storage by using the Azure portal, see Manage long-term backup retention by using the Azure portal.
- For information about how to configure, manage, and restore from long-term retention of automated backups in Azure Blob Storage by using PowerShell, see Manage long-term backup retention by using PowerShell.
- Get more information about how to restore a database to a point in time by using the Azure portal.
- To learn all about backup storage consumption on Azure SQL Managed Instance, see Backup storage consumption on Managed Instance explained.
- To learn how to fine-tune backup storage retention and costs for Azure SQL Managed Instance, see Fine tuning backup storage costs on SQL Managed Instance.