]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/main/messagesres.tex
Fix typo reported by James
[bacula/docs] / docs / manuals / en / main / messagesres.tex
1 %%
2 %%
3
4 \chapter{Messages Resource}
5 \label{MessagesChapter}
6 \index[general]{Resource!Messages}
7 \index[general]{Messages Resource}
8
9 The Messages resource defines how messages are to be handled and destinations
10 to which they should be sent. 
11
12 Even though each daemon has a full message handler, within the File daemon and
13 the Storage daemon, you will normally choose to send all the appropriate
14 messages back to the Director.  This permits all the messages associated with
15 a single Job to be combined in the Director and sent as a single email message
16 to the user, or logged together in a single file.
17
18 Each message that Bacula generates (i.e. that each daemon generates) has an
19 associated type such as INFO, WARNING, ERROR, FATAL, etc. Using the message
20 resource, you can specify which message types you wish to see and where they
21 should be sent. In addition, a message may be sent to multiple destinations.
22 For example, you may want all error messages both logged as well as sent to
23 you in an email. By defining multiple messages resources, you can have
24 different message handling for each type of Job (e.g. Full backups versus
25 Incremental backups). 
26
27 In general, messages are attached to a Job and are included in the Job report.
28 There are some rare cases, where this is not possible, e.g. when no job is
29 running, or if a communications error occurs between a daemon and the
30 director. In those cases, the message may remain in the system, and should be
31 flushed at the end of the next Job. However, since such messages are not
32 attached to a Job, any that are mailed will be sent to {\bf
33 /usr/lib/sendmail}. On some systems, such as FreeBSD, if your sendmail is in a
34 different place, you may want to link it to the the above location. 
35
36 The records contained in a Messages resource consist of a {\bf destination}
37 specification followed by a list of {\bf message-types} in the format: 
38
39 \begin{description}
40
41 \item [destination = message-type1, message-type2, message-type3, ...  ]
42 \index[dir]{destination}
43 \end{description}
44
45 or for those destinations that need and address specification (e.g. email): 
46
47 \begin{description}
48
49 \item [destination = address = message-type1, message-type2,
50    message-type3, ...  ]
51 \index[dir]{destination}
52
53    Where {\bf destination} is one of a predefined set of keywords that define
54    where the message is to be sent ({\bf stdout}, {\bf file}, ...), {\bf
55    message-type} is one of a predefined set of keywords that define the type of
56    message generated by {\bf Bacula} ({\bf ERROR}, {\bf WARNING}, {\bf FATAL},
57    ...), and {\bf address} varies according to the {\bf destination} keyword, but
58    is typically an email address or a filename. 
59 \end{description}
60
61 The following are the list of the possible record definitions that can be used
62 in a message resource. 
63
64 \begin{description}
65
66 \item [Messages]
67 \index[dir]{Messages}
68    Start of the Messages records.  
69
70 \item [Name = \lt{}name\gt{}]
71 \index[dir]{Name}
72    The name of the Messages resource.  The name you specify here will be used to
73    tie this Messages  resource to a Job and/or to the daemon.  
74
75 \label{mailcommand}
76 \item [MailCommand = \lt{}command\gt{}]
77 \index[dir]{MailCommand}
78    In the absence of this resource,  Bacula will send all mail using the
79    following command:  
80
81 {\bf mail -s "Bacula Message" \lt{}recipients\gt{}}  
82
83 In many cases, depending on your machine, this command may not work.  
84 However, by using the {\bf MailCommand}, you can specify exactly how to
85 send the mail.  During the processing of the {\bf command} part, normally
86 specified as a quoted string, the following substitutions will be used:
87
88 \begin{itemize}
89 \item \%\% = \%  
90 \item \%c = Client's name  
91 \item \%d = Director's name  
92 \item \%e = Job Exit code (OK, Error, ...)  
93 \item \%h = Client address
94 \item \%i = Job Id  
95 \item \%j = Unique Job name  
96 \item \%l = Job level  
97 \item \%n = Job name  
98 \item \%r = Recipients  
99 \item \%s = Since time
100 \item \%t = Job type (e.g. Backup, ...)  
101 \item \%v = Volume name (Only on director side)
102 \end{itemize}
103
104 Please note: any {\bf MailCommand} directive must be specified 
105 in the {\bf Messages} resource {\bf before} the desired
106 {\bf Mail}, {\bf MailOnSuccess}, or {\bf MailOnError}
107 directive. In fact, each of those directives may be preceded by
108 a different {\bf MailCommand}.
109
110 The following is the command I (Kern) use. Note, the whole  command should
111 appear on a single line in the configuration file  rather than split as is
112 done here for presentation:  
113
114 {\bf mailcommand = "/home/kern/bacula/bin/bsmtp -h mail.example.com -f
115 \textbackslash{}"\textbackslash{}(Bacula\textbackslash{})
116 \%r\textbackslash{}" -s \textbackslash{}"Bacula: \%t \%e of \%c
117 \%l\textbackslash{}" \%r"}
118
119 The {\bf bsmtp} program is provided as part of {\bf Bacula}.  For
120 additional details, please see the 
121 \ilink{ bsmtp -- Customizing Your Email Messages}{bsmtp} section of
122 the  Bacula Utility Programs chapter of this manual. Please test any  {\bf
123 mailcommand} that you use to ensure that your bsmtp gateway accepts  the
124 addressing form that you use. Certain programs such as Exim can be very 
125 selective as to what forms are permitted particularly in the from part.  
126
127 \item [OperatorCommand = \lt{}command\gt{}]
128 \index[fd]{OperatorCommand}
129    This resource specification is  similar to the {\bf MailCommand} except that
130    it is used for Operator  messages. The substitutions performed for the {\bf
131    MailCommand} are  also done for this command. Normally, you will set this
132    command to the  same value as specified for the {\bf MailCommand}. 
133    The {\bf OperatorCommand} directive must appear in the {\bf Messages}
134    resource before the {\bf Operator} directive.
135
136 \item [\lt{}destination\gt{} = \lt{}message-type1\gt{},
137    \lt{}message-type2\gt{}, ...]
138    \index[fd]{\lt{}destination\gt{}}
139
140 Where {\bf destination} may be one of the following:  
141
142 \begin{description}
143
144 \item [stdout]
145    \index[fd]{stdout}
146    Send the message to standard output.  
147
148 \item [stderr]
149    \index[fd]{stderr}
150    Send the message to standard error.  
151
152 \item [console]
153    \index[console]{console}
154    Send the message to the console (Bacula Console).  These messages are held
155 until the console program  connects to the Director.  
156 \end{description}
157
158 \item {\bf \lt{}destination\gt{} = \lt{}address\gt{} =
159    \lt{}message-type1\gt{}, \lt{}message-type2\gt{}, ...}
160    \index[console]{\lt{}destination\gt{}}
161
162 Where {\bf address} depends on the {\bf destination}. 
163
164 The {\bf destination} may be one of the following:  
165
166 \begin{description}
167
168 \item [director]
169    \index[dir]{director}
170    \index[general]{director}
171    Send the message to the Director whose name  is given in the {\bf address}
172    field. Note, in the current  implementation, the Director Name is ignored, and
173    the message  is sent to the Director that started the Job.  
174
175 \item [file]
176 \index[dir]{file}
177 \index[general]{file}
178    Send the message to the filename given in  the {\bf address} field. If the
179    file already exists, it will be  overwritten.  
180
181 \item [append]
182 \index[dir]{append}
183 \index[general]{append}
184    Append the message to the filename given  in the {\bf address} field. If the
185    file already exists, it will  be appended to. If the file does not exist, it
186    will be created.  
187
188 \item [syslog]
189 \index[general]{syslog}
190    Send the message to the system log (syslog)  using the facility specified in
191    the {\bf address} field.  Note, for the moment, the {\bf address} field is
192    ignored  and the message is always sent to the LOG\_DAEMON facility with
193    level LOG\_ERR. See {\bf man 3 syslog} for more details. Example:
194
195 \begin{verbatim}
196    syslog = all, !skipped
197 \end{verbatim}
198
199    Although the {\bf syslog} destination is not used in the default Bacula
200    config files, in certain cases where Bacula encounters errors in trying
201    to deliver a message, as a last resort, it will send it to the system
202    {\bf syslog} to prevent loss of the message, so you might occassionally
203    check the {\bf syslog} for Bacula output (normally {\bf
204    /var/log/syslog}).
205
206 \item [mail]
207    \index[general]{mail}
208    Send the message to the email addresses that are given as a comma
209    separated list in the {\bf address} field.  Mail messages are grouped
210    together during a job and then sent as a single email message when the
211    job terminates.  The advantage of this destination is that you are
212    notified about every Job that runs.  However, if you backup five or ten
213    machines every night, the volume of email messages can be important.
214    Some users use filter programs such as {\bf procmail} to automatically
215    file this email based on the Job termination code (see {\bf
216    mailcommand}).
217
218 \item [mail on error]
219    \index[general]{mail on error}
220    Send the message to the email addresses that are given as a comma
221    separated list in the {\bf address} field if the Job terminates with an
222    error condition.  MailOnError messages are grouped together during a job
223    and then sent as a single email message when the job terminates.  This
224    destination differs from the {\bf mail} destination in that if the Job
225    terminates normally, the message is totally discarded (for this
226    destination).  If the Job terminates in error, it is emailed.  By using
227    other destinations such as {\bf append} you can ensure that even if the
228    Job terminates normally, the output information is saved.
229
230 \item [mail on success]
231    \index[general]{mail on success}
232    Send the message to the email addresses that are given as a comma
233    separated list in the {\bf address} field if the Job terminates
234    normally (no error condition).  MailOnSuccess messages are grouped
235    together during a job and then sent as a single email message when the
236    job terminates.  This destination differs from the {\bf mail}
237    destination in that if the Job terminates abnormally, the message is
238    totally discarded (for this destination).  If the Job terminates
239    normally, it is emailed.
240
241 \item [operator]
242    \index[general]{operator}
243    Send the message to the email addresses that are specified as a comma
244    separated list in the {\bf address} field.  This is similar to {\bf
245    mail} above, except that each message is sent as received.  Thus there
246    is one email per message.  This is most useful for {\bf mount} messages
247    (see below).  
248
249 \item [console]
250   \index[general]{console}
251   Send the message to the Bacula console.
252
253 \item [stdout]
254   \index[general]{stdout}
255   Send the message to the standard output (normally not used).
256
257 \item [stderr]
258   \index[general]{stderr}
259   Send the message to the standard error output (normally not used).
260
261 \item [catalog]
262    \index[general]{catalog}
263    Send the message to the Catalog database. The message will be
264    written to the table named {\bf Log} and a timestamp field will
265    also be added. This permits Job Reports and other messages to
266    be recorded in the Catalog so that they can be accessed by
267    reporting software.  Bacula will prune the Log records associated
268    with a Job when the Job records are pruned.  Otherwise, Bacula 
269    never uses these records internally, so this destination is only
270    used for special purpose programs (e.g. {\bf bweb}).
271
272 \end{description}
273
274    For any destination, the {\bf message-type} field is a comma separated
275    list of the following types or classes of messages:
276
277 \begin{description}
278
279 \item [info]
280    \index[general]{info}
281    General information messages.  
282
283 \item [warning]
284    \index[general]{warning}
285    Warning messages. Generally this is some  unusual condition but not expected
286    to be serious. 
287
288 \item [error]
289    \index[general]{error}
290    Non-fatal error messages. The job continues running.  Any error message should
291    be investigated as it means that something  went wrong.  
292
293 \item [fatal]
294    \index[general]{fatal}
295    Fatal error messages. Fatal errors cause the  job to terminate.  
296
297 \item [terminate]
298    \index[general]{terminate}
299    Message generated when the daemon shuts down.  
300
301 \item [notsaved]
302    \index[fd]{notsaved}
303    \index[general]{notsaved}
304    Files not saved because of some error.  Usually because the file cannot be
305    accessed (i.e. it does not  exist or is not mounted).  
306
307 \item [skipped]
308    \index[fd]{skipped}
309    \index[general]{skipped}
310    Files that were skipped because of a user supplied option such as an
311    incremental backup or a file that matches an exclusion pattern.  This is
312    not considered an error condition such as the files listed for the {\bf
313    notsaved} type because the configuration file explicitly requests these
314    types of files to be skipped.  For example, any unchanged file during an
315    incremental backup, or any subdirectory if the no recursion option is
316    specified.
317
318 \item [mount]
319    \index[dir]{mount}
320    \index[general]{mount}
321    Volume mount or intervention requests from the Storage daemon.  These
322    requests require a specific operator intervention for the job to
323    continue.
324
325 \item [restored]
326    \index[fd]{restored}
327    \index[general]{restored}
328    The {\bf ls} style listing generated for each file restored is sent to
329    this message class.
330
331 \item [all]
332    \index[general]{all}
333    All message types.  
334
335 \item [security]
336    \index[general]{security}
337    Security info/warning messages principally from unauthorized      
338    connection attempts.
339
340 \item [alert]
341    \index[general]{alert}
342    Alert messages. These are messages generated by tape alerts.
343
344 \item [volmgmt]
345    \index[general]{volmgmt}
346    Volume management messages. Currently there are no volume mangement
347    messages generated.
348 \end{description}
349
350 \end{description}
351
352 The following is an example of a valid Messages resource definition, where
353 all messages except files explicitly skipped or daemon termination messages
354 are sent by email to enforcement@sec.com.  In addition all mount messages
355 are sent to the operator (i.e.  emailed to enforcement@sec.com).  Finally
356 all messages other than explicitly skipped files and files saved are sent
357 to the console:
358
359 \footnotesize
360 \begin{verbatim}
361 Messages {
362   Name = Standard
363   mail = enforcement@sec.com = all, !skipped, !terminate
364   operator = enforcement@sec.com = mount
365   console = all, !skipped, !saved
366 }
367 \end{verbatim}
368 \normalsize
369
370 With the exception of the email address (changed to avoid junk mail from
371 robot's), an example Director's Messages resource is as follows. Note, the {\bf
372 mailcommand} and {\bf operatorcommand} are on a single line -- they had to be
373 split for this manual: 
374
375 \footnotesize
376 \begin{verbatim}
377 Messages {
378   Name = Standard
379   mailcommand = "bacula/bin/bsmtp -h mail.example.com \
380     -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
381   operatorcommand = "bacula/bin/bsmtp -h mail.example.com \
382     -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed \
383         for %j\" %r"
384   MailOnError = security@example.com = all, !skipped, \
385                 !terminate
386   append = "bacula/bin/log" = all, !skipped, !terminate
387   operator = security@example.com = mount
388   console = all, !skipped, !saved
389 }
390 \end{verbatim}
391 \normalsize