Resize the Resources of a Replicated Virtual Machine

Resize CPU and MemorySometimes you want to migrate your workload to a different DataCentre or Hosting partner. You also think you might take this opportunity to adjust your computer resources during the migration.

Resizing your compute specs, such as CPU and Memory, will reduce your total hosting expenses; but how can you incorporate the new specs for your resourcing resize during the migration?

Many customers will use the Veeam Replication feature to migrate the entire environment, or some of the workloads, to a different ESXi host, new data centre or new hosting partner. Several readers of my blog have asked if they can resize the CPU and Memory resources of their VMs during the Replication or Migration stage, taking the opportunity to save on their hosting expenses.

The answer to this question is very simple, yes, you can resize your compute resources during the replication by using a very simple VMware script.

Let’s consider the following scenario before I provide you with the complete run through of the solution.

Scenario

The scenario is very simple. I want to replicate one Virtual Machine from a production ESXi to a DR ESXi host. After the replication complete, I want to resize the CPU and Memory size.

To accomplish this, I need the following:

  • Install VMware PowerCLI on the Veeam Backup and Replication Server; and then
  • a script to;
    • Connect to the virtual centre, and
    • Resize the replicated VM

Script

I will create a couple of very simple scripts to accomplish these tasks. The scripts I created are called resize.cmd and resize.ps1

resize.cmd

powershell c:\resize.ps1

exit 0

resize.ps1

Get-Module -ListAvailable -Name VMware* | Import-Module
Connect-VIServer -Server vcsasrv.veeamsalab.org -Protocol https -User ‘administrator@vsalab.org’ -Password ‘P@ssw0rd’
get-vm -name “TestVBR-Up4_Replica” | Set-VM -MemoryGB 2 -Confirm:$false

Replication Job Configuration

After the scripts are prepared, create a normal replication job.  Add the resize.cmd script to run after the replication job is complete. See the screenshot below.

Conclusion

If you follow those steps, resizing your Virtual Machine CPU and memory is very simple and straightforward. Of course, the scripts I have provided here are very simple and basic. They are intended to demonstrate a basic resizing solution to everyone, regardless of knowledge level.

This solution also depends upon VMware PowerCLI; therefore, I suggest that you take the time to learn more about PowerCLI, as you can do much more than just resize your CPU and Memory.

 

 

Leave a Reply