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.
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
I will create a couple of very simple scripts to accomplish these tasks. The scripts I created are called resize.cmd and resize.ps1
Get-Module -ListAvailable -Name VMware* | Import-Module
Connect-VIServer -Server vcsasrv.veeamsalab.org -Protocol https -User ‘firstname.lastname@example.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.
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.