立即与支持人员聊天
与支持团队交流

Rapid Recovery 6.9 - Commands and Scripting Reference Guide

Introduction to Rapid Recovery Command Line Management utility PowerShell module
Prerequisites for using PowerShell Working with commands and cmdlets Rapid Recovery PowerShell module cmdlets
Add-EsxAutoProtectObjects Add-EsxVirtualMachines Add-HyperVClusterSharedVirtualDisks Add-HyperVClusterVirtualMachines Add-HyperVVirtualMachines Disable-HyperVAutoProtection Edit-AzureVirtualStandby Edit-EsxiVirtualStandby Edit-HyperVVirtualStandby Edit-OracleDBVerifyNightlyJob Edit-OracleLogTruncationNightlyJob Edit-Replication Edit-ScheduledArchive Edit-VBVirtualStandby Edit-VMVirtualStandby Enable-HyperVAutoProtection Enable-OracleArchiveLogMode Get-ActiveJobs Get-CloudAccounts Get-Clusters Get-CompletedJobs Get-ExchangeMailStores Get-Failed Get-FailedJobs Get-HyperVClusterSharedVirtualDisks Get-ListAzureVMSizes Get-Mounts Get-OracleInstances Get-Passed Get-ProtectedServers Get-ProtectionGroups Get-QueuedJobs Get-RecoveryPoints Get-ReplicatedServers Get-Repositories Get-ScheduledArchives Get-SqlDatabases Get-TransferQueueEntries Get-UnprotectedVolumes Get-Version Get-VirtualizedServers Get-Volumes New-AzureVirtualStandby New-Base New-BootCD New-CloudAccount New-EncryptionKey New-EsxiVirtualStandby New-FileSearch New-HyperVVirtualStandby New-Mount New-Replication New-Repository New-ScheduledArchive New-Snapshot New-VBVirtualStandby New-VMVirtualStandby Push-Replication Push-Rollup Remove-Agent Remove-EsxAutoProtectObjects Remove-HyperVClusterSharedVirtualDisks Remove-HyperVClusterVirtualMachines Remove-HyperVVirtualMachines Remove-Mount Remove-Mounts Remove-RecoveryPoints Remove-RemoteMount Remove-RemoteMounts Remove-Replication Remove-Repository Remove-ScheduledArchive Remove-VirtualStandby Restart-CoreService Resume-Replication Resume-ScheduledArchive Resume-Snapshot Resume-VirtualStandby Set-AgentMetadataCredentials Set-DedupCacheConfiguration Set-License Set-OracleMetadataCredentials Set-ReplicationResponse Start-Archive Start-AttachabilityCheck Start-AzureDeploy Start-AzureExport Start-ChecksumCheck Start-ConsumeSeedDrive Start-CopySeedDrive Start-EsxiExport Start-HypervExport Start-LogTruncation Start-MountabilityCheck Start-OptimizationJob Start-OracleDBVerifyJob Start-OracleLogTruncationJob Start-Protect Start-ProtectCluster Start-ProtectEsxServer Start-ProtectHyperVCluster Start-ProtectHyperVServer Start-RepositoryCheck Start-RestoreAgent Start-RestoreArchive Start-ScheduledArchive Start-VBExport Start-VirtualStandby Start-VMExport Stop-ActiveJobs Stop-CoreService Suspend-Replication Suspend-ScheduledArchive Suspend-Scheduler Suspend-Snapshot Suspend-VirtualStandby Suspend-VMExport Update-Repository
Localization Qualifiers
Scripting

PostExportScript.ps1

The PostExportScript is run on the Core after any export job.

Note: There are no input parameters for the PostExportScript when used to run once on the exported protected machine after initial startup. The regular protected machine should contain this script in the PowerShell script folder as PostExportScript.ps1.

Sample PostExportScript

# receiving parameter from export job
param([object]$ExportJobRequest)
# building path to Core's Common.Contracts.dll and loading this assembly
$regLM = [Microsoft.Win32.Registry]::LocalMachine
$regLM = $regLM.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AppRecovery Core 5')
$regVal = $regLM.GetValue('InstallLocation')
$regVal = $regVal + 'CoreService\Common.Contracts.dll'
[System.Reflection.Assembly]::LoadFrom($regVal)  |  out-null
$regVal2 = $regLM.GetValue('InstallLocation')
$regVal2 = $regVal2 + 'CoreService\Common.Contracts.dll'
# Converting input parameter into specific object
$ExportJobRequestObject = $ExportJobRequest -as [Replay.Core.Contracts.Export.ExportJobRequest]
# Working with input object. All echo's are logged
if($ExportJobRequestObject -eq $null) {
		echo 'ExportJobRequestObject parameter is null'
}
else {
		echo 'VolumeImageIds:' $ExportJobRequestObject.VolumeImageIds
		echo 'RamInMegabytes:' $ExportJobRequestObject.RamInMegabytes
}

PreNightlyJobScript.ps1

The PreNightlyJobScript is run before every nighty job on Core side. It contains the parameter $JobClassName, which helps to handle those child jobs separately.

Sample PreNightlyJobScript

# receiving parameters from Nightlyjob
param([System.String]$JobClassMethod , [object]$NightlyAttachabilityJobRequest, [object]$RollupJobRequest, [object]$Agents, [object]$ChecksumCheckJobRequest, [object]$TransferJobRequest, [int]$LatestEpochSeenByCore)
# building path to Core's Common.Contracts.dll and loading this assembly
$regLM = [Microsoft.Win32.Registry]::LocalMachine
$regLM = $regLM.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AppRecovery Core 5')
$regVal = $regLM.GetValue('InstallLocation')
$regVal = $regVal + 'CoreService\Common.Contracts.dll'
[System.Reflection.Assembly]::LoadFrom($regVal)  |  out-null
# Nightlyjob has four child jobs: NightlyAttachability Job, Rollup Job, Checksum Check Job and Log Truncation Job. All of them are triggering the script, and $JobClassMethod (contain job name that calls the script) helps to handle those child jobs separately
switch ($JobClassMethod) {
# working with NightlyAttachability Job
	NightlyAttachabilityJob {
		$NightlyAttachabilityJobRequestObject = $NightlyAttachabilityJobRequest -as [Replay.Core.Contracts.Sql.NightlyAttachabilityJobRequest];
		echo 'Nightly Attachability job results:';
			if($NightlyAttachabilityJobRequestObject -eq $null) {
				echo 'NightlyAttachabilityJobRequestObject parameter is null';
			}
			else {
				echo 'AgentIds:' $NightlyAttachabilityJobRequestObject.AgentIds;
				echo 'IsNightlyJob:' $NightlyAttachabilityJobRequestObject.IsNightlyJob;
			}
			break;
		}
# working with Rollup Job
	RollupJob {
		$RollupJobRequestObject = $RollupJobRequest -as [Replay.Core.Contracts.Rollup.RollupJobRequest];
		echo 'Rollup job results:';
			if($RollupJobRequestObject -eq $null) {
					echo 'RollupJobRequestObject parameter is null';
			}
			else {
				echo 'SimultaneousJobsCount:' $RollupJobRequestObject.SimultaneousJobsCount;
					echo 'AgentIds:' $RollupJobRequestObject.AgentIds;
					echo 'IsNightlyJob:' $RollupJobRequestObject.IsNightlyJob;
			}
			$AgentsCollection = $Agents -as "System.Collections.Generic.List``1[System.Guid]"
			if($AgentsCollection -eq $null) {
				echo 'AgentsCollection parameter is null';
			}
			else {
				echo 'Agents GUIDs:'
				foreach ($a in $AgentsCollection) {
					echo $a
			}
		}
		break;
	}
# working with Checksum Check Job
		ChecksumCheckJob {
			$ChecksumCheckJobRequestObject = $ChecksumCheckJobRequest -as [Replay.Core.Contracts.Exchange.ChecksumChecks.ChecksumCheckJobRequest];
			echo 'Exchange checksumcheck job results:';
			if($ChecksumCheckJobRequestObject -eq $null) {
				echo 'ChecksumCheckJobRequestObject parameter is null';
		}
		else {
				echo 'RecoveryPointId:' $ChecksumCheckJobRequestObject.RecoveryPointId;
				echo 'AgentIds:' $ChecksumCheckJobRequestObject.AgentIds;
				echo 'IsNightlyJob:' $ChecksumCheckJobRequestObject.IsNightlyJob;
			}
			break;
		}
# working with Log Truncation Job
	TransferJob {
		$TransferJobRequestObject = $TransferJobRequest -as [Replay.Core.Contracts.Transfer.TransferJobRequest];
		echo 'Transfer job results:';
		if($TransferJobRequestObject -eq $null) {
				echo 'TransferJobRequestObject parameter is null';
		}
		else {
				echo 'TransferConfiguration:' $TransferJobRequestObject.TransferConfiguration;
				echo 'StorageConfiguration:' $TransferJobRequestObject.StorageConfiguration;
			}
			echo 'LatestEpochSeenByCore:' $LatestEpochSeenByCore;
			break;
		}
}

PostNightlyJobScript.ps1

The PostNightlyJobScript is run after every nighty job on the Core. It contains the parameter $JobClassName, which helps to handle those child jobs separately.

Sample PostNightlyJobScript

# receiving parameters from Nightlyjob
param([System.String]$JobClassMethod , [object]$NightlyAttachabilityJobRequest, [object]$RollupJobRequest, [object]$Agents, [object]$ChecksumCheckJobRequest, [object]$TransferJobRequest, [int]$LatestEpochSeenByCore, [object]$TakeSnapshotResponse)
# building path to Core's Common.Contracts.dll and loading this assembly
$regLM = [Microsoft.Win32.Registry]::LocalMachine
$regLM = $regLM.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AppRecovery Core 5')
$regVal = $regLM.GetValue('InstallLocation')
$regVal = $regVal + 'CoreService\Common.Contracts.dll'
[System.Reflection.Assembly]::LoadFrom($regVal)  |  out-null
$regVal2 = $regLM.GetValue('InstallLocation')
$regVal2= $regVal2 + 'CoreService\Core.Contracts.dll'
[System.Reflection.Assembly]::LoadFrom($regVal2) | out-null
# Nightlyjob has four child jobs: NightlyAttachability Job, Rollup Job, Checksum Check Job and Log Truncation Job. All of them are triggering the script, and $JobClassMethod (contain job name that calls the script) helps to handle those child jobs separately
switch ($JobClassMethod) {
# working with NightlyAttachability Job
	NightlyAttachabilityJob {
		$NightlyAttachabilityJobRequestObject = $NightlyAttachabilityJobRequest -as [Replay.Core.Contracts.Sql.NightlyAttachabilityJobRequest];
		echo 'Nightly Attachability job results:';
		if($NightlyAttachabilityJobRequestObject -eq $null) {
			echo 'NightlyAttachabilityJobRequestObject parameter is null';
		}
		else {
			echo 'AgentIds:' $NightlyAttachabilityJobRequestObject.AgentIds;
			echo 'IsNightlyJob:' $NightlyAttachabilityJobRequestObject.IsNightlyJob;
		}
		break;
	}
# working with Rollup Job
	RollupJob {
		$RollupJobRequestObject = $RollupJobRequest -as [Replay.Core.Contracts.Rollup.RollupJobRequest];
		echo 'Rollup job results:';
		if($RollupJobRequestObject -eq $null) {
			echo 'RollupJobRequestObject parameter is null';
		}
		else {
			echo 'AgentIds:' $RollupJobRequestObject.AgentIds;
			echo 'IsNightlyJob:' $RollupJobRequestObject.IsNightlyJob;
		}
		$AgentsCollection = $Agents -as "System.Collections.Generic.List``1[System.Guid]"
		if($AgentsCollection -eq $null) {
			echo 'AgentsCollection parameter is null';
		}
		else {
		echo 'Agents GUIDs:'
			foreach ($a in $AgentsCollection) {
				echo $a
				}
			}
			break;
		}
# working with Checksum Check Job
	ChecksumCheckJob {
		$ChecksumCheckJobRequestObject = $ChecksumCheckJobRequest -as [Replay.Core.Contracts.Exchange.ChecksumChecks.ChecksumCheckJobRequest];
		echo 'Exchange checksumcheck job results:';
		if($ChecksumCheckJobRequestObject -eq $null) {
			echo 'ChecksumCheckJobRequestObject parameter is null';
		}
		else {
			echo 'RecoveryPointId:' $ChecksumCheckJobRequestObject.RecoveryPointId;
			echo 'AgentIds:' $ChecksumCheckJobRequestObject.AgentIds;
			echo 'IsNightlyJob:' $ChecksumCheckJobRequestObject.IsNightlyJob;
		}
		break;
	}
# working with Log Truncation Job
	TransferJob {
		$TransferJobRequestObject = $TransferJobRequest -as [Replay.Core.Contracts.Transfer.TransferJobRequest];
		echo 'Transfer job results:';
		if($TransferJobRequestObject -eq $null) {
			echo 'TransferJobRequestObject parameter is null';
		}
		else {
			 echo 'TransferConfiguration:' $TransferJobRequestObject.TransferConfiguration;
			echo 'StorageConfiguration:' $TransferJobRequestObject.StorageConfiguration;
		}
		echo 'LatestEpochSeenByCore:' $LatestEpochSeenByCore;
		$TakeSnapshotResponseObject = $TakeSnapshotResponse -as [Replay.Agent.Contracts.Transfer.TakeSnapshotResponse];
		if($TakeSnapshotResponseObject -eq $null) {
			echo 'TakeSnapshotResponseObject parameter is null';
		}
		else {
			echo 'ID of this transfer session:' $TakeSnapshotResponseObject.SnapshotSetId;
			echo 'Volumes:' $TakeSnapshotResponseObject.VolumeSnapshots;
		}
		break;
	}
}

Using Bourne shell and Bash scripting with Rapid Recovery

Bourne shell (sh) is a shell language or command-line interpreter for Unix-based operating systems. Bourne shell is used in Rapid Recovery with Linux to customize environments and specify certain operations to occur in a predetermined sequence. The .sh is the file extension and naming convention for Bourne shell files.

Bourne Again Shell (Bash) is a similar shell language that implements the same grammar, parameter, and variable expansion, redirection and quoting. Bash also uses the same .sh file extension. The information here applies equally to Bash.

Using pre and post transfer, pre and post snapshot, and post export script hooks, you can perform system operations before and after a transfer or snapshot, or after virtual export. For example, you may want to disable a certain cronjob while a transfer is occurring and enable it once the transfer has finished. As another example, you may need to run commands to flush application-specific data to disk. The contents are written to a temporary file and run using exec. The script then runs using the interpreter defined in the first line of the script, for example, (#!/usr/bin/env bash). If the specified interpreter is not available, the script uses the default shell defined in the $SHELL environment variable.

You can substitute and use any interpreter. For example, on the #! line of the script, you can replace “bash” with “zsh” (Z shell), “tcsh” (tee shell), and so on, based on your preference.

You can add available objects from the TransferPrescript parameter or add your own commands to the PreTransferScript.sh and PostTransfer.sh scripts to customize them.

Only PreTransferScript and PostTransferScript receive parameters. The snapshot and export scripts do not.

This section describes the scripts that administrators can use at designated occurrences in Rapid Recovery for Windows and Linux. It includes the following topics:

Prerequisites for shell scripting

Rapid Recovery provides the ability to run Bourne shell, Bash, and other shell scripts on a protected Linux machine before and after a transfer. The following scripts are supported for Linux machines protected with the Rapid Recovery Agent software.

Note: If a script is not executable, the transfer job fails.
  • PreTransferScript.sh
  • PostTransferScript.sh
  • PreSnapshotScript.sh
  • PostSnapshotScript.sh
  • PostExportScript.sh

To use these scripts, ensure that they reside in the /opt/apprecovery/scripts/ directory.

Execution timing for pre and post scripts

For context, the following diagram shows the difference in timing for running pre and post transfer and snapshot scripts.

When pre and post scripts execute

When pre and post scripts execute

Supported transfer and post-transfer script parameters

The following parameters are supported on Linux for transfer scripts. For more information, see Sample shell scripts.

  • TransferPrescriptParameter_VolumeNames=$TransferPrescriptParameter_VolumeNames
  • TransferPrescriptParameter_ShadowCopyType=$TransferPrescriptParameter_ShadowCopyType
  • TransferPrescriptParameter_TransferConfiguration=$TransferPrescriptParameter_TransferConfiguration
  • TransferPrescriptParameter_StorageConfiguration=$TransferPrescriptParameter_StorageConfiguration
  • TransferPrescriptParameter_Key=$TransferPrescriptParameter_Key
  • TransferPrescriptParameter_ForceBaseImage=$TransferPrescriptParameter_ForceBaseImage
  • TransferPrescriptParameter_IsLogTruncation=$TransferPrescriptParameter_IsLogTruncation
  • TransferPrescriptParameter_LatestEpochSeenByCore=$TransferPrescriptParameter_LatestEpochSeenByCore

The following parameters are supported on Linux for post transfer scripts.

  • TransferPostscriptParameter_VolumeNames=$TransferPostscriptParameter_VolumeNames
  • TransferPostscriptParameter_ShadowCopyType=$TransferPostscriptParameter_ShadowCopyType
  • TransferPostscriptParameter_TransferConfiguration=$TransferPostscriptParameter_TransferConfiguration
  • TransferPostscriptParameter_StorageConfiguration=$TransferPostscriptParameter_StorageConfiguration
  • TransferPostscriptParameter_Key=$TransferPostscriptParameter_Key
  • TransferPostscriptParameter_ForceBaseImage=$TransferPostscriptParameter_ForceBaseImage
  • TransferPostscriptParameter_IsLogTruncation=$TransferPostscriptParameter_IsLogTruncation
  • TransferPostscriptParameter_LatestEpochSeenByCore=$TransferPostscriptParameter_LatestEpochSeenByCore

Testing shell scripting

You can test the scripts you want to run by using the editor for the script (.sh) files.

Note: If the pre or post script fails, the job also fails. Information about the job is available in the /var/log/apprecovery/apprecovery.log file.
 Successful scripts return the exit code 0.
相关文档

The document was helpful.

选择评级

I easily found the information I needed.

选择评级