Restoring VMWare VMs with the Commvault REST API
Restoring VMs with the Commvault REST API
One option to restoring VMware VM’s in bulk would be to use the Commvault REST API. It allows for flexibility, automation, and integration.
The following scripts use PowerShell and the Commvault REST API to automate the restore of VM’s in place, out-of-place, and at the guest file level via input files.
Restoring VM’s In-Place
To restore VMWare VM’s in-place in bulk you can download the script from here. This script restores VMs in-place as specified in input file with one VM per line
Example Input File:
VM1
VM2
VM3
VM4
VM5
- If using domain credentials then use the format
user@domain.example
- Create folder
C:\cvscripts
and run the script from this folder - Modify the
$cs
variable to match your environment
Restoring VM’s Out-of-Place
Restore VMWare VM’s in bulk out-of-place using the Commvault REST API. It can be downloaded here
- Prefix added to restored VM is
DRTest_
but can be changed. See$prefix
variable - Change the
$cs
and$hypervisor
variables to match your environment - If using domain credentials then use format
user@domain.example
- Create folder
C:\cvscripts
and run script from this folder
This is an example input csv file
vmname,esx,datastore
mysqlserver,esx1.company.lab,esx1_DR_Target
server2,esx2.company.lab,esx2_DR_Target
myserver3,esx3.company.lab,esx3_DR_Target
NotARealVM,esx2.company.lab,esx2_DR_Target
Restore same file for multiple VM’s
This script loops through a feeder txt file with one VMWare VM per line and restores a specified file in place for all VM’s. It can be downlowded here
- If using domain credentials then use format
user@domain.example
- Create folder
C:\cvscripts
and run script from this folder - Change the @body fileoption and destination sections to specify the file to be restored
- Change the @body guestUserPassword. Convert your password to base64. You can use this site
- Recommend generating the JSON via the Command Center Equivalent API option then using below as a reference for variable replacement. This also converts your password to base64 automatically!