Skip to main content

VRO Restore into AWS custom script


skitch210
Forum|alt.badge.img+1

So, I wrote this script a while ago (supported on Veeam version 11 ), before there was a Veeam Community Hub to write about it. After seeing a few forums posts, I decided to revisit the script, make sure it still works as expected, make a few minor adjustments, and to do a writeup on how to set it up and use it.

 

We can start by looking at the readme file in GitHub, 

https://github.com/VeeamHub/veeam-orchestrator/tree/main/RecoverToAWS

 

As this states, be aware of the AWS Hardware compatibility compared to the VMs that you want to restore to avoid conflicts. Pay attention to the known issues and the requirements listed.

 

Obviously, an AWS account and setup is necessary. I recommend going through the Restore to AWS feature in the Veeam console on the Veeam Backup Server. This will help you understand the information that is needed inside the script for the recovery to work.

 

The script is setup to use a CSV file that has the AWS account information in it and imports these as variables throughout. There are other ways to accomplish this, but for ease of use, this is the way I set it up. Consider this script as a template on how to do this and not as a production quality script.

 

Let’s go through the script at a high level and then look at how to set it up in VRO. Something I have added to scripts for VRO is the Write-Host lines. This is for reporting purposes inside VRO so that VRO will show the status of the script for DR audit reporting and for troubleshooting.

 

First line in the script is a param variable that accepts the name of the VM from VRO. We will discuss this later when we add the script to VRO.

 

The script imports the csv file for the login information and other settings we need to perform the restore. This is the access key, secret key, and region you would like to restore into.

 

To have a faster recovery, you should have a backup copy job to send backups into an AWS S3 bucket. The script retrieves this backup copy job and uses this to find the latest restore point on that repository to use for the recovery.

 

It then uses the metadata inside the backup file to get the CPU and ram of the VM. This will be used to match the machine size in AWS.

 

The script is hard coded to select a T class instance in AWS. Change this for your needs.

 

Then it gets the VM disks that are in the backup file, will loop through if more than 1 disk

 

Next will be setting all of the AWS parts that are needed to restore. This is like the info you will see in the VBR UI to perform the restore.

 

It adds a tag to the restored VM. This tag can be used by Veeam Backup for AWS as a policy to perform backups inside AWS after the restore. (Will post this in a future post, so be on the lookout for that )

 

Then it submits the restore and will sit in a wait loop until the restore is complete.

 

In the end, since you cannot change the IP of the VM instance in AWS, the script will retrieve the IP and VM name and place that into a CSV file that can be used to update a DNS server after restoring.

 

Now that we have reviewed the script at a high level, let’s look at how to add and use it in VRO.

 

Start by logging into VRO as an administrator and go to the Administration Gear Icon in the upper right corner. Once on this page, click on the Plan Steps in the Left navigation pane.

 

Since this is a new custom step, click the Add on the top of the screen, use a name that makes sense, like Restore to AWS .

 

Click Next, for the File: browse to the script location on your computer. Once you select it, you will see the script in the Preview: pane. This allows you to view the script but you cannot edit it here. 

 

Click Next, then either select to add to All scopes or you can add to specific scopes later. I choose to add to All Scopes for now. Click Next and then Click Finish on the Summary.

 

After it is created, back in the Plan Steps list, select it and click Edit. Click Next twice to get to the Parameters tab. Under Common Parameters, change the timeout. I set mine for 1 hour, 3600 seconds, to be safe as restoring into AWS does take time. Your mileage my vary and you made need to make it longer or shorter.

 

Under Execute Location – Default Value – Select Veeam Backup Server

 

Click Add to add a new parameter. This will be setup as the VM name variable to pass to the script. The parameter name must match exactly the variable param in the script. In my script it is VMName.

 

 

In the Default Value: - click Edit, Double Click the %source_vm_name%

 

Click Finish. Then Click Finish again

 

Now the Plan Step is ready to be used in a Recovery Plan. Exit the Administration page.

 

Here is where it gets a little tricky but also cool. Since we are passing the source VM name into the script, we can split a recovery into multiple locations. 

 

Example may be to restore some VMs from a backup job to an on prem DR site, or to Azure, and others into AWS via the script. Or we can use the script to restore all VMs into AWS by adding the custom script Plan Step to the VM in the plan.

 

To start, create a Recovery Plan if you do not have one. Select Recovery Plan – Manage – New. Fill in all fields appropriately, click Next. Select the Scope to assign the Plan to. Choose Restore as type of Plan, click Next. Choose your default recovery location – hint this will only matter for VMs that we do not adjust after the plan is created. 

 

Under Inventory Groups, select the Group that has the VMs in it that you plan to restore, click Next. For VM Recovery Options, I choose Proceed with the Plan and In Parallel, but you may want to use In Sequence. It is important to select Proceed with Plan as certain things in VRO will have a warning and this is expected. Click Next.

 

Now is the important part. If you plan to restore all VMs in the Group to AWS, you can remove the Restore VM and Check VM Heartbeat steps and add the custom Plan step. Remember, this is the action for everything in the plan.

 

After Removing, Add your custom step.

 

Set any of the other settings based on your needs/use and click Finish.

 

After the Plan is created, you will get a Warning under Check license and availability, and the details will show that the Restore VM Step is not found. We know this because we removed it .

 

The Plan is now ready to run. When you run it, watch the Step Details and the Veeam VBR for Status. Once complete, it will show a warning even though it is complete. All of the details of what occurred should be in the details and this will show up on the Plan Execution Report.

 

Another thing that happens is that the plan does not auto reset because of our customization. So you will need to select the Plan afterwards and manually reset it.

 

Also, if you used the part of the script to create the DNS CSV file, this will be on your VBR server with the VM names and AWS Ips. This can be used to verify the VMs are up and to adjust your DNS server with the new Ips of the VMs

5 comments

coolsport00
Forum|alt.badge.img+20
  • Veeam Legend
  • 4132 comments
  • August 13, 2024

Hey..great post Marty! Question re: scripting with VRO → can scripts be run against VMs upon Restore? A Community member posted about this with regular Replication, which I know scripts can’t be run against (unless there is something I’m not aware of there); but was wondering if they could be run in VRO?

Thanks!


skitch210
Forum|alt.badge.img+1
  • Author
  • Veeam MVP
  • 19 comments
  • August 13, 2024

In the Plan Steps in VRO, you can choose Execute Location - In Guest OS. There are limitations, but yes you can have VRO run scripts in the guest.

 


coolsport00
Forum|alt.badge.img+20
  • Veeam Legend
  • 4132 comments
  • August 13, 2024
skitch210 wrote:

In the Plan Steps in VRO, you can choose Execute Location - In Guest OS. There are limitations, but yes you can have VRO run scripts in the guest.

 

Ok, thanks. I assumed so, but since I haven’t dug into VRO (yet), I wasn’t entirely sure. Appreciate it Marty!


Chris.Childerhose
Forum|alt.badge.img+21
  • Veeam Legend, Veeam Vanguard
  • 8439 comments
  • August 13, 2024

Great post Marty as I love using scripts as much as possible for automation.  Nice to see the facility in VRO for this.


Dynamic
Forum|alt.badge.img+9
  • Veeam Vanguard
  • 368 comments
  • August 20, 2024

Great post and overview. Thanks for sharing this. 
Currently i’m running VRO only on one customer (here with replicas on the DR site) with multiple sites and use simple recovery plans for Tests, Reports and the DR scenario. 
I will bookmark and also recommend your post to my colleagues 👍


Comment