• This topic has 6 replies, 1 voice, and was last updated October 1, 2020 by Chad F.

DNS Pre / Post – Recovery Script:

  • <b>References:</b>
    <u><b>Disclaimer </b></u><u><b>Warnings:</b></u>
    1. Pre or Post Recovery Script work on Test or Live Failovers (so consider pulling Script Configs in VPG for Tests)
    2. Be 100% sure that all DNS references in CSV files are 100% correct at Protection or Recovery Site because the script will delete and create according to what is in the files
    <u><b>DNS Automation Instructions:</b></u>
    1. Create Zerto Domain Service account
    2. Add Service Account to Domain DNS Admin
    3. Go to Both ZVM’s and update the Zerto Service “Log on” from Local to the newly create Service account
    4. Create a dir for each VPG on each ZVM’s @ SITE-A and SITE-B Example = c:\zertp\vpgs\colo-vpg-01\
    5. Create VPG’s
    6. Configure Pre or Post Recovery with Configuration below to execute the Script on failover
    All these scripts and files can be managed remotely with powershell or files shares on the ZVM’s. The script that is triggers is the Script @ you Recovery Site, so if the VPG is going to Site B, the script @ Site B will be executed. Now this is why you use the same directory for each site, when it goes back to Site A it runs the scripts on Site A ZVM and when it goes to Site B it runs the scripts on Site B to update the DNS.
    <u><b> </b></u>
    <u><b>VPG Configuration</b></u>
    Command = powershell.exe
    Paramerter = C:\zerto\vpgs\colo-vpg-01\zerto-dns.ps1
    <b>VPG Pre/Post Recovery Config</b>
    <i>Command </i>= powershell.exe  <i>Params </i>= C:\zerto\vpgs\bos-vpg-01\zerto-dns.ps1
    All of this is driven with DNSCMD, you should run all scripts on your ZVM’s to validate functionality. Run dnscmd on your ZVM’s and if you have trouble make sure you have DNS management tools installed. If you also have trouble executing the script or commands locally or from the VPG You may want to check your powershell execution policies as well, i was running in Bypass initially but then moved to RemoteSigned.
    If you haven’t used DNSCMD before this, I would suggest using example commands below to create and delete records to get comfortable with the commands functionality.
    #Add Record
    #dnscmd ADServer-01 /recordadd domain.com testing A x.x.x.x
    #Create PTR
    #dnscmd ADServer-01 /recordadd reversezone x.x.x.x PTR testing.domain.com
    #Delete Record
    #dnscmd ADServer-01 /recorddelete domain.com testing A /f
    #Delete PTR
    #dnscmd ADServer-01 /RecordDelete reversezone x.x.x.x PTR testing.domain.com /f
    #Create Record w/ Files
    #Import-Csv .\dns-newa.csv | foreach {dnscmd Server-01 /RecordAdd $_.zone $_.hostname A $_.ip}
    #Create PTR w/ Files
    #Import-Csv .\dns-newptr.csv | foreach {dnscmd Server-01 /RecordAdd $_.reversezone $_.lowip PTR $_.fqdn}
    #Delete Record w/ File
    #Import-Csv .\dns-olda.csv | foreach {dnscmd Server-01 /RecordDelete $_.zone $_.hostname A $_.ip /f}
    #Delete PTR w/ File
    #Import-CSV .\dns-oldptr.csv | foreach {dnscmd Server-01 /RecordDelete $_.reversezone $_.lowip PTR $_.fqdn /f}
    ## Set DNS servers
    $DNSservers= @(“Server-01”, “Server-01”)
    ## Filepath to script and CSV files
    $FP = “C:\zerto\vpgs\bos-vpg-01”
    CD $FP
    Foreach($DNSserver in $DNSservers)
      Import-CSV .\dns-olda.csv | foreach {
        dnscmd $DNSserver /RecordDelete $_.zone $_.hostname A $_.ip /f}
      Import-CSV .\dns-newa.csv | foreach {
        dnscmd $DNSserver /RecordAdd $_.zone $_.hostname A $_.ip}
      Import-CSV .\dns-oldptr.csv | foreach {
        dnscmd $DNSserver /RecordDelete $_.reversezone $_.lowip PTR $_.fqdn /f}
      Import-CSV .\dns-newptr.csv | foreach {
        dnscmd $DNSserver /RecordAdd $_.reversezone $_.lowip PTR $_.fqdn}
    Thanks for all the help from the community members and i hope this helps.

    Thanks for your contributions, Dan! I hope this is useful for others looking for information.


    Follow me: www.twitter.com/HarrySiii

    Great post. Zerto’s documentation on post failover script requirements is unclear and their example scripts have errors in them. I was able to configure it successfully using this post.

    Hey Mike,


    Good to hear it! I had a bit of a hard time pulling together what i needed as well so im happy this helped!



    Do you have an example of what the .csv file should look like?

    Anybody else have any luck with this?

    Any new updates on this or different way to tackle it with V7.5 or v8?

You must be logged in to create new topics. Click here to login