将VM备份到现有的Recovery Service Vault

时间:2018-11-28 20:47:41

标签: json azure azure-pipelines arm-template azure-backup-vault

我能够部署VM,但是当我尝试使用备份保管库(位于不同资源组中)时,出现以下错误

“未找到资源组“ rg-hub-centralus”下的资源“ Microsoft.RecoveryServices / vaults / rsv-hub-centralus”。”

在Json模板中,这里是代码

        parameters:{
        "recoveryServiceVaultName" :{
              "type" :"string",
              "metadata": {
                "description": "Existing Recovery Service Vault Name in the Subscription"
              }
            },
        }


 "variables": {
       "backupFabric": "Azure",
"backupPolicyName": "RA-standard-daily-11pm-centralus",
"v2VmType": "Microsoft.Compute/virtualMachines",
"v2VmContainer": "iaasvmcontainer;iaasvmcontainerv2;",
"v2Vm": "vm;iaasvmcontainerv2;"
      },
"resources": [
    {
  "name": "[concat(parameters('recoveryServiceVaultName'), '/', variables('backupFabric'), '/', variables('v2VmContainer'), concat(resourcegroup().name,';',parameters('vmName')), '/', variables('v2Vm'), concat(resourcegroup().name,';',parameters('vmName')))]",
  "apiVersion": "2016-06-01",
  "location": "[parameters('location')]",
  "type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
  "properties": {
    "protectedItemType": "[variables('v2VmType')]",
    "policyId": "[resourceId(parameters('vaultResourceGroup'),'Microsoft.RecoveryServices/vaults/backupPolicies',parameters('recoveryServiceVaultName'),variables('backupPolicyName'))]",
    "sourceResourceId": "[resourceId(resourcegroup().name,'Microsoft.Compute/virtualMachines',parameters('vmName'))]"
  }
}
  ]

在Powershell中,我正在调用json文件

$recoveryServiceVault = Get-AzureRmRecoveryServicesVault -ResourceGroupName "rg-hubb-recoveryservice-centralus"

$recoveryServiceVaultName = $recoveryServiceVault.Name

# Assemble template parameters
$templateParameters = @{}
$templateParameters.Add("recoveryServiceVaultName", $recoveryServiceVaultName)


New-AzureRmResourceGroup -ResourceGroupName $resourceGroupName -Location $location -Force
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile "azuredeploy.json" -TemplateParameterObject $templateParameters

resourceGroup()。name在“ protectionContainer”和“ protectionItem”中-是VM还是RSV的资源组?

1 个答案:

答案 0 :(得分:0)

我认为,这是VM的资源组。看一下protectedItemId的template属性。所以我认为protectedItem是您要备份的VM。另外,还有一个有关备份的示例模板,请参见recovery services backup vm。以确切的资源类型命名的变量。