PowerShell script exchange
Post Reply
Sergihire
Lurker
Posts: 1
Liked: never
Joined: Dec 09, 2015 3:43 pm
Full Name: Sergii Marchenko
Contact:

Backup Proxy Traffic Throttling Rules

Post by Sergihire »

Hi Veeam Community,

I would like to configure Network Traffic Throttling Rules using Powershell, but I can't find a way to do that.
In Get-VBRViProxy command I couldn't find a parameters to set it up.

So, could you please help me?
veremin
Product Manager
Posts: 20261
Liked: 2249 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by veremin »

Unfortunately, throttling rules are not configurable via PowerShell. Thanks.
ryan.odwyer
Service Provider
Posts: 7
Liked: never
Joined: May 07, 2012 12:39 am
Full Name: Ryan O'Dwyer
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by ryan.odwyer »

Hi,

Is this on the roadmap?

I'm keen to use it in this scenario:

Users login to RDS servers on weekends and out of normal business hours during the week.

With Backup Copy and Cloud Connect copy jobs the bandwidth to push offsite is impacting RDS users.

When there are no users logged in and active(can script a test through powershell already) then a script would configure the traffic shaping rules to not apply and run full speed to offsite locations.

When there are active users in RDS enable the traffic throttling rules with Veeam powershell commands so that their RDS is responsive.

If you haven't guessed the link is only a few Mb so every thing competes for bandwidth.

Thanks,
Ryan
tsightler
VP, Product Management
Posts: 6003
Liked: 2840 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by tsightler »

I know this is outside of "Veeam box", but does your network equipment have the ability to set any QoS rules or policies? If so, it might be a better and far simpler option to just tag Veeam traffic on the WAN as "bulk" and then it will use the bandwidth available but everything else will always get priority.
tomkai
Lurker
Posts: 1
Liked: never
Joined: Nov 12, 2012 3:55 pm
Full Name: Thomas Kaiser
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by tomkai »

Hello,

i would also rise this feature request to set Network traffic rules with power Shell. We have to set this rule for about 50 remote Locations and this would darmatically Speed up this process.
odruard
Enthusiast
Posts: 40
Liked: 5 times
Joined: Jan 25, 2011 2:12 pm
Full Name: Olivier Druard
Contact:

Configure network throttling

Post by odruard »

Hello

I'm looking for a way to configure network throttling rules using Powershell.
We'll need to configure tens of rules on several Veeam B&R servers, and it would be kind to script it.

I found this topic which says that throttling rules are not configurable via PowerShell.
powershell-f26/backup-proxy-traffic-thr ... 31732.html
However, according to the date, the answer was for Veeam B&R v8.

Did the v9 or the v9.5 came with new cmdlets allowing to configure network throttling rules ?

Thanks for your help.
Olivier.
veremin
Product Manager
Posts: 20261
Liked: 2249 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by veremin »

Unfortunately, those settings cannot be configured via PowerShell. Thanks.
toasty
Lurker
Posts: 1
Liked: never
Joined: Feb 07, 2017 9:30 pm
Full Name: Randy Lucas
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by toasty »

Is there any way to at least see what the throttle settings are via PowerShell? I don't need to change them (though that would be nice), but I would like to be able to setup a notification if our throttle settings are changed.
tsightler
VP, Product Management
Posts: 6003
Liked: 2840 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by tsightler » 2 people like this post

There is no cmdlet to do this, however, it is possible to get creative by calling the underlying .NET methods. For example, getting the existing rules is very easy:

Code: Select all

$ttr = [Veeam.Backup.Core.SBackupOptions]::GetTrafficThrottlingRules().GetRules()
After running this command $ttr will hold an array with all of the rules. But you can do more, the GetTrafficThrottlingRules() method returns a nice object that can be easily manipulated to add/remove rules, here's an example of adding a new rule to the existing ruleset (it should work even if the ruleset is empty):

Code: Select all

# Get existing traffic throttling rules
$ttr = [Veeam.Backup.Core.SBackupOptions]::GetTrafficThrottlingRules()

# Add a new default traffic throttling rule to existing rules
$nttr = $ttr.AddRule()

# Set options for the new traffic throttling rule
$nttr.SpeedLimit = 10
$nttr.SpeedUnit = "Mbps" # Options are Mbps, KBps, MBps
$nttr.AlwaysEnabled = $true
$nttr.EncryptionEnabled = $false
$nttr.ThrottlingEnabled = $true
$nttr.SetScheduleInfo($nttr.GetScheduleInfo())
$nttr.FirstDiapason.FirstIp = "192.168.10.1"
$nttr.FirstDiapason.LastIp = "192.168.10.255"
$nttr.SecondDiapason.FirstIp = "192.168.20.1"
$nttr.SecondDiapason.LastIp = "192.168.20.255"

# Save new traffic throttiling rules
[Veeam.Backup.Core.SBackupOptions]::SaveTrafficThrottlingRules($ttr)
Deleting a rule is pretty easy as well:

Code: Select all

# Get existing traffic throttling rules
$ttr = [Veeam.Backup.Core.SBackupOptions]::GetTrafficThrottlingRules()

# Find all rules where the source match would include this IP address
$ttr_to_delete = $ttr.GetRulesByFirstDiapason("192.168.0.1")

# Delete these rules
if ($ttr_to_delete) {
    foreach ($rule in $ttr_to_delete) {
        $ttr.RemoveRule($rule)
    }
}

# Save new traffic throttling rules
[Veeam.Backup.Core.SBackupOptions]::SaveTrafficThrottlingRules($ttr)
You can also search by target IP (GetRulesBySecondDiapason) and there are some other search criteria as well, but you can also just pipe and filter on any property of the rules. Of course, all of these methods are "unsupported" since we're calling directly into the backend code, but I tried to use the functions in the same ways the GUI would, and it seems to work OK in quick testing. Obviously it would be better to have supported cmdlets to do this, but sometimes you gotta do what you gotta do and this has come up often enough for me that I have these hacks lying around.
odruard
Enthusiast
Posts: 40
Liked: 5 times
Joined: Jan 25, 2011 2:12 pm
Full Name: Olivier Druard
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by odruard »

Interesting.
I'll try your solution.
Thanks for the trick.
murdocmk
Enthusiast
Posts: 25
Liked: 4 times
Joined: Dec 14, 2009 5:10 pm
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by murdocmk »

We had a situation where we needed to generate throttling rules for 3 schedules (with different throttling rates) for 80-100 different IP ranges (remote sites). Because the sites were in different time zones we found that adding the throttling rules manually was time-consuming and error prone.

This is the script we used, which we wrapped in a powershell loop to generate the rules. We created a file that defined a site name, 2nd octet of the IP, GMT offset and bandwidth (in KBps) settings for 3 different schedules: weekday, evenings and weekends. Example file format:

Site1 50 -6 128 256 384
Site2 51 8 128 256 256

Then with a loop like this we can iterate the various entries in the file and run the script:

Code: Select all

$sites = Import-CSV -Delimiter "`t" -Header sitename,ip,offset,bw1,bw2,bw3 -Path .\sites.txt
foreach ($site in $sites) { 
  Adding rules for site: " + $site.sitename;
  .\add-throttle.ps1 -SiteIP $site.ip -Offset $site.offset -DayBW $site.bw1 -EveningBW $site.bw2 -WeekendBW $site.bw3
}
And then, the script, which is largely based on tshightler's code example (thank you), but adds the 7AM - 5PM weekday, evening and weekend schedules (adjusted to be in local time for the site):

Code: Select all

param (
[Parameter(Mandatory=$true)]
[String] $SiteIP,
[Parameter(Mandatory=$true)]
[string] $Offset,
[Parameter(Mandatory=$true)]
[string] $DayBW,
[Parameter(Mandatory=$true)]
[string] $EveningBW,
[Parameter(Mandatory=$true)]
[string] $WeekendBW
)

Add-PSSnapin VeeamPSSnapin

Connect-VBRServer -Server MYSERVER.MYDOMAIN.COM

$gmt_weekdays = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
$gmt_evenings = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
$gmt_weekends = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

function weekdays($offset) {
    # Slide the array by the GMT offset
    $newarr = @()
    if($offset -gt 0) {
        $newarr = $gmt_weekdays[$offset..(($gmt_weekdays.count) - 1)] + $gmt_weekdays[0..($offset - 1)]
    }
    Elseif($offset -lt 0) {
        $newarr = $gmt_weekdays[$offset..-1] + $gmt_weekdays[0..($gmt_weekdays.count - 1 + $offset)]
    }
    Else {
        $newarr = $gmt_weekdays
    }
    $return = "<scheduler><Sunday>" + ($newarr[0..23] -join ",") + "</Sunday>" + "<Monday>" + ($newarr[24..47] -join ",") + "</Monday>" +
        "<Tuesday>" + ($newarr[48..71] -join ",") + "</Tuesday>" + "<Wednesday>" + ($newarr[72..95] -join ",") + "</Wednesday>" +
        "<Thursday>" + ($newarr[96..119] -join ",") + "</Thursday>" + "<Friday>" + ($newarr[120..143] -join ",") + "</Friday>" +
        "<Saturday>" + ($newarr[144..167] -join ",") + "</Saturday></scheduler>"

    return $return
}

function evenings($offset) {
    # Slide the array by the GMT offset
    $newarr = @()
    if($offset -gt 0) {
        $newarr = $gmt_evenings[$offset..(($gmt_evenings.count) - 1)] + $gmt_evenings[0..($offset - 1)]
    }
    Elseif($offset -lt 0) {
        $newarr = $gmt_evenings[$offset..-1] + $gmt_evenings[0..($gmt_evenings.count - 1 + $offset)]
    }
    Else {
        $newarr = $gmt_evenings
    }
    $return = "<scheduler><Sunday>" + ($newarr[0..23] -join ",") + "</Sunday>" + "<Monday>" + ($newarr[24..47] -join ",") + "</Monday>" +
        "<Tuesday>" + ($newarr[48..71] -join ",") + "</Tuesday>" + "<Wednesday>" + ($newarr[72..95] -join ",") + "</Wednesday>" +
        "<Thursday>" + ($newarr[96..119] -join ",") + "</Thursday>" + "<Friday>" + ($newarr[120..143] -join ",") + "</Friday>" +
        "<Saturday>" + ($newarr[144..167] -join ",") + "</Saturday></scheduler>"

    return $return
}

function weekends($offset) {
    # Slide the array by the GMT offset
    $newarr = @()
    if($offset -gt 0) {
        $newarr = $gmt_weekends[$offset..(($gmt_weekends.count) - 1)] + $gmt_weekends[0..($offset - 1)]
    }
    Elseif($offset -lt 0) {
        $newarr = $gmt_weekends[$offset..-1] + $gmt_weekends[0..($gmt_weekends.count - 1 + $offset)]
    }
    Else {
        $newarr = $gmt_weekends
    }
    $return = "<scheduler><Sunday>" + ($newarr[0..23] -join ",") + "</Sunday>" + "<Monday>" + ($newarr[24..47] -join ",") + "</Monday>" +
        "<Tuesday>" + ($newarr[48..71] -join ",") + "</Tuesday>" + "<Wednesday>" + ($newarr[72..95] -join ",") + "</Wednesday>" +
        "<Thursday>" + ($newarr[96..119] -join ",") + "</Thursday>" + "<Friday>" + ($newarr[120..143] -join ",") + "</Friday>" +
        "<Saturday>" + ($newarr[144..167] -join ",") + "</Saturday></scheduler>"

    return $return
}

$ttr = [Veeam.Backup.Core.SBackupOptions]::GetTrafficThrottlingRules()
#$rules = $ttr.GetRules()

# We'll be creating 3 rules for 3 different schedules
$nttr1 = $ttr.AddRule()
$nttr2 = $ttr.AddRule()
$nttr3 = $ttr.AddRule()

# Set options for the new traffic throttling rule
$nttr1.SpeedLimit = $DayBW;
$nttr1.SpeedUnit = "KBps" # Options are Mbps, KBps, MBps
$nttr1.AlwaysEnabled = $false
$nttr1.EncryptionEnabled = $false
$nttr1.ThrottlingEnabled = $true
$nttr1.ScheduleInfoStr = weekdays($Offset)
$nttr1.FirstDiapason.FirstIp = "10." + $SiteIP + ".0.0"
$nttr1.FirstDiapason.LastIp = "10." + $SiteIP + ".255.255"
$nttr1.SecondDiapason.FirstIp = "10.0.0.0"
$nttr1.SecondDiapason.LastIp = "10.255.255.255"

$nttr2.SpeedLimit = $EveningBW
$nttr2.SpeedUnit = "KBps" # Options are Mbps, KBps, MBps
$nttr2.AlwaysEnabled = $false
$nttr2.EncryptionEnabled = $false
$nttr2.ThrottlingEnabled = $true
$nttr2.ScheduleInfoStr = evenings($Offset)
$nttr2.FirstDiapason.FirstIp = "10." + $SiteIP + ".0.0"
$nttr2.FirstDiapason.LastIp = "10." + $SiteIP + ".255.255"
$nttr2.SecondDiapason.FirstIp = "10.0.0.0"
$nttr2.SecondDiapason.LastIp = "10.255.255.255"

$nttr3.SpeedLimit = $WeekendBW
$nttr3.SpeedUnit = "KBps" # Options are Mbps, KBps, MBps
$nttr3.AlwaysEnabled = $false
$nttr3.EncryptionEnabled = $false
$nttr3.ThrottlingEnabled = $true
$nttr3.ScheduleInfoStr = weekends($Offset)
$nttr3.FirstDiapason.FirstIp = "10." + $SiteIP + ".0.0"
$nttr3.FirstDiapason.LastIp = "10." + $SiteIP + ".255.255"
$nttr3.SecondDiapason.FirstIp = "10.0.0.0"
$nttr3.SecondDiapason.LastIp = "10.255.255.255"

# Save new traffic throttiling rules
[Veeam.Backup.Core.SBackupOptions]::SaveTrafficThrottlingRules($ttr)

Disconnect-VBRServer
I'm going to clean that up some and combine the weekday/evening/weekend functions into a single function, but I wanted to get it out here for others to use while I was thinking of it. Hope it helps someone get over a couple of hurdles that I had to, a little quicker.
signal
Enthusiast
Posts: 65
Liked: 4 times
Joined: Oct 06, 2016 1:19 pm
Contact:

[MERGED] Powershell to enable network encryption

Post by signal »

Hello

Is it possible to use powershell to add a network traffic rule and enable encryption on it?

In GUI one would do it like this: https://helpcenter.veeam.com/docs/backu ... tml?ver=95
I can't find any cmdlets that look like they might do that.
veremin
Product Manager
Posts: 20261
Liked: 2249 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by veremin »

Try the workaround suggested above. Thanks.
signal
Enthusiast
Posts: 65
Liked: 4 times
Joined: Oct 06, 2016 1:19 pm
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by signal »

Thank you.

If I set first IP to 0.0.0.0 and second ip to 255.255.255.255, will that work to always have encryption enabled?
veremin
Product Manager
Posts: 20261
Liked: 2249 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by veremin »

It should as long as you set $True value for a corresponding property (EncryptionEnabled = $True). By the way, if you're concerned with traffic leaving your environment and want to have it encrypted, be aware that we encrypt it automatically without any rules specified. Thanks.
signal
Enthusiast
Posts: 65
Liked: 4 times
Joined: Oct 06, 2016 1:19 pm
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by signal »

v.Eremin wrote:It should as long as you set $True value for a corresponding property (EncryptionEnabled = $True). By the way, if you're concerned with traffic leaving your environment and want to have it encrypted, be aware that we encrypt it automatically without any rules specified. Thanks.
I work with some customers who are concerned with security, and adding network encryption to their backup would probably not be a bad thing.
veremin
Product Manager
Posts: 20261
Liked: 2249 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by veremin »

Sure, then, setting $True value for EncryptionEnabled property is a way to go indeed. Thanks.
signal
Enthusiast
Posts: 65
Liked: 4 times
Joined: Oct 06, 2016 1:19 pm
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by signal »

v.Eremin wrote:It should as long as you set $True value for a corresponding property (EncryptionEnabled = $True). By the way, if you're concerned with traffic leaving your environment and want to have it encrypted, be aware that we encrypt it automatically without any rules specified. Thanks.
In powershell this works fine, but when using gui the IP's are invalid. I tried changing to 0.0.0.1 to 255.255.255.254 but this is still wrong. Since I add this by using powershell there would be no problem do some looping and add several rules if needed, but what are valid ranges?
oleg.feoktistov
Veeam Software
Posts: 1901
Liked: 634 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Backup Proxy Traffic Throttling Rules

Post by oleg.feoktistov » 2 people like this post

Just if somebody encounters this thread seeking for a solution - cmdlets for network traffic rules configuration are available since B&R 9.5 U4 version:
https://helpcenter.veeam.com/docs/backu ... l?ver=95u4
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests