在 Azure VM 中运行的 SQL Server 的 Azure 备份Azure Backup for SQL Server running in Azure VM

除了其他产品/服务,Azure 备份还提供在 Azure VM 中运行的 SQL Server 等工作负荷的备份支持。Azure Backup, amongst other offerings, provides support for backing up workloads such as SQL Server running in Azure VMs. 由于 SQL 应用程序在 Azure VM 中运行,因此备份服务需要有权访问该应用程序并提取必需的详细信息。Since the SQL application is running within an Azure VM, the backup service needs permission to access the application and fetch the necessary details. 为此,Azure 备份会在用户触发的注册过程中在 SQL Server 运行时所在的 VM 上安装 AzureBackupWindowsWorkload 扩展。To do that, Azure Backup installs the AzureBackupWindowsWorkload extension on the VM, in which the SQL Server is running, during the registration process triggered by the user.

必备条件Prerequisites

有关支持的方案的列表,请参阅 Azure 备份支持的可支持性矩阵For the list of supported scenarios, refer to the supportability matrix supported by Azure Backup.

网络连接Network connectivity

Azure 备份支持 NSG 标记,可以部署代理服务器或列出的 IP 范围;有关每种方法的详细信息,请参阅此文章Azure Backup supports NSG Tags, deploying a proxy server or listed IP ranges; for details on each of the methods, refer this article.

扩展架构Extension schema

扩展架构和属性值是服务传递给 CRP API 的配置值(运行时设置)。The extension schema and property values are the configuration values (runtime settings) that service is passing to CRP API. 这些配置值在注册和升级过程中使用。These config values are used during registration and upgrade. AzureBackupWindowsWorkload 扩展也使用此架构。AzureBackupWindowsWorkload extension also uses this schema. 此架构已预设置;可以在 objectStr 字段中添加新参数The schema is pre-set; a new parameter can be added in the objectStr field

"runtimeSettings": [{
    "handlerSettings": {
        "protectedSettingsCertThumbprint": "",
        "protectedSettings": {
            "objectStr": "",
            "logsBlobUri": "",
            "statusBlobUri": ""
        }
    },
    "publicSettings": {
        "locale": "en-us",
        "taskId": "1c0ae461-9d3b-418c-a505-bb31dfe2095d",
        "objectStr": "",
        "commandStartTimeUTCTicks": "636295005824665976",
        "vmType": "vmType"
    }
}]

以下 JSON 显示 WorkloadBackup 扩展的架构。The following JSON shows the schema for the WorkloadBackup extension.

{
  "type": "extensions",
  "name": "WorkloadBackup",
  "location":"<myLocation>",
  "properties": {
    "publisher": "Microsoft.RecoveryServices",
    "type": "AzureBackupWindowsWorkload",
    "typeHandlerVersion": "1.1",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "locale":"<location>",
      "taskId":"<TaskId used by Azure Backup service to communicate with extension>",

      "objectStr": "<The configuration passed by Azure Backup service to extension>",

      "commandStartTimeUTCTicks": "<Scheduled start time of registration or upgrade task>",
      "vmType": "<Type of VM where registration got triggered Eg. Compute or ClassicCompute>"
    },
    "protectedSettings": {
      "objectStr": "<The sensitive configuration passed by Azure Backup service to extension>",
      "logsBlobUri": "<blob uri where logs of command execution by extension are written to>",
      "statusBlobUri": "<blob uri where status of the command executed by extension is written>"
    }
  }
}

属性值Property values

名称Name 值/示例Value/example 数据类型Data type
区域设置locale zh-cnen-us 字符串string
taskIdtaskId "1c0ae461-9d3b-418c-a505-bb31dfe2095d""1c0ae461-9d3b-418c-a505-bb31dfe2095d" 字符串string
objectStrobjectStr
(publicSettings)(publicSettings)
"eyJjb250YWluZXJQcm9wZXJ0aWVzIjp7IkNvbnRhaW5lcklEIjoiMzVjMjQxYTItOGRjNy00ZGE5LWI4NTMtMjdjYTJhNDZlM2ZkIiwiSWRNZ210Q29udGFpbmVySWQiOjM0NTY3ODg5LCJSZXNvdXJjZUlkIjoiMDU5NWIwOGEtYzI4Zi00ZmFlLWE5ODItOTkwOWMyMGVjNjVhIiwiU3Vic2NyaXB0aW9uSWQiOiJkNGEzOTliNy1iYjAyLTQ2MWMtODdmYS1jNTM5ODI3ZTgzNTQiLCJVbmlxdWVDb250YWluZXJOYW1lIjoiODM4MDZjODUtNTQ4OS00NmNhLWEyZTctNWMzNzNhYjg3OTcyIn0sInN0YW1wTGlzdCI6W3siU2VydmljZU5hbWUiOjUsIlNlcnZpY2VTdGFtcFVybCI6Imh0dHA6XC9cL015V0xGYWJTdmMuY29tIn1dfQ==""eyJjb250YWluZXJQcm9wZXJ0aWVzIjp7IkNvbnRhaW5lcklEIjoiMzVjMjQxYTItOGRjNy00ZGE5LWI4NTMtMjdjYTJhNDZlM2ZkIiwiSWRNZ210Q29udGFpbmVySWQiOjM0NTY3ODg5LCJSZXNvdXJjZUlkIjoiMDU5NWIwOGEtYzI4Zi00ZmFlLWE5ODItOTkwOWMyMGVjNjVhIiwiU3Vic2NyaXB0aW9uSWQiOiJkNGEzOTliNy1iYjAyLTQ2MWMtODdmYS1jNTM5ODI3ZTgzNTQiLCJVbmlxdWVDb250YWluZXJOYW1lIjoiODM4MDZjODUtNTQ4OS00NmNhLWEyZTctNWMzNzNhYjg3OTcyIn0sInN0YW1wTGlzdCI6W3siU2VydmljZU5hbWUiOjUsIlNlcnZpY2VTdGFtcFVybCI6Imh0dHA6XC9cL015V0xGYWJTdmMuY29tIn1dfQ==" 字符串string
commandStartTimeUTCTickscommandStartTimeUTCTicks "636967192566036845""636967192566036845" 字符串string
vmTypevmType "microsoft.compute/virtualmachines""microsoft.compute/virtualmachines" 字符串string
objectStrobjectStr
(protectedSettings)(protectedSettings)
"eyJjb250YWluZXJQcm9wZXJ0aWVzIjp7IkNvbnRhaW5lcklEIjoiMzVjMjQxYTItOGRjNy00ZGE5LWI4NTMtMjdjYTJhNDZlM2ZkIiwiSWRNZ210Q29udGFpbmVySWQiOjM0NTY3ODg5LCJSZXNvdXJjZUlkIjoiMDU5NWIwOGEtYzI4Zi00ZmFlLWE5ODItOTkwOWMyMGVjNjVhIiwiU3Vic2NyaXB0aW9uSWQiOiJkNGEzOTliNy1iYjAyLTQ2MWMtODdmYS1jNTM5ODI3ZTgzNTQiLCJVbmlxdWVDb250YWluZXJOYW1lIjoiODM4MDZjODUtNTQ4OS00NmNhLWEyZTctNWMzNzNhYjg3OTcyIn0sInN0YW1wTGlzdCI6W3siU2VydmljZU5hbWUiOjUsIlNlcnZpY2VTdGFtcFVybCI6Imh0dHA6XC9cL015V0xGYWJTdmMuY29tIn1dfQ==""eyJjb250YWluZXJQcm9wZXJ0aWVzIjp7IkNvbnRhaW5lcklEIjoiMzVjMjQxYTItOGRjNy00ZGE5LWI4NTMtMjdjYTJhNDZlM2ZkIiwiSWRNZ210Q29udGFpbmVySWQiOjM0NTY3ODg5LCJSZXNvdXJjZUlkIjoiMDU5NWIwOGEtYzI4Zi00ZmFlLWE5ODItOTkwOWMyMGVjNjVhIiwiU3Vic2NyaXB0aW9uSWQiOiJkNGEzOTliNy1iYjAyLTQ2MWMtODdmYS1jNTM5ODI3ZTgzNTQiLCJVbmlxdWVDb250YWluZXJOYW1lIjoiODM4MDZjODUtNTQ4OS00NmNhLWEyZTctNWMzNzNhYjg3OTcyIn0sInN0YW1wTGlzdCI6W3siU2VydmljZU5hbWUiOjUsIlNlcnZpY2VTdGFtcFVybCI6Imh0dHA6XC9cL015V0xGYWJTdmMuY29tIn1dfQ==" 字符串string
logsBlobUrilogsBlobUri https://seapod01coord1exsapk732.blob.core.chinacloudapi.cn/bcdrextensionlogs-d45d8a1c-281e-4bc8-9d30-3b25176f68ea/sopattna-vmubuntu1404ltsc.v2.Logs.txt?sv=2014-02-14&sr=b&sig=DbwYhwfeAC5YJzISgxoKk%2FEWQq2AO1vS1E0rDW%2FlsBw%3D&st=2017-11-09T14%3A33%3A29Z&se=2017-11-09T17%3A38%3A29Z&sp=rw 字符串string
statusBlobUristatusBlobUri https://seapod01coord1exsapk732.blob.core.chinacloudapi.cn/bcdrextensionlogs-d45d8a1c-281e-4bc8-9d30-3b25176f68ea/sopattna-vmubuntu1404ltsc.v2.Status.txt?sv=2014-02-14&sr=b&sig=96RZBpTKCjmV7QFeXm5IduB%2FILktwGbLwbWg6Ih96Ao%3D&st=2017-11-09T14%3A33%3A29Z&se=2017-11-09T17%3A38%3A29Z&sp=rw 字符串string

模板部署Template deployment

建议在虚拟机上启用 SQL Server 备份,通过这种方式将 AzureBackupWindowsWorkload 扩展添加到虚拟机。We recommended adding AzureBackupWindowsWorkload extension to a virtual machine is by enabling SQL Server backup on the virtual machine. 可以通过设计用于在 SQL Server VM 上自动进行备份的资源管理器模板来实现此操作。This can be achieved through the Resource Manager template designed for automating backup on a SQL Server VM.

PowerShell 部署PowerShell deployment

需要将包含 SQL 应用程序的 Azure VM“注册”到恢复服务保管库。You need to 'register' the Azure VM that contains the SQL application with a Recovery services vault. 在注册期间,AzureBackupWindowsWorkload 扩展会安装到 VM 上。During registration, AzureBackupWindowsWorkload extension gets installed on the VM. 请使用  Register-AzRecoveryServicesBackupContainerPS cmdlet 注册 VM。Use Register-AzRecoveryServicesBackupContainerPS cmdlet to register the VM.

$myVM = Get-AzVM -ResourceGroupName <VMRG Name> -Name <VMName>
Register-AzRecoveryServicesBackupContainer -ResourceId $myVM.ID -BackupManagementType AzureWorkload -WorkloadType MSSQL -VaultId $targetVault.ID -Force

此命令会返回此资源的“备份容器”,状态将为“已注册”。 The command will return a backup container of this resource and the status will be registered.

后续步骤Next steps

  • 详细了解 Azure SQL Server 备份故障排除准则。Learn More about Azure SQL Server VM backup troubleshooting guidelines
  • 有关如何备份在 Azure 虚拟机 (VM) 上运行并使用 Azure 备份服务的 SQL Server 数据库的常见问题Common questions about backing up SQL Server databases that run on Azure virtual machines (VMs) and that use the Azure Backup service.