The following sample script will create a simple data recovery job. You will need to modify this script to fit your environment and configuration.
Be sure and expand your screen wide enough so that lines in the script file do not wrap.
# Sample script to create a simple data recovery job
# Specify the variables to be used in the script
# Original source server name $DtOriginalSourceName = "alpha"
# Repository server and credentials $DtRepositoryName = "beta" $DtRepositoryUserName = "domain\administrator" $DtRepositoryPassword = "password"
# Recovery server and credentials $DtRecoveryName = "gamma" $DtRecoveryUserName = "domain\administrator" $DtRecoveryPassword = "password"
# Type of image you will be recovering from (FullServer or DataOnly) $ImageType = "DataOnly"
# Type of workload you will be recovering and type of job you will be creating $DtWorkloadType = "DataOnlyImageRecovery" $DtJobType = "DataOnlyImageRecovery"
# Paths from the replica data to recover $DtSourceRecoveryPath1 = "C:\Dir1\" $DtSourceRecoveryPath2 = "C:\Dir2\"
# Import the Double-Take PowerShell module # This may be \Service\ or \Console\ depending on your installation Import-Module "C:\Program Files\Vision Solutions\Double-Take\Console\DoubleTake.PowerShell.dll"
# Create source and target objects $DtRepository = New-DtServer -Name $DtRepositoryName -UserName $DtRepositoryUserName -Password $DtRepositoryPassword $DtRecovery = New-DtServer -Name $DtRecoveryName -UserName $DtRecoveryUserName -Password $DtRecoveryPassword
# Get the images stored on the repository server $DtAllImages = Get-DtImages -ServiceHost $DtRepository # Filter out, by name and image type, the single image that you want to recover from $DtSingleImage = $DtAllImages | Where-Object {$_.SourceName -eq $DtOriginalSourceName -and $_.ImageType -eq $ImageType }
# Create a workload $DtWorkloadGUID = New-DtWorkload -ServiceHost $DtRepository -WorkloadTypeName $DtWorkloadType -ImageId $DtSingleImage.Id
# Specify the data to recover $DtRecoveryPath1 = New-Object DoubleTake.Common.Contract.PhysicalRule -Property @{Path=$DtSourceRecoveryPath1} $DtRecoveryRule1 = Add-DtPhysicalRule -ServiceHost $DtRepository -WorkloadId $DtWorkloadGuid -Rule $DtRecoveryPath1 $DtRecoveryPath2 = New-Object DoubleTake.Common.Contract.PhysicalRule -Property @{Path=$DtSourceRecoveryPath2} $DtRecoveryRule2 = Add-DtPhysicalRule -ServiceHost $DtRepository -WorkloadId $DtWorkloadGuid -Rule $DtRecoveryPath2 $DtWorkload = Get-DtWorkload -ServiceHost $DtRepository -WorkloadId $DtWorkloadGuid
# Get the default job options that will be used to create the job $DtJobOptions = Get-DtRecommendedJobOptions -ServiceHost $DtRecovery -Source $DtRepository -JobType $DtJobType -Workload $DtWorkload
# Create the job $DtJobGuidForDataRecovery = New-DtJob -ServiceHost $DtRecovery -Source $DtRepository -JobType $DtJobType -JobOptions $DtJobOptions.JobOptions
# Start the job Start-DtJob -ServiceHost $DtRecovery -JobId $DtJobGuidForDataRecovery
# Close the connections for the server objects Disconnect-DtServer -ServiceHost $DtRepository Disconnect-DtServer -ServiceHost $DtRecovery |
If you want to hide your user credentials in your script, use the Windows PowerShell Get-Credential cmdlet. The password will not be visible because Windows stores an encrypted password. See Hiding your password in a PowerShell script for basic details on using this cmdlet. See your Windows PowerShell documentation for detailed instructions.