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.

Table 1. Environment Variables Available to All Command Steps
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.

Table 2. Environment Variables Available to Per-Virtual Machine Command Steps
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
Table 3. Environment Variables Available to Per-Virtual Machine Command Steps That Run on Recovered Virtual Machines
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

For the VMware Live Site Recovery Appliance, you can create a myServerScript.sh script that has the following content.
clear
echo "$(date "+%Y-%m-%d %H:%M:%S") : Recovery Plan $VMware_RecoveryName ran in $VMware_RecoveryMode mode"
# some more custom actions
Note: Do not use the vertical bar (|) and the single quote (') symbols when writing the commands in the script.
To run the myServerScript.sh script, use the following command content.
/bin/sh /home/admin/myServerScript.sh
You 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
To run the myGuestScript.bat, use the following command content.
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
To run the myGuestScript.sh file, use the following command content.
/bin/sh myGuestScript.sh &>$VMware_GuestOp_OutputFile