Using PowerShell with Veeam Backup – Restore to Azure

Using PowerShell with Veeam Backup – Restore to Azure

In my recent post about Veeam Backup – Restore to Azure  I show how to do it GUI way. Veeam Backup include PowerShell PSSnapIn we can use it to manage many aspects of Veeam including Microsoft Azure integration. Today post is about that.

To get started we need open Windows PowerShell, we can open it from a computer where Veeam Backup and Replication console is installed, as shown on below picture. That will load PSSnipin automatically or if we have already open PowerShell console we can run Add-PSSnapin VeeamPSSnapIn.

0 - opening ps

Opening Windows PowerShell from Veeam Console

Next step will be to get connected to Veeam Backup server.

1 - con to svr

Connecting to Veeam server

Running Get-Command *Azure* -PSSnapin VeeamPSSnapin reveal all commands we can use to work with Microsoft Azure account

2 ps commands

PowerShell commands to work with Azure

Our first command to run will be Add-VBRAzureAccount if the computer has not installed Microsoft Azure PowerShell module. We can find installation file at this location C:/Program Files/Veeam/Backup and Replication/Console/azure-PowerShell.3.1.0.msi 
I have encounter error when PowerShell Azure module is a different version than provided with Veeam. Running Add-VBRAzureAccount finish with an error even though the account can be seen as added.

Running Add-VBRAzureAccount command will open Sign in to your account window where we need to tape email and password to get connected when finish we can see information about Azure account.

3 - error no ps installed

Missing Azure PowerShell module error

5 - adding account

Sign in to Azure account

6 - added account

Account added successfully

We can use Veeam PowerShell command to retrieve information about Azure subscription, location, VM size, resources group etc. This post is about restoring to Azure we will need most of them. The command which we want to use is Start-VBRVMRestoreToAzure 

7- start command

Start-VBRVMRestoreToAzure command parameters

We start with finding information about Veeam Backup job and restore points. My lab contain only single restore point for the backup, in case we do have more than one we need to select this one which we want to use. $restore is array we can use $restore[0] for example to retrieve first restore point on the list.

8 - getbackup

Backup and restore points

Next, we need an Azure account and subscription information. Again I will be creating $subscription variable for future use.

9 -account and sub

Azure account and subscription information

When we have subscription information, we can proceed to retrieve Storage Account information and location where we want to restore our VM

10 - location storage

Azure storage account and location

We need VM size as well. Azure provides different VM sizes, number of CPU, memory size and disk size. Is good to choose correct one, as this can affect how much we will be paying to run restore VM in Azure

11 -vm size

Restore VM size

Last information we require is Network name and subnet.

Network and subnet information

All necessary information collected and stored in variables, we can proceed with restoring our VM from backup. As mention before we will use command Start-VBRVMRestoreToAzure with parameters -RestorePoint -Subscription -StorageAccount -VMSize -NewResourcesGroup -VirtualNetwork -VirtualSubnet -VMName -Reason. Pressing Enter will start the job and display information about it. We can see that the “Results” is in Starting state.

Starting to restore VM from PowerShell

Depending on network and VM size it can take a while before the restore will complete. In my lab, it just below 25 minutes. After login to Azure console, I could see new VM under new resource group in running state.

Succesful restore

 

Thank you for reading.

 

Advertisements