A powershell script has been prepared to address such a situation. The script accepts two mandatory parameters: the list of nodes and the days of the week each of the nodes should be backed up. The script must be scheduled using Windows Task Scheduler to run on a daily basis at the time the backups are desired.
Due to the particular requirements of the job, there are 2 operations to perform:
1. A backup of all volumes
2. A backup with log truncation of the Exchange volumes.
If enabled, mountability checks are performed after each operation.
The code for the script is shown below between horizontal lines and attached to this KB
_____________________________________________________________________________________
param ([array]$dagnodes=$null,[array]$weekdays=$null)
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
}
function private:Wait-turn{
param($agentname,$jobtype,$pause=60)
Write-Host "`n Waiting for $agentname $jobtype to start"
do {
$notstarted = get-activejobs -ProtectedServer $agentname
Write-Host "`[$((get-date).tostring("yyyy-MM-dd HH:mm:ss"))`] $($notstarted.Summary)"
start-sleep $pause
Write-Host "." -NoNewline
}while(!($notstarted))
write-Host "`n Waiting for $jobtype for $agentname to finish"
do{
start-sleep $pause
$notdone = get-activejobs -ProtectedServer $agentname
Write-Host "`[$((get-date).tostring("yyyy-MM-dd HH:mm:ss"))`] $($notdone.Summary)"
Write-Host "." -NoNewline
}while($notdone)
Write-Host "`n $jobtype Done"
}
#$dagnodes="Trion","Trenzalore","Skaro","Gallifrey"
#$weekdays = "Monday","Tuesday","Wednesday","Thursday"
if(!($dagnodes)){Write-Host "-dagnodes cannot be null. Exiting"; exit}
if(!($weekdays)){Write-Host "-weekdays cannot be null; Exiting";exit}
if($dagnodes.Count -ne $weekdays.Count){write-Host "-dagnodes must match -weekdays. Try again. Exiting"; exit}
$corename=$env:computername
$today=(get-date).tostring("dddd")
$dagschedule = @{}
for($i=0;$i -lt $dagnodes.count;$i++){$dagschedule.Add($dagnodes[$i],$weekdays[$i])}
#get nodes
$nodes = (get-infoobject -uriend "agents").agents.agent | where {$_.agenttype -eq "Protected"} | select-object displayname,id,dayofweek,@{n="truncate";e={[boolean]::parse($_.hasSQLInstance) -or [boolean]::parse($_.hasExchangeInstance)}} | where {$dagnodes -contains $_.displayname }
$fullnodes=@()
foreach($node in $nodes){$node.dayofweek = $dagschedule[$node.displayname]; $fullnodes += $node}
[array]$myjobs = $fullnodes | where {$_.dayofweek -eq $today}
foreach($myjob in $myjobs){
$agentid = $myjob.id
$agentname = $myjob.displayname
$body= @"
$agentid
false
"@
$transfer = Invoke-RestMethod -Uri "https://$($corename):8006/apprecovery/api/core/xfer/schedule/forcealltransfer" -Method POST -Body $body -ContentType "application/xml" -UseDefaultCredentials
$transfer.transferJobsInfo.exceptioncollection
wait-turn -agentname $agentname -jobtype "Backup" -pause 5
if($myjob.truncate){
Start-LogTruncation -ProtectedServer $agentname
wait-turn -agentname $agentname -jobtype "Log Truncation" -pause 5
}
}
$body2=@"
"@
$Truncation = Invoke-RestMethod -Uri "https://$($corename):8006/apprecovery/api/core/logtruncation/agents/$($agentId)/force" -Method POST -Body $body2 -ContentType "text/xml" -UseDefaultCredentials
#>
_____________________________________________________________________________________