0

I'm currently backing up Azure VMs via Azure CLI:

create resource group:

az group create -n backup-resource-group -l uksouth

create recovery services vault:

az backup vault create --resource-group backup-resource-group --name backup --location uksouth

loop VMs to create backup jobs:

az backup protection enable-for-vm --resource-group backup-resource-group --vault-name backup --vm $(az vm show -g servers-resource-group -n {{ loopedoutvm }} --query id | tr -d '"') --policy-name DefaultPolicy

This works fine, but only backs up VMs in the same Azure region. I'd like to adjust this to store the backups in a different region (in addition to the same region the VMs run in). If I run this again with a new resource group and vault created in a different region, Azure returns a message that recovery service vaults can only contain VMs from that location.

Which is strange, because in the Azure portal, it seems I can replicate VM backups to other regions (either via: some VM > disaster recovery > advanced, or via: some recovery services vault > replicate). But I don't know how to achieve this (or something similar) via Azure CLI in order to automate it. There doesn't seem to be anything in Microsoft's documentation for doing this with CLI.

If anyone could point me in the right direction it would be hugely appreciated.

Sam
  • 163
  • 1
  • 5

1 Answers1

1

As you mentioned, you can't attach a VM to a recovery vault in a different region. What you do is use a vault in the VM's region, then enable geo-redundancy on teh vault to replicate your backups to another region.

enter image description here

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113
  • Thanks, this is really helpful actually - pointed me to https://docs.microsoft.com/en-us/cli/azure/backup/vault/backup-properties?view=azure-cli-latest#az-backup-vault-backup-properties-set, which shows how to set via CLI - `az backup vault backup-properties set --backup-storage-redundancy GeoRedundant`. Though it actually seems to default to geo-redundant anyway, and I think the option I actually want is Cross Region Restore (below replication type option, but not shown in your screenshot). For that, there doesn't seem to be a CLI option unfortunately, or at least not yet been documented. – Sam Jun 30 '20 at 08:36