Change automated backup settings for Azure SQL Managed Instance

Applies to: Azure SQL Managed Instance

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.

Note

This article provides steps about how to delete personal data from the device or service and can be used to support your obligations under the GDPR. For general information about GDPR, see the GDPR section of the Microsoft Trust Center and the GDPR section of the Service Trust portal.

Change short-term retention policy

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 for a single active database in a managed instance, use the following PowerShell example:

PowerShell
# 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 1

To change the PITR backup retention for all active databases in a managed instance, use the following PowerShell example:

PowerShell
# 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 1

To change the PITR backup retention for a single deleted database in a managed instance, use the following PowerShell example:

PowerShell
# 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 0

To change the PITR backup retention for all deleted databases in a managed instance, use the following PowerShell example:

PowerShell
# 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 0

Zero 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.

Configure backup storage redundancy

Configure backup storage redundancy for SQL Managed Instance by using the Azure portal, the Azure CLI, and Azure PowerShell.

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.

Next steps