While customized scripts are not supported by Quest Data Protection Support, knowedgeable users can use the sample PowerShell scripts or customize their own scripts to run at designated occurrences; for example, before or after a snapshot, before or after attachability and mountability checks, and so on. (Because the scripts run before or after a specific Rapid Recovery process, they are referred to as pre- and post- scripts.)
A powershell script addressing this issue has been prepared. Please note that Powershell 3.0 or later needs to be installed on the core from which the settings are to be extracted.
The script assumes that the agent IDs have been preserved. This is likely as it make sense to keep the replicated backup chains and add incrementals as opposed to adding new base images.
When running the script opens a menu that allows the type of exports to perform.
The final result is a .reg file called either -protection-policy.reg or -retention_policy.reg depending of the chosen option. These files contain instructions for deleting unecessary keys and values on the targeted core and adding the desired ones.
These are the retention Policy and Protection Groups together with the backup schedule.
The script creates the C:\Temp\Temp1 folder and the c:\temp\Temp1\folder. This last folder contains the values in .reg form for each agent separately so they can be used on an individual basis.
If only a few agents are to be exported, the script needs to be launched with the -interactive parameter and the user will be presented with a gridview allowing the selection of the agents of interest.
The script code is shown below between horizontal lines and attached to the KB.
_____________________________________________________
param ([switch]$interactive)
#export-import retention policy for a core and agents
function get-infoobject{
param ($cred=$null,$corename=$env:computername,$uriend)
try{
if(!($corename)){$corename=$env:computername}
$url = "https://$($corename):8006/apprecovery/api/core/"
$url = $url + $uriend
$wc = New-Object System.Net.WebClient
if($cred){$wc.Credentials = $cred}else{$wc.usedefaultcredentials=$true}
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
[xml]$objectinfo = $wc.DownloadString($url)
}catch{Write-Host "Unable to retrieve requested object from core $corename" -f red;return $null }
return $objectinfo
}
cls
$menu = @"
Select the operation to perform
1. Export Retention Policy
2. Export Protection Groups and Transfer Schedule
Enter value
"@
do{
cls
Write-Host "Retention Policy / Protection Policy Export Script`n--------------------------------------------------`n`n" -f Green
$optype = Read-Host -Prompt $menu
}until(1,2 -contains $optype)
$tempfolder = "c:\temp\temp1"
$placeholder=([GUID]::NewGuid()).Guid
#make unique temp folder
if(!(test-path -path $tempfolder -PathType Container)){New-Item -Path "$($tempfolder)" -ItemType Directory > $null}
New-Item -Path "$($tempfolder)\$($placeholder)" -ItemType Directory > $null
$firstline = "Windows Registry Editor Version 5.00"
if($optype -eq 1){
$corerp = "HKEY_LOCAL_MACHINE\SOFTWARE\AppRecovery\Core\RollupService"
$agentrp = "HKEY_LOCAL_MACHINE\SOFTWARE\AppRecovery\Core\Agents\$placeholder\RollupService"
$opname= "retention_policy"
if(!($interactive.IsPresent)){
#export core rollup policy
Write-Host "Exporting Core $($env:computername) $opname" -f yellow
& reg export $corerp "$($tempfolder)\$($placeholder)\$($env:computername).reg"
$keyremovalfile += "`[-$($corerp)`]",""
$addendum = " Core Retention Policy will NOT change"
}
}
else {
$agentrp = "HKEY_LOCAL_MACHINE\SOFTWARE\AppRecovery\Core\Agents\$placeholder\AgentProtectionConfiguration\ProtectionGroups"
$opname= "protection_policy"
}
$keyremovalfile = @()
$finalregfiletext=@()
#get agents ids
$agentsraw = (get-infoobject -uriend "agents").agents.agent
$agents= $agentsraw | select-object displayname,id
if($interactive.IsPresent){$agents = $agents | Out-GridView -Title "Select the agents to process. $addendum" -PassThru}
if(!($agents)){Write-Host "`n`nExiting...`n`n";exit}
#export agents rollup policy
foreach ($agent in $agents){
start-sleep 1
Write-Host "Exporting agent $($agent.displayname) $opname" -f yellow
$agentkey = $agentrp.replace($placeholder,$agent.id)
& reg export $agentkey "$($tempfolder)\$($placeholder)\$($agent.displayname).reg"
$keyremovalfile += "`[-$($agentkey)`]",""
}
$regfiles = (get-childitem -Path "$($tempfolder)\$($placeholder)").fullname
$finalregfiletext +=$firstline,""
$finalregfiletext += $keyremovalfile
foreach ($regfile in $regfiles){
$finalregfiletext += (get-content -Path $regfile).replace($firstline,"")
}
$finalregfiletext> "$tempfolder\$($env:computername)-$($opname).reg"
invoke-item -path $tempfolder
_____________________________________________________
© ALL RIGHTS RESERVED. Feedback 利用規約 プライバシー Cookie Preference Center