|
From: Mehrdad R. <meh...@am...> - 2025-04-07 06:04:50
|
Hi Bill
Thanks for your reponse, lots of info there!
I am actualy trying to do this via a bash script which i am trying to
run by putting it in the mail command, I am saying trying because so far
It has not been working. Running Bacula in debug mode gives a
"permission denied" although i have changed everything on the script,
from setting owner-group to file permissions, but seems there is more to
do here
The python script u mentioned is gret alternative, i'll look for it
Regards /Mehrdad
On 2025-04-06 07:05, Bill Arlofski via Bacula-users wrote:
> On 4/1/25 6:58 AM, Mehrdad Ravanbod wrote:
>> Hi Guys
>>
>> I have managed to gt the mail notifications working on my Bacula
>> installation, but I seem to have encountered a problem
>>
>> I don't want to get a notification for successful jobs only on jobs that
>> fail(get an error) and jobs that do complete but with warnings
>>
>> The first one is easy, just using MailOnError keyword, BUT there is no
>> keyword command for warnings and MailOnError does not generate an email
>> for these jobs
>>
>> has anyone managed to do this, i.e get a mail notification for jobs that
>> do complete but with warning(with out turning on mail for all jobs)??
>>
>> Regards /Mehrdad
>
> Hello Mehrdad,
>
> As you have discovered, there is no such setting/option/feature.
>
> The reason for this is as follows:
>
> In the catalog, a `jobstatus` of "W" was considered very early on in
> the development of Bacula, and, in some hard-coded queries where the
> goal is to select Good Jobs (Termination: Backup OK), o
> r Good jobs with warnings (Termination: Backup OK -- with warnings),
> there is an "AND jobstatus IN ('T', 'W')" clause.
>
> However, the "W" has never been implemented in any code that inserts
> or modifies the Job table's jobstatus field, so you will never find a
> "W" in this field for any job - unless you manually set it. :)
>
> Here is the "status" table in the bacula catalog database where we can
> see that a jobstatus of "W: Terminated normally with warnings" exists:
> ----8<----
> # sudo -u bacula psql bacula
> psql (17.2)
> Type "help" for help.
>
> bacula=> select * from status;
> jobstatus | jobstatuslong | severity
> -----------+-----------------------------------+----------
> C | Created, not yet running | 15
> R | Running | 15
> B | Blocked | 15
> T | Completed successfully | 10
> E | Terminated with errors | 25
> e | Non-fatal error | 20
> f | Fatal error | 100
> D | Verify found differences | 15
> A | Canceled by user | 90
> F | Waiting for Client | 15
> S | Waiting for Storage daemon | 15
> m | Waiting for new media |
> M | Waiting for media mount | 15
> s | Waiting for storage resource | 15
> j | Waiting for job resource | 15
> c | Waiting for client resource | 15
> d | Waiting on maximum jobs | 15
> t | Waiting on start time | 15
> p | Waiting on higher priority jobs | 15
> a | SD despooling attributes | 15
> i | Doing batch insert file records | 15
> I | Incomplete Job | 25
> l | Doing data desp
> ooling | 15
> L | Committing data (last despool) | 15
> u | Cloud upload | 15
> w | Cloud download | 15
> q | Queued waiting for device | 15
> W | Terminated normally with warnings | 25 <------ Here
> (28 rows)
> ----8<----
>
> The way for you to accomplish what you are looking for would be with a
> small script that your `mailcommand` would call (instead of calling
> the bsmtp binary), and in that script is where you would make the
> decisions on when to send an email or not, and where to send it.
>
> A quick idea would be to pass the script the jobid, and other things
> you would want to use on the email subject line of any emails that get
> sent, as well as the entire log text (which is passed automatically
> via stdin, I believe...)
>
> Then, the simplest way to make the determination of who and when to
> send an email without any database queries is to do a
> simple string comparison on the Job's Summary line `Termination: xxxxxx`
>
> Doing something like this would then take all the responsibility about
> where and when to send emails away from Bacula, and put it in the
> script based on the decisions it makes.
>
> This would then also remove the need for using `mailonerror` etc in
> your Messages resources...
>
>
> Alternatively, if you do not need to send job logs with specific
> termination statuses to different places, and have someone read and
> deal with every email that Bacula sends, you might want to take a look
> at the "Bacula Backup Report" Python script that I wrote and have
> released to the open-source community for free.
>
> It is quite customizable, and when run via cron each morning, it sends
> an HTML email summarizing all of your jobs in the past (default) 24
> hours.
>
> You can even have cron trigger it multiple times each morning, each
> time using different settings from the config file so that each
> morning you can have differe
> nt reports, based on different criteria, sent to different
> people/teams. Your boss will be happy to always get email reports of
> all GOOD jobs. :) But seriously, as a real example, you might have an
> "all jobs with errors or which failed" email report be sent to a team
> that would need to deal with these issues.
>
> The latest version of the script (baculabackupreport.py) may be found
> on my Github account here: https://github.com/waa
>
>
> Good luck,
> Bill
>
>
>
> _______________________________________________
> Bacula-users mailing list
> Bac...@li...
> https://lists.sourceforge.net/lists/listinfo/bacula-users
--
________________________________________________________
Ampfield Aktiebolag
Mehrdad Ravanbod
System administrator
|