|
| 1 | +--- |
| 2 | +title: Manage automated backups for Azure Arc-enabled SQL Server from Azure portal |
| 3 | +description: Describes how to configure automated backups |
| 4 | +author: dnethi |
| 5 | +ms.author: dinethi |
| 6 | +ms.reviewer: mikeray, randolphwest |
| 7 | +ms.date: 11/14/2023 |
| 8 | +ms.topic: conceptual |
| 9 | +--- |
| 10 | + |
| 11 | +# Manage automated backups - Azure Arc-enabled SQL Server |
| 12 | + |
| 13 | +[!INCLUDE [sqlserver](../../includes/applies-to-version/sqlserver.md)] |
| 14 | + |
| 15 | +The Azure extension for [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] can perform backups automatically for the system and user databases that are part of the Azure Arc-enabled [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] instance. |
| 16 | + |
| 17 | +This article explains how you can: |
| 18 | + |
| 19 | +- Enable these built-in automated backups |
| 20 | +- Configure backup schedule |
| 21 | + |
| 22 | +[!INCLUDE [azure-arc-sql-preview](includes/azure-arc-sql-preview.md)] |
| 23 | + |
| 24 | +Automated backups are disabled by default. |
| 25 | + |
| 26 | +You can enable automated backups through Azure portal or via `az` CLI by setting the retention days property to a value between 1 and 35 days. |
| 27 | + |
| 28 | +### Supported license types |
| 29 | + |
| 30 | +Automated backups are only supported for license types of PAID or PAYG. |
| 31 | + |
| 32 | +## Backup frequency and retention days |
| 33 | + |
| 34 | +Two properties can be configured when you enable automated backups: |
| 35 | + |
| 36 | +- **retention days** - number of days to retain the backup files. Use a number between 1 and 35. |
| 37 | +- **backup schedule** - the schedule at which the full, differential and transaction log backups should be performed. Full backups can be configured to run on a daily or weekly basis. Differential backups can be configured to run either every 12 hours or every 24 hours. Transaction log backups can be configured to run in increments of 5 minutes. |
| 38 | + |
| 39 | +Backups can also be configured to run on a **default** schedule which is as follows: |
| 40 | + |
| 41 | +- Full backups: every 7 days |
| 42 | +- Differential backups: every 24 hours |
| 43 | +- Transaction log backups: every 15 minutes |
| 44 | + |
| 45 | +## Assign permissions |
| 46 | + |
| 47 | +The current backup service within the Azure extension for Arc-enabled Server uses `[NT AUTHORITY\SYSTEM]` account to perform the backups. As such, you need to grant the following permissions to this account. |
| 48 | + |
| 49 | + > [!NOTE] |
| 50 | + > This requirement applies to the preview release. |
| 51 | +
|
| 52 | +1. Add `[NT AUTHORITY\SYSTEM]` user account to the **dbcreator** server role at the server level. Run the following Transact-SQL to add this account: |
| 53 | + |
| 54 | + ```sql |
| 55 | + USE master; |
| 56 | + GO |
| 57 | + ALTER SERVER ROLE [dbcreator] ADD MEMBER [NT AUTHORITY\SYSTEM]; |
| 58 | + GO |
| 59 | + ``` |
| 60 | + |
| 61 | +1. Add `[NT AUTHORITY\SYSTEM]` user account to logins, and make it a member of `[db_backupoperator]` role in `master`, `model`, `msdb`, and each user database. |
| 62 | + |
| 63 | + For example: |
| 64 | + |
| 65 | + ```sql |
| 66 | + CREATE USER [NT AUTHORITY\SYSTEM] FOR LOGIN [NT AUTHORITY\SYSTEM]; |
| 67 | + GO |
| 68 | + ALTER ROLE [db_backupoperator] ADD MEMBER [NT AUTHORITY\SYSTEM]; |
| 69 | + GO |
| 70 | + ``` |
| 71 | + |
| 72 | +1. Run the preceding code for each user and system database (except `tempdb`). |
| 73 | + |
| 74 | +## Enable automated backups |
| 75 | + |
| 76 | +After you have assigned permissions, you can enable automated backups. |
| 77 | + |
| 78 | +### [Azure portal](#tab/azure) |
| 79 | + |
| 80 | +To enable automated backups in Azure portal: |
| 81 | + |
| 82 | +1. Browse to the Arc-enabled [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] for which you want to enable automated backups. |
| 83 | +1. Select **Backups**. |
| 84 | +1. Select on**Configure policies**. |
| 85 | +1. From the Configure policies options: |
| 86 | + - Set a value for backup retention days - between 1 and 35. |
| 87 | + - Set a schedule for the full, differential, and transactional log backups. |
| 88 | +1. Select **Apply** to enable this configuration. |
| 89 | + |
| 90 | +Once the automated backups are configured, the Arc SQL extension will initiate a backup of all the databases to the default backup location configured. |
| 91 | + |
| 92 | +Once the backups are enabled, a full back for each user database is initiated right away. The backups are native [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] backups which means all backup history is available in the backup related tables in the `msdb` database. |
| 93 | + |
| 94 | +### [Azure CLI](#tab/az) |
| 95 | + |
| 96 | +To enable automated backups using `az` CLI: |
| 97 | + |
| 98 | +1. Disable any existing backup routines. |
| 99 | +1. After you disable existing backup routines, run the following command(s): |
| 100 | + |
| 101 | + a. Enable the extension: |
| 102 | + |
| 103 | + ```azurecli |
| 104 | + --Install the arcdata extension if not already done |
| 105 | + az extension add --name arcdata |
| 106 | + ``` |
| 107 | + |
| 108 | + b. Configure either **default** schedule **or** a **custom** schedule |
| 109 | + |
| 110 | + ```azurecli |
| 111 | + -- default schedule |
| 112 | + az sql server-arc backups-policy set --name <arc-server-name> --resource-group <resourcegroup> --retention-days <retentiondays> |
| 113 | +
|
| 114 | + --Example: |
| 115 | + az sql server-arc backups-policy set --name MyArcServer-SQLServerPROD --resource-group my-rg --retention-days 24 |
| 116 | + |
| 117 | + --custom schedule |
| 118 | + az sql server-arc backups-policy set --name <arc-server-name> --resource-group <resourcegroup> --retention-days <retentiondays> --full-backup-days <num of days> --diff-backup-hours <12 or 24 hours> --tlog-backup-mins <num in minutes> |
| 119 | +
|
| 120 | + --Example: |
| 121 | + az sql server-arc backups-policy set --name MyArcServer-SQLServerPROD --resource-group my-rg --retention-days 24 --full-backup-days 7 --diff-backup-hours 24 --tlog-backup-mins 30 |
| 122 | + ``` |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## View current backup policy |
| 127 | + |
| 128 | +To view the current backup policy for a given Arc-enabled [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)], run the following command: |
| 129 | + |
| 130 | +```azurecli |
| 131 | +az sql server-arc backups-policy show --name <arc-server-name> --resource-group <resourcegroup> |
| 132 | +``` |
| 133 | + |
| 134 | +Example: |
| 135 | + |
| 136 | +```azurecli |
| 137 | +az sql server-arc backups-policy show --name MyArcServer-SQLServerPROD --resource-group my-rg |
| 138 | +``` |
| 139 | + |
| 140 | +Output: |
| 141 | + |
| 142 | +```json |
| 143 | +{ |
| 144 | + "DiffBackupHours": 24, |
| 145 | + "FullBackupDays": 7, |
| 146 | + "InstanceName": "SQLServerPROD", |
| 147 | + "RetentionPeriodInDays": 24, |
| 148 | + "TlogBackupMins": 5 |
| 149 | +} |
| 150 | +``` |
| 151 | + |
| 152 | +## Backup system databases |
| 153 | + |
| 154 | +When the built-in automated backups are enabled on an Arc-enabled [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)], the system databases are also backed up into the default backup location. Only full backups are performed for the system databases. |
| 155 | + |
| 156 | +## Considerations |
| 157 | + |
| 158 | +- The backup files are stored in the default backup location. |
| 159 | +- To find the default backup location for a [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] instance (on [!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] and later) run: |
| 160 | + |
| 161 | + ```sql |
| 162 | + SELECT SERVERPROPERTY('InstanceDefaultBackupPath'); |
| 163 | + ``` |
| 164 | + |
| 165 | +- For [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] versions below 2019, the default backup path is stored in a registry setting. Configure this setting with the extended stored procedure `xp_instance_regwrite` or from SQL Server Management Studio (SSMS). To use SSMS: |
| 166 | + |
| 167 | + 1. Connect to the Arc-enabled SQL Server from SSMS. |
| 168 | + 1. Go to **Server properties** > **Database Settings** > **Database default locations**. |
| 169 | + |
| 170 | +- The backups policy is configured at the instance level and applies to all the databases on the instance. |
| 171 | +- The value for `--name` should be the name of the Arc-enabled [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)], which is usually in the [Servername_SQLservername] format. |
| 172 | +- The value for `--retention-days` can be from 0-35. |
| 173 | +- A value of `0` for `--retention-days` indicates to not perform automated backups for the instance. |
| 174 | +- The backup files are written to the default backup location as configured at the instance level. |
| 175 | +- If there are multiple [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] instances on the same host where the Azure extension for [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] is installed, you need to turn on automated backups separately for each instance separately. |
| 176 | +- If you change the `--retention-days` after the `--backups-policy` is already configured, any change will take effect going forward and isn't retroactively applied. |
| 177 | + |
| 178 | +## Limitations |
| 179 | + |
| 180 | +- Automated backups are currently not supported for Always On failover cluster instances |
| 181 | +- The user databases need to be in full recovery model for the backups to be performed. Databases that aren't in full recovery model are not automatically backed up. |
| 182 | +- Automated backups are only supported on the primary replica of an Always On availability group. |
| 183 | +- Currently the backups can only be restored back to the same Arc-enabled [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] |
| 184 | +- Automated backups are only available for licenses with Software Assurance, SQL subscription, or pay-as-you-go. For details, see [Feature availability depending on license type](overview.md#feature-availability-depending-on-license-type). |
| 185 | + |
| 186 | +## Related tasks |
| 187 | + |
| 188 | +- [Restore to a point-in-time](point-in-time-restore.md) |
| 189 | +- [View SQL Server databases - Azure Arc](view-databases.md) |
| 190 | +- [Recovery Models (SQL Server)](../../relational-databases/backup-restore/recovery-models-sql-server.md) |
0 commit comments