VeeamHub/powershell

BR-DataIntegrationAPIModule.psm1

Closed this issue · 1 comments

Ti360 commented

Hello,

Long story short, I have a VBR in aws and one all-in-one (hyper-v, On host proxy, On host repository) server per site (20+ sites). I wondered if there was a way to tell the script to use the server where the job was running instead of using get-random. For example, I added the PS file to a test job in Toronto/Canada, and get-random attached the drive to a veeam proxy in Dallas/Texas. I was about to test using location tagging, but I did not plan to use that feature in the future.

It was only a 50 GB drive, but I am targeting bigger than that over a weekend.

Checking this script you referenced, here's the code that covers that logic:

if ($restoresessions -ne $null) {
# find target server with least number of restore sessions where not exceeding 2 sessions
# can improve this by doing math on cpu and memory usage of target servers. need one additional core for base OS
$maxSessionsPerTarget = 2
$targetServer = $null
$targetServerSessions = @{}
foreach($target in $targetServers) {
$targetServerSessions[$target.Name] = ($restoresessions | Where-Object {$_.InitiatorName -eq $target.Name} | measure-object).Count
Write-Log "Target server $($target.Name) has $($targetServerSessions[$target.Name]) restore sessions."
}
$leastSessionsServer = $targetServerSessions.GetEnumerator() | sort-object -property Value | select-object -first 1
if ($leastSessionsServer.Value -lt $maxSessionsPerTarget) {
$targetServer = $targetServers | Where-Object {$_.Name -eq $leastSessionsServer.Name}
}
# loop if target servers all have too many restore sessions, wait 30 seconds with a maximum of 30 minutes
$waittime = 0
while ($targetServer -eq $null -and $waittime -lt 1800) {
Write-Log "No target server found with less than $($maxSessionsPerTarget) restore sessions. Waiting 30 seconds."
Start-Sleep -Seconds 30
$waittime += 30
$restoresessions = @()
foreach($targets in $targetServers) {
$restoresessions += Get-VBRPublishedBackupContentSession
}
$targetServerName = $restoresessions | Group-Object -Property InitiatorName | Sort-Object -Property Count | Where-Object {$_.Count -lt $maxSessionsPerTarget} | Select-Object -First 1 -ExpandProperty Name
$targetServer = $targetServers | Where-Object {$_.Name -eq $targetServerName}
}
} else {
# pick random target server if no running restore sessions found
$targetServer = $targetServers | Get-Random
}

Per the code, before choosing a random server, the script looks for a target server where the number of active restore sessions does not exceed 2 sessions.

With this in mind, you can either adjust this logic in the script to what you desire or ensure your target server meets the requirements the script is looking for.