Running Scripts Before or After Recovering a VPG

KB Number:
00000033

Solution:

Purpose


An administrator may want to run a script before or after failing over a VPG. Zerto Virtual Replication supports this functionality with the Pre-recovery and Post-recovery script configuration option, in the VPG configuration.

Affected Versions


Through 2.0 Update 1 (Viper)

Complexity


Medium

Explanation


Before and after executing a Failover, move or test Failover, you can run executable scripts, such as Windows bat files. The Post-recovery scripts that run after a Failover, move or test Failover, run after all the virtual machines have been powered on at the recovery site.  Refer to the Example Pre-recovery / Post-recovery Scripts solution article.
These scripts must be saved to the machine where the peer Zerto Virtual Manager is installed. If the site is masked, you cannot see or specify scripts in the VPG definition at the masked site, but the site that implements the masking can edit the VPG to add scripts.
 
Note: It is recommended to duplicate scripts on the Zerto Virtual Managers for both the protected and recovery sites, so that if reverse replication is required, the scripts are available. The location of the scripts on both local and peer machines must be to the same. For example, if the scripts are saved to C:ZertScripts on the peer Zerto Virtual Manager machine, they must be saved toC:ZertScripts on the local Zerto Virtual Manager machine.
The scripts can include environment variables which can be included as part of the script itself, or passed to the script as parameters. When the script is passed an environment variable as a parameter, the variable is evaluated before executing the script. The following environment variables are available:
  • %ZertoVPGName% – The name of the VPG. If the name includes a space, enclose the variable in double quotes (”). For example, the VPG MyVPG uses the format %ZertoVPGName% but the VPG My VPG uses the format “%ZertoVPGName%”.
  • %ZertoOperation% – The operation being run: Failover, Move, Test, MoveBeforeCommit, MoveRollback.
  • %ZertoVCenterIP% – The IP address of the vCenter Server where the VPG is recovered.
  • %ZertoVCenterPort% – The port used by the Zerto Virtual Manager to communicate with the vCenter Server – the default is 443.
  • %ZertoForce% – A boolean value, Yes/No, that dictates whether to abort the operation if the script fails.
For example, if a specific VPG should not be migrated, the pre-recovery script can determine whether to continue based on the values of the %ZertoOperation% and %ZertoVPGName%.
 
When specifying scripts in the definition of a VPG, check the Use recovery scripts checkbox to display the script field - scripts can, however, be defined without being used.The following values are entered for the Pre-recovery Script and Post-recovery Script:
  • Command to run – The name of the script to run, including the full path. The script must be located on the same machine as the Zerto Virtual Manager for the recovery site.
  • Params – The values of any parameters to pass to the script. Separate parameters with a space.
  • Timeout (sec) – The time out in seconds for the script to run. If the script runs before executing a failover, move or test failover and the script fails or a timeout value is reached, an alert is generated and the failover, move or test failover is not performed1. If the script runs after executing a failover, move or test failover and the timeout value is reached, an alert is generated. The default value is the value specified in the Site Configuration Advanced Settings dialog.

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.00 out of 5)
Loading...