Processing deeper logic in Carbonite replication PowerShell scripts: Mirror Start Options

  • 31 January 2023
  • 0 replies
  • 41 views

Userlevel 1

When creating a Carbonite replication job, you have to make some decisions on the Job Options.  Some of these options straight forward decisions, do you want encryption, True or False, others may have to build more logic in the decision.  The next set of examples include how to address some of these in-depth decisions.

Mirror Start Options

The Mirror Start Options has several different choices when viewed in the console.

Mirror Start Options

However, when processing the PowerShell (or REST API) you will need to calculate results based on the enumerated values found in the PowerShell Scripting Guide.  Here is a link to the specific information in case you are interested:

https://download.doubletake.com/_download/8.5/8.5.1.0/Docs/PowerShell/PowerShellScriptingGuide.htm#Enumerations/MirrorOperationOptions.htm?Highlight='mirror'%20AND%20'option'

in the simple example below, I show the “Import-Csv” PowerShell Cmdlet to read a multi-line .CSV file into a PowerShell object variable ($jobstream).  Then, I show the FOREACH PowerShell loop that reads each row of the $jobstream for processing.

$jobStream = Import-Csv $qName 

foreach($row in $jobStream)

 

The $jobstream CSV, for this use case, has about 35 fields in it.  One of those fields holds the Mirror Options values.  These values (in this case) are "Synchronize", "Report", "CalculateDifferences", "CalculateSize" and "ProcessOrphans".  If you are building your own solution you can choose to represent these values any way you would like. But for this example, the field value will be placed into an array ($tmpAry) then another foreach loop will process each array element.

 $tmpAry=$row.MrrOpOptions -split ";"

       [int]$mmoEnum=0

foreach($mo in $tmpAry){      

 

The processing of the array elements accumulates the value of the element into a variable ($mmoEnum).  The element values are based on the defined values in the documentation (see link above)      

        if($mo -eq "Synchronize"){$mmoEnum=$mmoEnum + 1}

        if($mo -eq "Report"){$mmoEnum=$mmoEnum + 2}

        if($mo -eq "CalculateDifferences"){$mmoEnum=$mmoEnum + 4}

        if($mo -eq "CalculateSize"){$mmoEnum=$mmoEnum + 8}

        if($mo -eq "ProcessOrphans"){$mmoEnum=$mmoEnum + 16}

    }

So, if the array element is equal to “Synchronize” then the variable $mmoEnum is incremented by the value of 1.  If the array element is “Report” then add 2 to the $mmoEnum variable. Continue through the array to achieve the final value for the $mmoEnum variable.  Once done, assign that value to the Job Options object

 $dtJobOptions.JobOptions.CoreConnectionOptions.ConnectionStartParameters.MirrorParameters.Options = $mmoEnum

 Later in the PowerShell script you will create the job using the $dtJobOptions.JobOption object, which now contains the $mmoEnum value that was calculated.

$dtJobGuid = New-DtJob -ServiceHost $dtTgt -Source $dtSrc -JobType $DtJobType -Options $dtJobOptions.JobOptions

 

I hope this helps your development of the PowerShell scripts for Carbonite.  If you have any questions, please reach out and ask.


0 replies

Be the first to reply!

Reply