VMware Live Site Recovery makes environment variables available that you can use in commands for custom recovery steps.
Command steps on VMware Live Site Recovery Server run with the identity of the VMware Live Site Recovery service account. In the default configuration, command steps on a recovered VM run with the identity of the VMware Tools service account. You can change the default configuration of the VMs that are compatible with the recovery.autoDeployGuestAlias setting. For information about the recovery.autoDeployGuestAlias setting, see Change Recovery Settings.
VMware Live Site Recovery sets the environment variables only for the duration of the command step. The specific environment variables do not exist in VMware Live Site Recovery Server and the guest OS of the recovered VM if the command is completed.
Name | Value | Example |
---|---|---|
VMware_RecoveryName | Name of the recovery plan that is running. | Plan A |
VMware_RecoveryMode | Recovery mode. | Test or recovery |
VMware_VC_Host | Host name of the vCenter Server at the recovery site. | vc_hostname.example.com |
VMware_VC_Port | Network port used to contact vCenter Server. | 443 |
VMware Live Site Recovery makes additional environment variables available for per-virtual machine command steps that run either on VMware Live Site Recovery Server or on the recovered virtual machine.
Name | Value | Example |
---|---|---|
VMware_VM_Uuid | UUID used by vCenter Server to uniquely identify this virtual machine. | 4212145a-eeae-a02c-e525-ebba70b0d4f3 |
VMware_VM_Name | Name of this virtual machine, as set at the protected site. | My New Virtual Machine |
VMware_VM_Ref | Managed object ID of the virtual machine. | vm-1199 |
VMware_VM_GuestName | Name of the guest OS as defined by the VIM API. | otherGuest |
VMware_VM_GuestIp | IP address of the virtual machine, if known. | 192.168.0.103 |
Vmware_VM_Path | Path to the VMX file of this virtual machine. | [datastore-123] jquser-vm2/jquser-vm2.vmx |
Name | Value and Description | Example |
---|---|---|
VMware_GuestOp_OutputFile | The value is the path to a command output file. If the command creates the file, VMware Live Site Recovery downloads the content of the file and adds it as a result to the recovery plan history and server logs. VMware Live Site Recovery adds the final 4 KB of the command output file to the recovery plan history and server logs. If the scripts generate an output greater than 4 KB, the output must be recorded in a custom location. When the command finishes, VMware Live Site Recovery deletes the command output file. |
C:\Windows\TEMP\vmware0\srmStdOut.log |
Commands That Can Run on VMware Live Site Recovery
clear echo "$(date "+%Y-%m-%d %H:%M:%S") : Recovery Plan $VMware_RecoveryName ran in $VMware_RecoveryMode mode" # some more custom actions
/bin/sh /home/admin/myServerScript.shYou cannot run commands on VMware Live Site Recovery Server on Azure VMware Solution.
Content for Command That Runs on a Recovered Virtual Machine
For Windows guest OS, you can create a myGuestScript.bat file that has the following content.
@echo off echo %DATE% %TIME% : VM %VMware_VM_Name% recovered by RP %VMware_RecoveryName% ran in %VMware_RecoveryMode% mode echo %DATE% %TIME% : Configured with the following FQDN: %VMware_VM_GuestName% and IP: %VMware_VM_GuestIp% :: some more custom actions
C:\Windows\System32\cmd.exe /c C:\myScripts\myGuestScript.bat > %VMware_GuestOp_OutputFile% 2>&1
For Linux or UNIX guest OS, you can create a myGuestScript.sh file that has the following content.
echo $(date) : VM $VMware_VM_Name recovered by $VMware_RecoveryName ran echo $(date) : Configured with the following FQDN: $VMware_VM_GuestName and IP: $VMware_VM_GuestIp # some more custom actions
/bin/sh myGuestScript.sh &>$VMware_GuestOp_OutputFile