]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/main/messagesres.tex
Fix description of Volume Retention -- bug 1844
[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{verbatim}
89     %% = %
90     %b = Job Bytes
91     %c = Client's name
92     %d = Daemon's name (Such as host-dir or host-fd)
93     %D = Director's name (Also valid on file daemon)
94     %e = Job Exit Status
95     %f = Job FileSet (Only on director side)
96     %F = Job Files
97     %h = Client address
98     %i = JobId
99     %j = Unique Job id
100     %l = Job Level
101     %n = Job name
102     %p = Pool name (Only on director side)
103     %P = Current PID process
104     %r = Recipients
105     %s = Since time
106     %t = Job type (Backup, ...)
107     %v = Volume name (Only on director side)
108     %w = Storage name (Only on director side)
109     %x = Spooling enabled? ("yes" or "no")
110 \end{verbatim}
111
112 Please note: any {\bf MailCommand} directive must be specified 
113 in the {\bf Messages} resource {\bf before} the desired
114 {\bf Mail}, {\bf MailOnSuccess}, or {\bf MailOnError}
115 directive. In fact, each of those directives may be preceded by
116 a different {\bf MailCommand}.
117
118 The following is an exampl. Note, the whole  command should
119 appear on a single line in the configuration file  rather than split as is
120 done here for presentation:  
121
122 {\bf mailcommand = "/home/kern/bacula/bin/bsmtp -h mail.example.com -f
123 \textbackslash{}"\textbackslash{}(Bacula\textbackslash{})
124 \%r\textbackslash{}" -s \textbackslash{}"Bacula: \%t \%e of \%c
125 \%l\textbackslash{}" \%r"}
126
127 The {\bf bsmtp} program is provided as part of {\bf Bacula}.  For
128 additional details, please see the 
129 \borgxrlink{bsmtp -- Customizing Your Email Messages}{bsmtp}{utility}{section} of
130 the  Bacula Utility Programs chapter of this manual. Please test any  {\bf
131 mailcommand} that you use to ensure that your bsmtp gateway accepts  the
132 addressing form that you use. Certain programs such as Exim can be very 
133 selective as to what forms are permitted particularly in the from part.  
134
135 \item [OperatorCommand = \lt{}command\gt{}]
136 \index[fd]{OperatorCommand}
137    This resource specification is  similar to the {\bf MailCommand} except that
138    it is used for Operator  messages. The substitutions performed for the {\bf
139    MailCommand} are  also done for this command. Normally, you will set this
140    command to the  same value as specified for the {\bf MailCommand}. 
141    The {\bf OperatorCommand} directive must appear in the {\bf Messages}
142    resource before the {\bf Operator} directive.
143
144 \item [\lt{}destination\gt{} = \lt{}message-type1\gt{},
145    \lt{}message-type2\gt{}, ...]
146    \index[fd]{\lt{}destination\gt{}}
147
148 Where {\bf destination} may be one of the following:  
149
150 \begin{description}
151
152 \item [stdout]
153    \index[fd]{stdout}
154    Send the message to standard output.  
155
156 \item [stderr]
157    \index[fd]{stderr}
158    Send the message to standard error.  
159
160 \item [console]
161    \index[console]{console}
162    Send the message to the console (Bacula Console).  These messages are held
163 until the console program  connects to the Director.  
164 \end{description}
165
166 \item {\bf \lt{}destination\gt{} = \lt{}address\gt{} =
167    \lt{}message-type1\gt{}, \lt{}message-type2\gt{}, ...}
168    \index[console]{\lt{}destination\gt{}}
169
170 Where {\bf address} depends on the {\bf destination}. 
171
172 The {\bf destination} may be one of the following:  
173
174 \begin{description}
175
176 \item [director]
177    \index[dir]{director}
178    \index[general]{director}
179    Send the message to the Director whose name  is given in the {\bf address}
180    field. Note, in the current  implementation, the Director Name is ignored, and
181    the message  is sent to the Director that started the Job.  
182
183 \item [file]
184 \index[dir]{file}
185 \index[general]{file}
186    Send the message to the filename given in  the {\bf address} field. If the
187    file already exists, it will be  overwritten.  
188
189 \item [append]
190 \index[dir]{append}
191 \index[general]{append}
192    Append the message to the filename given  in the {\bf address} field. If the
193    file already exists, it will  be appended to. If the file does not exist, it
194    will be created.  
195
196 \item [syslog]
197 \index[general]{syslog}
198    Send the message to the system log (syslog)  using the facility specified in
199    the {\bf address} field.  Note, for the moment, the {\bf address} field is
200    ignored  and the message is always sent to the LOG\_DAEMON facility with
201    level LOG\_ERR. See {\bf man 3 syslog} for more details. Example:
202
203 \begin{verbatim}
204    syslog = all, !skipped
205 \end{verbatim}
206
207    Although the {\bf syslog} destination is not used in the default Bacula
208    config files, in certain cases where Bacula encounters errors in trying
209    to deliver a message, as a last resort, it will send it to the system
210    {\bf syslog} to prevent loss of the message, so you might occassionally
211    check the {\bf syslog} for Bacula output (normally {\bf
212    /var/log/syslog}).
213
214 \item [mail]
215    \index[general]{mail}
216    Send the message to the email addresses that are given as a comma
217    separated list in the {\bf address} field.  Mail messages are grouped
218    together during a job and then sent as a single email message when the
219    job terminates.  The advantage of this destination is that you are
220    notified about every Job that runs.  However, if you backup five or ten
221    machines every night, the volume of email messages can be important.
222    Some users use filter programs such as {\bf procmail} to automatically
223    file this email based on the Job termination code (see {\bf
224    mailcommand}).
225
226 \item [mail on error]
227    \index[general]{mail on error}
228    Send the message to the email addresses that are given as a comma
229    separated list in the {\bf address} field if the Job terminates with an
230    error condition.  MailOnError messages are grouped together during a job
231    and then sent as a single email message when the job terminates.  This
232    destination differs from the {\bf mail} destination in that if the Job
233    terminates normally, the message is totally discarded (for this
234    destination).  If the Job terminates in error, it is emailed.  By using
235    other destinations such as {\bf append} you can ensure that even if the
236    Job terminates normally, the output information is saved.
237
238 \item [mail on success]
239    \index[general]{mail on success}
240    Send the message to the email addresses that are given as a comma
241    separated list in the {\bf address} field if the Job terminates
242    normally (no error condition).  MailOnSuccess messages are grouped
243    together during a job and then sent as a single email message when the
244    job terminates.  This destination differs from the {\bf mail}
245    destination in that if the Job terminates abnormally, the message is
246    totally discarded (for this destination).  If the Job terminates
247    normally, it is emailed.
248
249 \item [operator]
250    \index[general]{operator}
251    Send the message to the email addresses that are specified as a comma
252    separated list in the {\bf address} field.  This is similar to {\bf
253    mail} above, except that each message is sent as received.  Thus there
254    is one email per message.  This is most useful for {\bf mount} messages
255    (see below).  
256
257 \item [console]
258   \index[general]{console}
259   Send the message to the Bacula console.
260
261 \item [stdout]
262   \index[general]{stdout}
263   Send the message to the standard output (normally not used).
264
265 \item [stderr]
266   \index[general]{stderr}
267   Send the message to the standard error output (normally not used).
268
269 \item [catalog]
270    \index[general]{catalog}
271    Send the message to the Catalog database. The message will be
272    written to the table named {\bf Log} and a timestamp field will
273    also be added. This permits Job Reports and other messages to
274    be recorded in the Catalog so that they can be accessed by
275    reporting software.  Bacula will prune the Log records associated
276    with a Job when the Job records are pruned.  Otherwise, Bacula 
277    never uses these records internally, so this destination is only
278    used for special purpose programs (e.g. {\bf bweb}).
279
280 \end{description}
281
282    For any destination, the {\bf message-type} field is a comma separated
283    list of the following types or classes of messages:
284
285 \begin{description}
286
287 \item [info]
288    \index[general]{info}
289    General information messages.  
290
291 \item [warning]
292    \index[general]{warning}
293    Warning messages. Generally this is some  unusual condition but not expected
294    to be serious. 
295
296 \item [error]
297    \index[general]{error}
298    Non-fatal error messages. The job continues running.  Any error message should
299    be investigated as it means that something  went wrong.  
300
301 \item [fatal]
302    \index[general]{fatal}
303    Fatal error messages. Fatal errors cause the  job to terminate.  
304
305 \item [terminate]
306    \index[general]{terminate}
307    Message generated when the daemon shuts down.  
308
309 \item [notsaved]
310    \index[fd]{notsaved}
311    \index[general]{notsaved}
312    Files not saved because of some error.  Usually because the file cannot be
313    accessed (i.e. it does not  exist or is not mounted).  
314
315 \item [skipped]
316    \index[fd]{skipped}
317    \index[general]{skipped}
318    Files that were skipped because of a user supplied option such as an
319    incremental backup or a file that matches an exclusion pattern.  This is
320    not considered an error condition such as the files listed for the {\bf
321    notsaved} type because the configuration file explicitly requests these
322    types of files to be skipped.  For example, any unchanged file during an
323    incremental backup, or any subdirectory if the no recursion option is
324    specified.
325
326 \item [mount]
327    \index[dir]{mount}
328    \index[general]{mount}
329    Volume mount or intervention requests from the Storage daemon.  These
330    requests require a specific operator intervention for the job to
331    continue.
332
333 \item [restored]
334    \index[fd]{restored}
335    \index[general]{restored}
336    The {\bf ls} style listing generated for each file restored is sent to
337    this message class.
338
339 \item [all]
340    \index[general]{all}
341    All message types.  
342
343 \item [security]
344    \index[general]{security}
345    Security info/warning messages principally from unauthorized      
346    connection attempts.
347
348 \item [alert]
349    \index[general]{alert}
350    Alert messages. These are messages generated by tape alerts.
351
352 \item [volmgmt]
353    \index[general]{volmgmt}
354    Volume management messages. Currently there are no volume mangement
355    messages generated.
356 \end{description}
357
358 \end{description}
359
360 The following is an example of a valid Messages resource definition, where
361 all messages except files explicitly skipped or daemon termination messages
362 are sent by email to enforcement@sec.com.  In addition all mount messages
363 are sent to the operator (i.e.  emailed to enforcement@sec.com).  Finally
364 all messages other than explicitly skipped files and files saved are sent
365 to the console:
366
367 \footnotesize
368 \begin{verbatim}
369 Messages {
370   Name = Standard
371   mail = enforcement@sec.com = all, !skipped, !terminate
372   operator = enforcement@sec.com = mount
373   console = all, !skipped, !saved
374 }
375 \end{verbatim}
376 \normalsize
377
378 With the exception of the email address (changed to avoid junk mail from
379 robot's), an example Director's Messages resource is as follows. Note, the {\bf
380 mailcommand} and {\bf operatorcommand} are on a single line -- they had to be
381 split for this manual: 
382
383 \footnotesize
384 \begin{verbatim}
385 Messages {
386   Name = Standard
387   mailcommand = "bacula/bin/bsmtp -h mail.example.com \
388     -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
389   operatorcommand = "bacula/bin/bsmtp -h mail.example.com \
390     -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed \
391         for %j\" %r"
392   MailOnError = security@example.com = all, !skipped, \
393                 !terminate
394   append = "bacula/bin/log" = all, !skipped, !terminate
395   operator = security@example.com = mount
396   console = all, !skipped, !saved
397 }
398 \end{verbatim}
399 \normalsize