Re: Limit Bandwidth of Incremental backups only

Bill Arlofski via Bacula-users <[email protected]>
Newsgroups gmane.comp.bacula.user
Message-ID <[email protected]>
On 2/13/25 2:59 PM, [email protected] wrote:
> I've used bacula for years and it's always figured out the correct Level of job to run if there are multiple scheduled.  That 
> may have to do with these settings as well:
> 
> Allow Duplicate Jobs = no
> Cancel Lower Level Duplicates = yes
> Cancel Queued Duplicates = yes
> Cancel Running Duplicates = no
> 
> Thanks for your insights.  The Schedule resource is documented <https://www.bacula.org/15.0.x-manuals/en/main/ 
> Configuring_Director.html#blb:ScheduleResource> to allow a small set of <job-overrides>^
> 
> Job-overrides are specified as: keyword=value where the keyword is Level, Storage, Messages, Pool, FullPool, 
> DifferentialPool, or IncrementalPool, and the value is as defined on the respective directive formats for the Job resource.
> 
> in a Run line, but unfortunately Maximum Bandwidth is not one.  I'm not sure there's a way to accomplish this even with the 
> limited set of overrides available, unless someone can think of something creative with the available overrides.
> 

Here's an idea. 💡

In your Job, configure two RunScripts sections. One before and one after.

Have a small script that takes the current jobid and the level.

If the level is "limit", set bandwidth to xxxx, if the level is "unlimited", set the bandwidth on the jobid to 0.


Job {
   Name = xxxxx

   [...all other Job settings...]

   RunScript {
     RunsWhen = before
     RunsOnClient = no
     FailJobOnError = no
     Command = "/path/to/bandwidth_control.sh %j %l"
   }

   RunScript {
     RunsWhen = after
     RunsOnClient = no
     FailJobOnError = no
     Command = "/path/to/bandwidth_control.sh %j %l"
   }
}

/path/to/bandwidth_control.sh:
----8<----
#!/bin/bash

# Set some variables
# ------------------
bandwidth=xxxx
bcbin=/opt/bacula/bin/bconsole
bccfg=/opt/bacula/etc/bconsole.conf

# Parameters passed to the script
# -------------------------------
# Job is $1
# Level is $2

if [ $2 = "Incremental" ]; then
   /usr/bin/echo "Job level: $2. Limiting bandwidth to ${bandwidth}."
   echo -e "setbandwidth jobid=$1 limit=${bandwidth}\nquit\n" | ${bcbin} -c ${bccfg}
else
   /usr/bin/echo "Job level: $2. Setting bandwidth to unlimited."
   echo -e "setbandwidth jobid=$1 limit=0\nquit\n" | ${bcbin} -c ${bccfg}
fi
----8<----

I just whipped this up in my email client, so I have not tested for errors, but this should do exactly what you want.

Additionally, there is zero error checking, so you might want to add some, at least to check that the right number of 
parameters is sent to the script.


Hope this helps,
Bill

-- 
Bill Arlofski
[email protected]

_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users
signature.asc (application/pgp-signature, 509 B)
-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wsBzBAEBCAAnBQJnrnCeCRBIDTDab9XDQBYhBMuLnlBaSQiuSUbb6UgNMNpv
1cNAAACu2Af9FGnXSHHnZX8J+GEgJkSYS5WgN8mAaINtja8WCHC5qs5dZ6qm
nxZB5bCL5QwPTHqW5kSXbZ/Jz9kxaamMGDQjaPh0JUBKSNdEAYcVGy/clD1e
a8oT08iMDHrq37gCsrQAUfjfEy6NDGOBP4Rz6oCezUYRYSKjpj7NARXUNoxD
eaGeZCXib3IRIu3adDoFntznWrO8YyFLawvTkzStNH4dyhjrewNalp18WWfB
kIpnJyfc6mf25A3j3+OISV/NhqXoUh7n1+P++M9lIpRk8kaxQr4Z6igZT7t0
HubmiOgwkYo47Qa69rea7KL8FNegUUtBdHn123VeFU/h7ZFHD3Xnbw==
=Wbs3
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.