Site Recovery Manager makes environment variables available that you can use in commands for custom recovery steps.

Command steps on Site Recovery Manager Server run with the identity of the Site Recovery Manager 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.

Site Recovery Manager sets the environment variables only for the duration of the command step. Тhe specific environment variables do not exist in Site Recovery Manager 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

Site Recovery Manager makes additional environment variables available for per-virtual machine command steps that run either on Site Recovery Manager 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, Site Recovery Manager downloads the content of the file and adds it as a result to the recovery plan history and server logs.

Site Recovery Manager 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, Site Recovery Manager deletes the command output file.

C:\Windows\TEMP\vmware0\srmStdOut.log

Commands That Can Run on Site Recovery Manager

For the Site Recovery Manager 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

Content for Command That Runs on a Recovered Virtual Machine

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