Skip to main content

Veeam V10 Direct Restore Multiple VMs Into Azure- Part 2 PowerShell


Restoring Multiple VMs to Azure: Part 2 PowerShell

Hopefully you have read Part 1 of my Azure Multiple VM restores though Veeam GUI.
This is a continuation of that post where i share how to achieve the same process but using only PowerShell.

I built this script off a base script on this Blog post from a Colleague. Michael Cade is a Global Technologist for Veeam Software. Here is a Link to Michael's  Blog & Here is the Original Post.

Prerequisites are the same as Part 1 so please follow the same.

To execute the Script, you need to Add VeeamPSSnapin & connect to the backup server holding the required backups.
Add -Server “Name of your Veeam Backup Server” mine in this case was “veeam”
Next we need to set the required Variables, like the Backups we want to use, the restore point, the Azure account & subscription, the network , storage & VM size we will use during the restore.
I’ve made Duplicate lines of Variables for each backup point that I will call during the restore.
$Restorepoint (I will call this variable during restore, Veeam needs to know what VM & what recovery point it must use) You will see I’ve created multiple $restorepointNC , $restorepointACS…

To give these Variables value I use Get-VBRBackup -Name "Azurestack Infrastructure" , This is the name of my backup Job ( you might have seen this in a screenshot in Part 1 ) The next part is to select a Object or backed up VM within this job to use Get-VBRRestorePoint -Name "AzS-NC01"

So $restorepointNC  is assigned to "Azurestack Infrastructure" Backup job & VM within that Job "AzS-NC01" , There are multiple Restore points for this VM so we need to allocate one.

Sort-Object $_.creationtime -Descending | Select -First 1 
I sort all the Restore points for "AzS-NC01" by Creation date in a descending order & select the first one.
Like you see in the embedded script you do this for each server you want to restore simultaneously.
Now we need to configure the Azure Setting (note this should have already been added though VBR GUI) This is a once off task as we will use the same setting for each restore session to azure.

Variable is $Account ,  I used $AccountCloud nothing special.
We need to assign your azure account details to the $AccountCloud variable, where -Name is your Username for you Azure portal login.

Next you need to assign you subscription under your -Name to $subscription Variable , this is the first time you reference the variable $AccountCloud , -Name is your Subscription display name.

The Rest are straight forward:
$storageaccount Assign storage profile using $subscription variable -Name (add ur own)
$location Assign Location profile using $subscription variable -Name (add ur own)
$network Assign network profile using $subscription variable -Name (add ur own)
$subnet Leave Default
$resourcegroup Assign Resource using $subscription variable -Name (add ur own)

Next variable I wanted to separate because it’s a variable with variations, I want to restore 13VMs at once, but they need to be different VM sizes in Azure.
I wanted to use a mixture of the Standard A2, A4 & A8
I created Variables, Small, medium & Large … $vmsizeSMALL … I will call these variables during the restore to tell Veeam & Azure what size VM I want the restore to have.

Now that we are done with the Variables, we can start building the Restore Script, the restore script will pull already saved settings in each variable and use them to guide the restore silently.
At this point you should be able to see the reference patterns.

Start the restore to Azure from Veeam      Start-VBRVMRestoreToAzure
Select the restore point already defined    -RestorePoint $restorepointNC
Select the Azure Account & Plan already defined     -Subscription $subscription
Select the Storage profile already defined     -StorageAccount $storageaccount
Select 1 of 3 VM sizes already defined       -VmSize $vmsizeSMALL
Select Network Vlan already defined       -VirtualNetwork $network
Select Network Subnet Left Default       -VirtualSubnet $subnet
Select resource group Already defined        -ResourceGroup $resourcegroup
Give the restored VM a Name that will register and display in azure     -VmName Azs-NC01-Azure
Give a Reason for the Restore         -Reason "TESTING MY NEW SCRIPT"




Here is a Link to download the Full script and make the changes you need Here :
LINK

Thank you for Reading this post , please comment , follow & Share .

Comments