Bacula-users

Re: [Bacula-users] Bacula Email Confirmation

2010-10-27 21:03:32
Subject: Re: [Bacula-users] Bacula Email Confirmation
From: Bill Arlofski <waa-bacula AT revpol DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Wed, 27 Oct 2010 20:32:13 -0400
On 10/27/10 09:04, Mark Gordon wrote:
> Hello all I'm using Bacula 5.02 and find it very useful. However is
> there a way to include in the email notification that the job completed
> ok to list all the files that were sent to the storage. Ex when under
> ./bconsole
>
> list files jobid=316 | more


Hi Mark... Well, since the mailcommand can be just about anything you want you
can do something like this:

In the Standard Messages block you can change the "mailcommand" from a simple
call to Bacula's bsmtp with variable replacement:

mailcommand = "/usr/sbin/bsmtp -h server.example.com -f \"Example-Server
Bacula \<%r\>\" -s 'Servername - %t %e - %n JobId=%i Level=%l' %r"


instead to something like:


mailcommand = "/path/to/full/email/script.sh %r %t %e %n %i %l"


Then create a script /path/to/full/email/script.sh that has this sort of logic:

--[snip]--
#!/bin/bash
#
# Variable substitutions from Bacula documentation
# ------------------------------------------------
# %% = %
# %c = Client's name
# %d = Director's name
# %e = Job Exit code (OK, Error, ...)
# %i = Job Id
# %j = Unique Job name
# %l = Job level
# %n = Job name
# %r = Recipients
# %t = Job type (e.g. Backup, ...)
# ------------------------------------------------

filelist=`echo "list files jobid=$5" | bconsole`

echo "$filelist" | sendmail -s 'Servername - $2 $3 - $4 JobId=$5 Level=$6' $1

--[snip]--


A couple of things to keep in mind.

1. I wrote this quickly to try and point you in the right direction and didn't
dig too deeply to get the "console output" that is normally sent in the email.
This is the block that shows the time-stamped log messages as well as the
start time, end time, elapsed time, bytes etc.   That would be great to have
in one email along with the file list you asked for. Maybe someone can add to
this exchange so that that we can pull that info can in too.

2. The email can easily become HUGE if you include the listing of files as
described above.   Use with caution. :)

3. Since I wrote this quickly you may need to verify the order of my variables. 
:)

4. You may not have "sendmail" or a symlink called sendmail on your system, so
you may need to substitute that with  "mailx" or another local minimal MTA
that you do have installed.


Hope this helps a little.


--
Bill Arlofski
Reverse Polarity, LLC
http://www.revpol.com/

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

<Prev in Thread] Current Thread [Next in Thread>