|
| 1 | +--- |
| 2 | +title: Azure Quickstart - Back up a VM with Resource Manager template |
| 3 | +description: Learn how to back up your virtual machines with Azure Resource Manager template |
| 4 | +services: backup |
| 5 | +author: rayne-wiselman |
| 6 | +manager: carmonm |
| 7 | +ms.service: backup |
| 8 | +ms.devlang: azurecli |
| 9 | +ms.topic: quickstart |
| 10 | +ms.date: 05/14/2019 |
| 11 | +ms.author: raynew |
| 12 | +ms.custom: mvc |
| 13 | +--- |
| 14 | + |
| 15 | +# Back up a virtual machine in Azure with Resource Manager template |
| 16 | + |
| 17 | +[Azure Backup](backup-overview.md) backs up on-premises machines and apps, and Azure VMs. This article shows you how to back up an Azure VM with Resource Manager template and Azure PowerShell. This quickstart focuses on the process of deploying a Resource Manager template to create a Recover Services vault. For more information on developing Resource Manager templates, see [Resource Manager documentation](/azure/azure-resource-manager/) and the [template reference](/azure/templates/microsoft.recoveryservices/allversions). |
| 18 | + |
| 19 | +Alternatively, you can back up a VM using [Azure PowerShell](./quick-backup-vm-powershell.md), the [Azure CLI](quick-backup-vm-cli.md), or in the [Azure portal](quick-backup-vm-portal.md). |
| 20 | + |
| 21 | +## Create a VM and Recovery Services vault |
| 22 | + |
| 23 | +A [Recovery Services vault](backup-azure-recovery-services-vault-overview.md) is a logical container that stores backup data for protected resources, such as Azure VMs. When a backup job runs, it creates a recovery point inside the Recovery Services vault. You can then use one of these recovery points to restore data to a given point in time. |
| 24 | + |
| 25 | +The template used in this quickstart is from [Azure quickstart templates](https://azure.microsoft.com/resources/templates/101-recovery-services-create-vm-and-configure-backup/). This template allows you to deploy simple Windows VM and Recovery Services Vault configured with the DefaultPolicy for Protection. |
| 26 | + |
| 27 | +To deploy the template, select **Try it** to open the Azure Cloud shell, and then paste the following PowerShell script into the shell window. To paste the code, right-click the shell window and then select **Paste**. |
| 28 | + |
| 29 | +```azurepowershell-interactive |
| 30 | +$projectName = Read-Host -Prompt "Enter a project name (limited to eight characters) that is used to generate Azure resource names" |
| 31 | +$location = Read-Host -Prompt "Enter the location (i.e. centralus)" |
| 32 | +$adminUsername = Read-Host -Prompt "Enter the administrator username for the virtual machine" |
| 33 | +$adminPassword = Read-Host -Prompt "Enter the administrator password for the virtual machine" -AsSecureString |
| 34 | +$dnsPrefix = Read-Host -Prompt "Enter the unique DNS Name for the Public IP used to access the virtual machine" |
| 35 | +
|
| 36 | +$resourceGroupName = "${projectName}rg" |
| 37 | +$templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-recovery-services-create-vm-and-configure-backup/azuredeploy.json" |
| 38 | +
|
| 39 | +New-AzResourceGroup -Name $resourceGroupName -Location $location |
| 40 | +New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -projectName $projectName -adminUsername $adminUsername -adminPassword $adminPassword -dnsLabelPrefix $dnsPrefix |
| 41 | +``` |
| 42 | + |
| 43 | +Azure PowerShell is used to deploy the Resource Manager template in this quickstart. The [Azure portal](../azure-resource-manager/resource-group-template-deploy-portal.md), [Azure CLI](../azure-resource-manager/resource-group-template-deploy-cli.md), and [Rest API](../azure-resource-manager/resource-group-template-deploy-rest.md) can also be used to deploy templates. |
| 44 | + |
| 45 | +## Start a backup job |
| 46 | + |
| 47 | +The template creates a VM and enables back on the VM. After you deploy the template, you need to start a backup job. For more information, see [Start a backup job](./quick-backup-vm-powershell.md#start-a-backup-job). |
| 48 | + |
| 49 | +## Monitor the backup job |
| 50 | + |
| 51 | +To monitor the backup job, see [Monitor the backup job](./quick-backup-vm-powershell.md#monitor-the-backup-job). |
| 52 | + |
| 53 | +## Clean up the deployment |
| 54 | + |
| 55 | +If you no longer need to back up the VM, you can clean it up. |
| 56 | + |
| 57 | +- If you want to try out restoring the VM, skip the clean up. |
| 58 | +- If you used an existing VM, you can skip the final [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) cmdlet to leave the resource group and VM in place. |
| 59 | + |
| 60 | +Disable protection, remove the restore points and vault. Then delete the resource group and associated VM resources, as follows: |
| 61 | + |
| 62 | +```powershell |
| 63 | +Disable-AzRecoveryServicesBackupProtection -Item $item -RemoveRecoveryPoints |
| 64 | +$vault = Get-AzRecoveryServicesVault -Name "myRecoveryServicesVault" |
| 65 | +Remove-AzRecoveryServicesVault -Vault $vault |
| 66 | +Remove-AzResourceGroup -Name "myResourceGroup" |
| 67 | +``` |
| 68 | + |
| 69 | +## Next steps |
| 70 | + |
| 71 | +In this quickstart, you created a Recovery Services vault, enabled protection on a VM, and created the initial recovery point. |
| 72 | + |
| 73 | +- [Learn how](tutorial-backup-vm-at-scale.md) to back up VMs in the Azure portal. |
| 74 | +- [Learn how](tutorial-restore-disk.md) to quickly restore a VM |
0 commit comments