Back up a virtual machine in Azure with PowerShell
სტატია
The Azure PowerShell AZ module is used to create and manage Azure resources from the command line or in scripts.
Azure Backup backs up on-premises machines and apps, and Azure VMs. This article shows you how to back up an Azure VM with the AZ module. Alternatively, you can back up a VM using the Azure CLI, or in the Azure portal.
This quickstart requires the Azure PowerShell AZ module version 1.0.0 or later. Run Get-Module -ListAvailable Az to find the version. If you need to install or upgrade, see Install Azure PowerShell module.
Sign in to your Azure subscription with the Connect-AzAccount command and follow the on-screen directions.
PowerShell
Connect-AzAccount
The first time you use Azure Backup, you must register the Azure Recovery Service provider in your subscription with Register-AzResourceProvider, as follows:
A Recovery Services vault 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.
When you create the vault:
For the resource group and location, specify the resource group and location of the VM you want to back up.
If you used this sample script to create the VM, the resource group is myResourceGroup, the VM is *myVM, and the resources are in the WestEurope region.
Azure Backup automatically handles storage for backed up data. By default the vault uses Geo-Redundant Storage (GRS). Geo-redundancy ensures that backed up data is replicated to a secondary Azure region, hundreds of miles away from the primary region.
Storage Redundancy can be modified only if there are no backup items protected to the vault.
Enable backup for an Azure VM
You enable backup for an Azure VM, and specify a backup policy.
The policy defines when backups run, and how long recovery points created by the backups should be retained.
The default protection policy runs a backup once a day for the VM, and retains the created recovery points for 30 days. You can use this default policy to quickly protect your VM.