VMware Cloud Community
raadek
Enthusiast
Enthusiast
Jump to solution

SRM 4.1 - different custom steps in Recovery Plan Test and DR Mode

Hi all,

Whilst running SRM Recovery Plan, I need to to trigger two different scripts (doing different things), depending whether the plan is run in Test, or in DR Mode.

Can this be done based on the operator input (like 'choice Y/N - is this a test?'), or do I need to build two separate Recovery Plans, one for testing, the other one for actual fail-over?

Kind regards,
Radek

0 Kudos
1 Solution

Accepted Solutions
cjscol
Expert
Expert
Jump to solution

If you add a command step to the recovery plan to run a batch file, e.g.

c:\windows\system32\cmd.exe /c c:\srm_scripts\myscript.bat

And then in the batch file check the variable %VMware_RecoveryMode%.  If it is set to recovery it is running in recovery mode, if it is set to test it is in testmode e.g. To run a different PowerCLI script depending on whether it is running a true DR recovery or a test but the following in the batch file, where myrecoveryscript.ps1 is the PowerCLI script to run in recovery mode and mytestscript.ps1 is the PowerCLI script to run in test mode:

if %VMware_RecoveryMode%=="recovery" powershell -PSconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "c:\srm_scripts\myrecoveryscript.ps1"

if %VMware_RecoveryMode%=="test" powershell -PSconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "c:\srm_scripts\mytestscript.ps1"

Calvin Scoltock VCP 2.5, 3.5, 4, 5 & 6 VCAP5-DCD VCAP5-DCA http://pelicanohintsandtips.wordpress.com/blog LinkedIn: https://www.linkedin.com/in/cscoltock

View solution in original post

0 Kudos
3 Replies
raadek
Enthusiast
Enthusiast
Jump to solution

OK, on a second thought my question is a little bit dumb Smiley Wink - I can always do the Y/N (Test/DR) choice within my script.

Still curious whether Recovery Plan itself can be build with different choices.

0 Kudos
cjscol
Expert
Expert
Jump to solution

If you add a command step to the recovery plan to run a batch file, e.g.

c:\windows\system32\cmd.exe /c c:\srm_scripts\myscript.bat

And then in the batch file check the variable %VMware_RecoveryMode%.  If it is set to recovery it is running in recovery mode, if it is set to test it is in testmode e.g. To run a different PowerCLI script depending on whether it is running a true DR recovery or a test but the following in the batch file, where myrecoveryscript.ps1 is the PowerCLI script to run in recovery mode and mytestscript.ps1 is the PowerCLI script to run in test mode:

if %VMware_RecoveryMode%=="recovery" powershell -PSconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "c:\srm_scripts\myrecoveryscript.ps1"

if %VMware_RecoveryMode%=="test" powershell -PSconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "c:\srm_scripts\mytestscript.ps1"

Calvin Scoltock VCP 2.5, 3.5, 4, 5 & 6 VCAP5-DCD VCAP5-DCA http://pelicanohintsandtips.wordpress.com/blog LinkedIn: https://www.linkedin.com/in/cscoltock
0 Kudos
raadek
Enthusiast
Enthusiast
Jump to solution

Very useful hint - thanks a lot!

0 Kudos