]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/concepts/newfeatures.tex
ebl fix typo
[bacula/docs] / docs / manuals / en / concepts / newfeatures.tex
1 %%
2 %%
3
4 \chapter{New Features}
5 \label{NewFeaturesChapter}
6 \index[general]{New Features}
7
8 This chapter presents the new features added to the development 2.5.x
9 versions to be released as Bacula version 3.0.0 near the end of 2008.
10
11 \section{Accurate Backup}
12 \index[general]{Accurate Backup}
13
14 As with most other backup programs, by default Bacula decides what files to backup for
15 Incremental and Differental backup by comparing the change (st\_ctime) and
16 modification (st\_mtime) times of the file to the time the last backup
17 completed.  If one of those two times is later than the last backup time,
18 then the file will be backed up.  This does not, however, permit tracking what
19 files have been deleted and will miss any file with an old time that may have
20 been restored to or moved onto the client filesystem.
21
22 \subsection{Accurate = \lt{}yes|no\gt{}}
23 If the {\bf Accurate = \lt{}yes|no\gt{}} directive is enabled (default no) in
24 the Job resource, the job will be run as an Accurate Job. For a {\bf Full}
25 backup, there is no difference, but for {\bf Differential} and {\bf
26   Incremental} backups, the Director will send a list of all previous files
27 backed up, and the File daemon will use that list to determine if any new files
28 have been added or or moved and if any files have been deleted. This allows
29 Bacula to make an accurate backup of your system to that point in time so that
30 if you do a restore, it will restore your system exactly.  One note of caution
31 about using Accurate backup is that it requires more resources (CPU and memory)
32 on both the Director and the Client machines to create the list of previous
33 files backed up, to send that list to the File daemon, for the File daemon to
34 keep the list (possibly very big) in memory, and for the File daemon to do
35 comparisons between every file in the FileSet and the list.
36
37
38 \section{Copy Jobs}
39 \index[general]{Copy Jobs}
40 A new {\bf Copy} job type has been implemented. It is essentially
41 identical to the existing Migration feature with the exception that
42 the Job that is copied is left unchanged.  This essentially creates
43 two identical copies of the same backup.  The Copy Job runs without
44 using the File daemon by copying the data from the old backup Volume to
45 a different Volume in a different Pool. See the Migration documentation
46 for additional details.
47
48 \section{Shared objects}
49 A default build of Bacula will now create the libraries as shared objects
50 (.so) rather than static libraries as was previously the case.  
51 The shared libraries are built using {\bf libtool} so it should be quite
52 portable.
53
54 An important advantage of using shared objects is that on a machine with the
55 Directory, File daemon, the Storage daemon, and a console, you will have only one copy
56 of the code in memory rather than four copies.  Also the total size of the
57 binary release is smaller since the library code appears only once rather than
58 once for every program that uses it; this results in significant reduction in
59 the size of the binaries particularly for the utility tools.
60  
61 In order for the system loader to find the shared objects when loading
62 the Bacula binaries, the Bacula shared objects must either be in a shared object
63 directory known to the loader (typically /usr/lib) or they must be in the directory
64 that may be specified on the {\bf ./configure} line using the
65 {\bf {-}{-}libdir} option as:
66
67 \begin{verbatim}
68   ./configure --libdir=/full-path/dir
69 \end{verbatim}
70
71 the default is /usr/lib. If {-}{-}libdir is specified, there should be
72 no need to modify your loader configuration provided that
73 the shared objects are installed in that directory (Bacula
74 does this with the make install command). The shared objects
75 that Bacula references are:
76
77 \begin{verbatim}
78 libbaccfg.so
79 libbacfind.so
80 libbacpy.so
81 libbac.so
82 \end{verbatim}
83
84 These files are symbolically linked to the real shared object file,
85 which has a version number to permit running multiple versions of
86 the libraries if desired (not normally the case).
87
88 If you have problems with libtool or you wish to use the old
89 way of building static libraries, you can do so by disabling
90 libtool on the configure command line with:
91
92 \begin{verbatim}
93   ./configure --disable-libtool
94 \end{verbatim}
95
96
97 \section{Virtual Backup (Vbackup)}
98 \index[general]{Virtual Backup}
99 \index[general]{Vbackup}
100
101 Bacula's virtual backup feature is often called Synthetic Backup or
102 Consolidation in other backup products.  It permits you to consolidate
103 the previous Full backup plus the most recent Differential backup and any
104 subsequent Incremental backups into a new Full backup. This is accomplished
105 without contacting the client by reading the previous backup data and 
106 writing it to a volume in a different pool.  
107
108 In some respects the Vbackup feature works similar to a Migration job, in
109 that Bacula normally reads the data from the pool specified in the 
110 Job resource, and writes it to the {\bf Next Pool} specified in the 
111 Job resource.  The input Storage resource and the Output Storage resource
112 must be different.
113
114 The Vbackup is enabled on a Job by Job in the Job resource by specifying
115 a level of {\bf VirtualFull}.
116
117 A typical Job resource definition might look like the following:
118
119 \begin{verbatim}
120 Job {
121   Name = "MyBackup"
122   Type = Backup
123   Client=localhost-fd
124   FileSet = "Full Set"
125   Storage = File
126   Messages = Standard
127   Pool = Default
128   SpoolData = yes
129 }
130
131 # Default pool definition
132 Pool {
133   Name = Default
134   Pool Type = Backup
135   Recycle = yes            # Automatically recycle Volumes
136   AutoPrune = yes          # Prune expired volumes
137   Volume Retention = 365d  # one year
138   NextPool = Full
139   Storage = File
140 }
141
142 Pool {
143   Name = Full
144   Pool Type = Backup
145   Recycle = yes            # Automatically recycle Volumes
146   AutoPrune = yes          # Prune expired volumes
147   Volume Retention = 365d  # one year
148   Storage = DiskChanger
149 }
150
151 # Definition of file storage device
152 Storage {
153   Name = File
154   Address = localhost
155   Password = "xxx"
156   Device = FileStorage
157   Media Type = File
158   Maximum Concurrent Jobs = 5
159 }
160
161 # Definition of DDS Virtual tape disk storage device
162 Storage {
163   Name = DiskChanger
164   Address = localhost  # N.B. Use a fully qualified name here
165   Password = "yyy"
166   Device = DiskChanger
167   Media Type = DiskChangerMedia
168   Maximum Concurrent Jobs = 4
169   Autochanger = yes
170 }
171 \end{verbatim}
172
173 Then in bconsole or via a Run schedule, you would run the job as:
174
175 \begin{verbatim}
176 run job=MyBackup level=Full
177 run job=MyBackup level=Incremental
178 run job=MyBackup level=Differential
179 run job=MyBackup level=Incremental
180 run job=MyBackup level=Incremental
181 \end{verbatim}
182
183 So providing there were changes between each of those jobs, you would end up
184 with a Full backup, a Differential, which includes the first Incremental
185 backup, then two Incremental backups.  All the above jobs would be written to
186 the {\bf Default} pool.
187
188 To consolidate those backups into a new Full backup, you would run the
189 following:
190
191 \begin{verbatim}
192 run job=MyBackup level=VirtualFull
193 \end{verbatim}
194
195 And it would produce a new Full backup without using the client, and the output
196 would be written to the {\bf Full} Pool which uses the Diskchanger Storage.
197
198 If the Virtual Full is run, and there are no prior Jobs, the Virtual Full will
199 fail with an error.
200
201 \section{Duplicate Job Control}
202 \index[general]{Duplicate Jobs}
203 The new version of Bacula provides four new directives that
204 give additional control over what Bacula does if duplicate jobs 
205 are started.  A duplicate job in the sense we use it here means
206 a second or subsequent job with the same name starts.  This
207 happens most frequently when the first job runs longer than expected because no 
208 tapes are available.
209
210 The four directives each take as an argument a {\bf yes} or {\bf no} value and
211 are specified in the Job resource.
212
213 They are:
214
215 \subsection{Allow Duplicate Jobs = \lt{}yes|no\gt{}}
216   If this directive is enabled duplicate jobs will be run.  If
217   the directive is set to {\bf no} (default) then only one job of a given name
218   may run at one time, and the action that Bacula takes to ensure only
219   one job runs is determined by the other directives (see below).
220
221 \subsection{Allow Higher Duplicates = \lt{}yes|no\gt{}}
222   If this directive is set to {\bf yes} (default) the job with a higher
223   priority (lower priority number) will be permitted to run.  If the
224   priorities of the two jobs are the same, the outcome is determined by
225   other directives (see below).
226
227 \subsection{Cancel Queued Duplicates = \lt{}yes|no\gt{}}
228   If this directive is set to {\bf yes} (default) any job that is
229   already queued to run but not yet running will be canceled.
230
231 \subsection{Cancel Running Duplicates = \lt{}yes|no\gt{}}
232   If this directive is set to {\bf yes} any job that is already running
233   will be canceled.  The default is {\bf no}.
234
235
236 \section{TLS Authentication}
237 \index[general]{TLS Authentication}
238 In Bacula version 2.5.x and later, in addition to the normal Bacula
239 CRAM-MD5 authentication that is used to authenticate each Bacula
240 connection, you can specify that you want TLS Authentication as well,
241 which will provide more secure authentication.
242
243 This new feature uses Bacula's existing TLS code (normally used for
244 communications encryption) to do authentication.  To use it, you must
245 specify all the TLS directives normally used to enable communications
246 encryption (TLS Enable, TLS Verify Peer, TLS Certificate, ...) and
247 a new directive:
248
249 \subsection{TLS Authenticate = yes}
250 \begin{verbatim}
251 TLS Authenticate = yes
252 \end{verbatim}
253
254 in the main daemon configuration resource (Director for the Director,
255 Client for the File daemon, and Storage for the Storage daemon).
256
257 When {\bf TLS Authenticate} is enabled, after doing the CRAM-MD5
258 authentication, Bacula will do the normal TLS authentication, then TLS 
259 encryption will be turned off.
260
261 If you want to encrypt communications data, do not turn on {\bf TLS
262 Authenticate}.
263
264 \section{bextract non-portable Win32 data}
265 \index[general]{bextract handles Win32 non-portable data}
266 {\bf bextract} has been enhanced to be able to restore
267 non-portable Win32 data to any OS.  Previous versions were 
268 unable to restore non-portable Win32 data to machines that
269 did not have the Win32 BackupRead and BackupWrite API calls.
270
271 \section{State File updated at Job Termination}
272 \index[general]{State File}
273 In previous versions of Bacula, the state file, which provides a
274 summary of previous jobs run in the {\bf status} command output was
275 updated only when Bacula terminated, thus if the daemon crashed, the
276 state file might not contain all the run data.  This version of
277 the Bacula daemons updates the state file on each job termination.
278
279 \section{MaxFullInterval = \lt{}time-interval\gt{}}
280 \index[general]{MaxFullInterval}
281 The new Job resource directive {\bf Max Full Interval = \lt{}time-interval\gt{}}
282 can be used to specify the maximum time interval between {\bf Full} backup
283 jobs. When a job starts, if the time since the last Full backup is
284 greater than the specified interval, and the job would normally be an
285 {\bf Incremental} or {\bf Differential}, it will be automatically
286 upgraded to a {\bf Full} backup.
287
288 \section{MaxDiffInterval = \lt{}time-interval\gt{}}
289 \index[general]{MaxDiffInterval}
290 The new Job resource directive {\bf Max Diff Interval = \lt{}time-interval\gt{}}
291 can be used to specify the maximum time interval between {\bf Differential} backup
292 jobs. When a job starts, if the time since the last Differential backup is
293 greater than the specified interval, and the job would normally be an
294 {\bf Incremental}, it will be automatically
295 upgraded to a {\bf Differential} backup.
296
297 \section{Honor No Dump Flag = \lt{}yes|no\gt{}}
298 \index[general]{MaxDiffInterval}
299 On FreeBSD systems, each file has a {\bf no dump flag} that can be set
300 by the user, and when it is set it is an indication to backup programs
301 to not backup that particular file.  This version of Bacula contains a
302 new Options directive within a FileSet resource, which instructs Bacula to
303 obey this flag.  The new directive is:
304
305 \begin{verbatim}
306   Honor No Dump Flag = yes|no
307 \end{verbatim}
308
309 The default value is {\bf no}.
310
311
312 \section{Exclude Dirs Containing = \lt{}filename-string\gt{}}
313 \index[general]{IgnoreDir}
314 The {\bf ExcludeDirsContaining = \lt{}filename\gt{}} is a new directive that can be added to the Include
315 section of the FileSet resource.  If the specified
316 filename is found on the Client in any directory to be backed up, 
317 the whole directory will be ignored (not backed up).
318 For example:
319
320 \begin{verbatim}
321   # List of files to be backed up
322   FileSet {
323     Name = "MyFileSet"
324     Include {
325       Options {
326         signature = MD5
327       }
328       File = /home
329       Exclude Dirs Containing = .excludeme
330     }
331   }
332 \end{verbatim}
333
334 But in /home, there may be hundreds of directories of users and some
335 people want to indicate that they don't want to have certain
336 directories backed up. For example, with the above FileSet, if
337 the user or sysadmin creates a file named {\bf .excludeme} in 
338 specific directories, such as
339
340 \begin{verbatim}
341    /home/user/www/cache/.excludeme
342    /home/user/temp/.excludeme
343 \end{verbatim}
344
345 then Bacula will not backup the two directories named:
346
347 \begin{verbatim}
348    /home/user/www/cache
349    /home/user/temp
350 \end{verbatim}
351
352 NOTE: subdirectories will not be backed up.  That is, the directive
353 applies to the two directories in question and any children (be they
354 files, directories, etc).
355
356
357
358 \section{Bacula Plugins}
359 \index[general]{Plugin}
360 Support for shared object plugins has been implemented in the Linux
361 (and Unix) File daemon. The API will be documented separately in
362 the Developer's Guide or in a new document.  For the moment, there is
363 a single plugin named {\bf bpipe} that allows an external program to
364 get control to backup and restore a file.
365
366 Plugins are also planned (partially implemented) in the Director and the
367 Storage daemon.  The code is also implemented to work on Win32 machines, 
368 but it has not yet been tested.
369
370 \subsection{Plugin Directory}
371 Each daemon (DIR, FD, SD) has a new {\bf Plugin Directory} directive that may
372 be added to the daemon definition resource. The directory takes a quoted 
373 string argument, which is the name of the directory in which the daemon can
374 find the Bacula plugins. If this directive is not specified, Bacula will not
375 load any plugins. Since each plugin has a distinctive name, all the daemons
376 can share the same plugin directory. 
377
378
379
380 \subsection{Plugin Options}
381 The {\bf Plugin Options} directive takes a quoted string
382 arguement (after the equal sign) and may be specified in the
383 Job resource.  The options specified will be passed to the plugin
384 when it is run.  The value defined in the Job resource can be modified
385 by the user when he runs a Job via the {\bf bconsole} command line 
386 prompts.
387
388 Note: this directive may be specified, but it is not yet passed to
389 the plugin (i.e. not fully implemented).
390
391 \subsection{Plugin Options ACL}
392 The {\bf Plugin Options ACL} directive may be specified in the
393 Director's Console resource. It functions as all the other ACL commands
394 do by permitting users running restricted consoles to specify a 
395 {\bf Plugin Options} that overrides the one specified in the Job
396 definition. Without this directive restricted consoles may not modify
397 the Plugin Options.
398
399 \subsection{Plugin = \lt{}plugin-command-string\gt{}}
400 The {\bf Plugin} directive is specified in the Include section of
401 a FileSet resource where you put your {\bf File = xxx} directives.
402 For example:
403
404 \begin{verbatim}
405   FileSet {
406     Name = "MyFileSet"
407     Include {
408       Options {
409         signature = MD5
410       }
411       File = /home
412       Plugin = "bpipe:..."
413     }
414   }
415 \end{verbatim}
416
417 In the above example, when the File daemon is processing the directives
418 in the Include section, it will first backup all the files in {\bf /home}
419 then it will load the plugin named {\bf bpipe} (actually bpipe-dir.so) from
420 the Plugin Directory.  The syntax and semantics of the Plugin directive
421 require the first part of the string up to the colon (:) to be the name
422 of the plugin. Everything after the first colon is ignored by the File daemon but
423 is passed to the plugin. Thus the plugin writer may define the meaning of the
424 rest of the string as he wishes.
425
426 Please see the next section for information about the {\bf bpipe} Bacula
427 plugin.
428
429 \section{The bpipe Plugin}
430 The {\bf bpipe} plugin is provided in the directory src/plugins/fd/bpipe-fd.c of
431 the Bacula source distribution. When the plugin is compiled and linking into
432 the resulting dynamic shared object (DSO), it will have the name {\bf bpipe-fd.so}.
433
434 The purpose of the plugin is to provide an interface to any system program for
435 backup and restore. As specified above the {\bf bpipe} plugin is specified in
436 the Include section of your Job's FileSet resource.  The full syntax of the
437 plugin directive as interpreted by the {\bf bpipe} plugin (each plugin is free
438 to specify the sytax as it wishes) is:
439
440 \begin{verbatim}
441   Plugin = "<field1>:<field2>:<field3>:<field4>"
442 \end{verbatim}
443
444 where
445 \begin{description}
446 \item {\bf field1} is the name of the plugin with the trailing {\bf -fd.so}
447 stripped off, so in this case, we would put {\bf bpipe} in this field.
448
449 \item {\bf field2} specifies the namespace, which for {\bf bpipe} is the
450 pseudo path and filename under which the backup will be saved. This pseudo
451 path and filename will be seen by the user in the restore file tree.
452 For example, if the value is {\bf /MYSQL/regress.sql}, the data
453 backed up by the plugin will be put under that "pseudo" path and filename.
454 You must be careful to choose a naming convention that is unique to avoid
455 a conflict with a path and filename that actually exists on your system.
456
457 \item {\bf field3} for the {\bf bpipe} plugin 
458 specifies the "reader" program that is called by the plugin during
459 backup to read the data. {\bf bpipe} will call this program by doing a
460 {\bf popen} on it.
461
462 \item {\bf field4} for the {\bf bpipe} plugin
463 specifies the "writer" program that is called by the plugin during
464 restore to write the data back to the filesystem.  
465 \end{description}
466
467 Putting it all together, the full plugin directive line might look
468 like the following:
469
470 \begin{verbatim}
471 Plugin = "bpipe:/MYSQL/regress.sql:mysqldump -f 
472           --opt --databases bacula:mysql"
473 \end{verbatim}
474
475 The directive has been split into two lines, but within the {\bf bacula-dir.conf} file
476 would be written on a single line.
477
478 This causes the File daemon to call the {\bf bpipe} plugin, which will write
479 its data into the "pseudo" file {\bf /MYSQL/regress.sql} by calling the 
480 program {\bf mysqldump -f --opt --database bacula} to read the data during
481 backup. The mysqldump command outputs all the data for the database named
482 {\bf bacula}, which will be read by the plugin and stored in the backup.
483 During restore, the data that was backed up will be sent to the program
484 specified in the last field, which in this case is {\bf mysql}.  When
485 {\bf mysql} is called, it will read the data sent to it by the plugn
486 then write it back to the same database from which it came ({\bf bacula}
487 in this case).
488
489 The {\bf bpipe} plugin is a generic pipe program, that simply transmits 
490 the data from a specified program to Bacula for backup, and then from Bacula to 
491 a specified program for restore.
492
493 By using different command lines to {\bf bpipe},
494 you can backup any kind of data (ASCII or binary) depending
495 on the program called.
496
497 \section{Microsoft Exchange Server 2003/2007 Plugin}
498
499 \subsection{Concepts}
500
501 Although it is possible to backup Exchange using Bacula VSS the Exchange 
502 plugin adds a good deal of functionality, because while Bacula VSS
503 completes a full backup (snapshot) of Exchange, it does
504 not support Incremental or Differential backups, restoring is more
505 complicated, and a single database restore is not possible.
506
507 Microsoft Exchange organises its storage into Storage Groups with
508 Databases inside them. A default installation of Exchange will have a
509 single Storage Group called 'First Storage Group', with two Databases
510 inside it, "Mailbox Store (SERVER NAME)" and 
511 "Public Folder Store (SERVER NAME)", 
512 which hold user email and public folders respectively.
513
514 In the default configuration, Exchange logs everything that happens to
515 log files, such that if you have a backup, and all the log files since,
516 you can restore to the present time. Each Storage Group has its own set
517 of log files and operates independently of any other Storage Groups. At
518 the Storage Group level, the logging can be turned off by enabling a
519 function called "Enable circular logging". At this time the Exchange
520 plugin will not function if this option is enabled.
521
522 The plugin allows backing up of entire storage groups, and the restoring
523 of entire storage groups or individual databases. Backing up and
524 restoring at the individual mailbox or email item is not supported but
525 can be simulated by use of the "Recovery" Storage Group (see below).
526
527 \subsection{Installing}
528
529 The Exchange plugin requires a DLL that is shipped with Microsoft
530 Exchanger Server called {\bf esebcli2.dll}. Assuming Exchange is installed
531 correctly the Exchange plugin should find this automatically and run
532 without any additional installation.
533
534 If the DLL can not be found automatically it will need to be copied into
535 the Bacula installation
536 directory (eg C:\verb+\+Program Files\verb+\+Bacula\verb+\+bin). The Exchange API DLL is
537 named esebcli2.dll and is found in C:\verb+\+Program Files\verb+\+Exchsrvr\verb+\+bin on a
538 default Exchange installation.
539
540 \subsection{Backup up}
541
542 To back up an Exchange server the Fileset definition must contain at
543 least {\bf Plugin = "exchange:/@EXCHANGE/Microsoft Information Store"} for
544 the backup to work correctly. The 'exchange:' bit tells Bacula to look
545 for the exchange plugin, the '@EXCHANGE' bit makes sure all the backed
546 up files are prefixed with something that isn't going to share a name
547 with something outside the plugin, and the 'Microsoft Information Store'
548 bit is required also. It is also possible to add the name of a storage
549 group to the "Plugin =" line, eg \\
550 {\bf Plugin = "exchange:/@EXCHANGE/Microsoft Information Store/First Storage Group"} \\
551 if you want only a single storage group backed up.
552
553 Additionally, you can suffix the 'Plugin =' directive with
554 ":notrunconfull" which will tell the plugin not to truncate the Exchange
555 database at the end of a full backup.
556
557 An Incremental or Differential backup will backup only the database logs
558 for each Storage Group by inspecting the "modified date" on each
559 physical log file. Because of the way the Exchange API works, the last
560 logfile backed up on each backup will always be backed up by the next
561 Incremental or Differential backup too. This adds 5MB to each
562 Incremental or Differential backup size but otherwise does not cause any
563 problems.
564
565 By default, a normal VSS fileset containing all the drive letters will
566 also back up the Exchange databases using VSS. This will interfere with
567 the plugin and Exchange's shared ideas of when the last full backup was
568 done, and may also truncate log files incorrectly. It is important,
569 therefore, that the Exchange database files be excluded from the backup,
570 although the folders the files are in should be included, or they will
571 have to be recreated manually if a baremetal restore is done.
572
573 \begin{verbatim}
574 FileSet {
575    Include {
576       File = C:/Program Files/Exchsrvr/mdbdata
577       Plugin = "exchange:..."
578    }
579    Exclude {
580       File = C:/Program Files/Exchsrvr/mdbdata/E00.chk
581       File = C:/Program Files/Exchsrvr/mdbdata/E00.log
582       File = C:/Program Files/Exchsrvr/mdbdata/E000000F.log
583       File = C:/Program Files/Exchsrvr/mdbdata/E0000010.log
584       File = C:/Program Files/Exchsrvr/mdbdata/E0000011.log
585       File = C:/Program Files/Exchsrvr/mdbdata/E00tmp.log
586       File = C:/Program Files/Exchsrvr/mdbdata/priv1.edb
587    }
588 }
589 \end{verbatim}
590
591 The advantage of excluding the above files is that you can significantly
592 reduce the size of your backup since all the important Exchange files
593 will be properly saved by the Plugin.
594
595
596 \subsection{Restoring}
597
598 The restore operation is much the same as a normal Bacula restore, with
599 the following provisos:
600
601 \begin{itemize}
602 \item  The {\bf Where} restore option must not be specified
603 \item Each Database directory must be marked as a whole. You cannot just
604      select (say) the .edb file and not the others.
605 \item If a Storage Group is restored, the directory of the Storage Group
606      must be marked too.
607 \item  It is possible to restore only a subset of the available log files,
608      but they {\bf must} be contiguous. Exchange will fail to restore correctly
609      if a log file is missing from the sequence of log files
610 \item Each database to be restored must be dismounted and marked as "Can be
611     overwritten by restore"
612 \item If an entire Storage Group is to be restored (eg all databases and
613    logs in the Storage Group), then it is best to manually delete the
614    database files from the server (eg C:\verb+\+Program Files\verb+\+Exchsrvr\verb+\+mdbdata\verb+\+*)
615    as Exchange can get confused by stray log files lying around.
616 \end{itemize}
617
618 \subsection{Restoring to the Recovery Storage Group}
619
620 The concept of the Recovery Storage Group is well documented by
621 Microsoft 
622 \elink{http://support.microsoft.com/kb/824126}{http://support.microsoft.com/kb/824126}, 
623 but to briefly summarize...
624
625 Microsoft Exchange allows the creation of an additional Storage Group
626 called the Recovery Storage Group, which is used to restore an older
627 copy of a database (e.g. before a mailbox was deleted) into without
628 messing with the current live data. This is required as the Standard and
629 Small Business Server versions of Exchange can not ordinarily have more
630 than one Storage Group.
631
632 To create the Recovery Storage Group, drill down to the Server in
633 Exchange System Manager, right click, and select 
634 {\bf "New -> Recovery Storage Group..."}. Accept or change the file locations and click OK. On
635 the Recovery Storage Group, right click and select 
636 {\bf "Add Database to Recover..."} and select the database you will be restoring.
637
638 In Bacula, select the Database and the log files, making sure to mark
639 the Storage Group directory itself too. Once you have selected the files
640 to back up, use the RegexWhere clause to remove the prefix of
641 "/@EXCHANGE/Microsoft Information Store/\lt{}storage group name\gt{}/" and
642 replace it with "/@EXCHANGE/Microsoft Information Store/Recovery Storage Group/". 
643 Then run the restore.
644
645 \subsection{Caveats}
646
647 This plugin is still being developed, so you should consider it
648 currently in BETA test, and thus use in a production environment
649 should be done only after very careful testing.
650
651 The "Enable Circular Logging" option cannot be enabled or the plugin
652 will fail.
653
654 Exchange insists that a successful Full backup must have taken place if
655 an Incremental or Differential backup is desired, and the plugin will
656 fail if this is not the case. If a restore is done, Exchange will
657 require that a Full backup be done before an Incremental or Differential
658 backup is done.
659
660 The plugin will most likely not work well if another backup application
661 (eg NTBACKUP) is backing up the Exchange database, especially if the
662 other backup application is truncating the log files.
663
664 The Exchange plugin has not been tested with the {\bf Accurate} option, so
665 we recommend either carefully testing or that you avoid this option for
666 the current time.
667
668 The Exchange plugin is not called during processing the bconsole {\bf estimate} command,
669 and so anything that would be backed up by the plugin will not be added
670 to the estimate total that is displayed.
671
672
673 \section{libdbi Framework}
674 As a general guideline, Bacula has support for a few catalog database drivers
675 (MySQL, PostgreSQL, SQLite)
676 coded natively by the Bacula team.  With the libdbi implementation, which is a
677 Bacula driver that uses libdbi to access the catalog, we have an open field to
678 use many different kinds database engines following the needs of users.
679
680 The according to libdbi (http://libdbi.sourceforge.net/) project: libdbi
681 implements a database-independent abstraction layer in C, similar to the
682 DBI/DBD layer in Perl. Writing one generic set of code, programmers can
683 leverage the power of multiple databases and multiple simultaneous database
684 connections by using this framework.
685
686 Currently the libdbi driver in Bacula project only supports the same drivers
687 natively coded in Bacula.  However the libdbi project has support for many
688 others database engines. You can view the list at
689 http://libdbi-drivers.sourceforge.net/. In the future all those drivers can be
690 supported by Bacula, however, they must be tested properly by the Bacula team.
691
692 Some of benefits of using libdbi are:
693 \begin{itemize}
694 \item The possibility to use proprietary databases engines in which your
695   proprietary licenses prevent the Bacula team from developing the driver.
696  \item The possibility to use the drivers written for the libdbi project.
697  \item The possibility to use other database engines without recompiling Bacula
698    to use them.  Just change one line in bacula-dir.conf
699  \item Abstract Database access, this is, unique point to code and profiling
700    catalog database access.
701  \end{itemize}
702  
703  The following drivers have been tested:
704  \begin{itemize}
705  \item PostgreSQL, with and without batch insert
706  \item Mysql, with and without batch insert
707  \item SQLite
708  \item SQLite3
709  \end{itemize}
710
711  In the future, we will test and approve to use others databases engines
712  (proprietary or not) like DB2, Oracle, Microsoft SQL.
713
714  To compile Bacula to support libdbi we need to configure the code with the
715  --with-dbi and --with-dbi-driver=[database] ./configure options, where
716  [database] is the database engine to be used with Bacula (of course we can
717  change the driver in file bacula-dir.conf, see below).  We must configure the
718  access port of the database engine with the option --with-db-port, because the
719  libdbi framework doesn't know the default access port of each database.
720
721 The next phase is checking (or configuring) the bacula-dir.conf, example:
722 \begin{verbatim}
723 Catalog {
724   Name = MyCatalog
725   dbdriver = dbi:mysql; dbaddress = 127.0.0.1; dbport = 3306
726   dbname = regress; user = regress; password = ""
727 }
728 \end{verbatim}
729
730 The parameter {\bf dbdriver} indicates that we will use the driver dbi with a
731 mysql database.  Currently the drivers supported by Bacula are: postgresql,
732 mysql, sqlite, sqlite3; these are the names that may be added to string "dbi:".
733
734 The following limitations apply when Bacula is set to use the libdbi framework:
735  - Not tested on the Win32 platform
736  - A little performance is lost if comparing with native database driver. 
737    The reason is bound with the database driver provided by libdbi and the 
738    simple fact that one more layer of code was added.
739
740 It is important to remember, when compiling Bacula with libdbi, the
741 following packages are needed:
742  \begin{itemize}
743   \item libdbi version 1.0.0, http://libdbi.sourceforge.net/
744   \item libdbi-drivers 1.0.0, http://libdbi-drivers.sourceforge.net/
745  \end{itemize}
746  
747  You can download them and compile them on your system or install the packages
748  from your OS distribution.
749
750
751 \section{Display Autochanger Content}
752 \index[general]{StatusSlots}
753
754 The {\bf status slots storage=\lt{}storage-name\gt{}} command displays
755 autochanger content.
756
757 \footnotesize
758 \begin{verbatim}
759  Slot |  Volume Name  |  Status  |  Media Type       |   Pool     |
760 ------+---------------+----------+-------------------+------------|
761     1 |         00001 |   Append |  DiskChangerMedia |    Default |
762     2 |         00002 |   Append |  DiskChangerMedia |    Default |
763     3*|         00003 |   Append |  DiskChangerMedia |    Scratch |
764     4 |               |          |                   |            |
765 \end{verbatim}
766 \normalsize
767
768 If you an asterisk ({\bf *}) appears after the slot number, you must run an
769 {\bf update slots} command to synchronize autochanger content with your
770 catalog.
771
772 \section{Miscellaneous}
773 \index[general]{Misc New Features}
774
775 \subsection{Allow Mixed Priority = \lt{}yes|no\gt{}}
776    This directive is only implemented in version 2.5 and later.  When
777    set to {\bf yes} (default {\bf no}), this job may run even if lower
778    priority jobs are already running.  This means a high priority job
779    will not have to wait for other jobs to finish before starting.
780    The scheduler will only mix priorities when all running jobs have
781    this set to true.
782
783    Note that only higher priority jobs will start early.  Suppose the
784    director will allow two concurrent jobs, and that two jobs with
785    priority 10 are running, with two more in the queue.  If a job with
786    priority 5 is added to the queue, it will be run as soon as one of
787    the running jobs finishes.  However, new priority 10 jobs will not
788    be run until the priority 5 job has finished.
789
790 \subsection{Bootstrap File Directive -- FileRegex}
791   {\bf FileRegex} is a new command that can be added to the bootstrap
792   (.bsr) file.  The value is a regular expression.  When specified, only
793   matching filenames will be restored.
794
795   During a restore, if all File records are pruned from the catalog
796   for a Job, normally Bacula can restore only all files saved. That
797   is there is no way using the catalog to select individual files.
798   With this new command, Bacula will ask if you want to specify a Regex
799   expression for extracting only a part of the full backup.
800
801 \subsection{Solaris ZFS/NFSv4 ACLs}
802   This is an upgrade of the previous Solaris ACL backup code
803   to the new library format, which will backup both the old
804   POSIX(UFS) ACLs as well as the ZFS ACLs.
805
806   The new code can also restore POSIX(UFS) ACLs to a ZFS filesystem
807   (it will translate the POSIX(UFS)) ACL into a ZFS/NFSv4 one) it can also
808   be used to transfer from UFS to ZFS filesystems.
809
810
811 \subsection{Virtual Tape Emulation}
812 We now have a Virtual Tape emulator that allows us to run though 99.9\% of
813 the tape code but actually reading and writing to a disk file. Used with the
814 \textbf{disk-changer} script, you can now emulate an autochanger with 10 drives
815 and 700 slots. This feature is most useful in testing.  It is enabled
816 by using {\bf Device Type = vtape} in the Storage daemon's Device
817 directive. This feature is only implemented on Linux machines.
818
819 \subsection{Bat Enhancements}
820 Bat (the Bacula Administration Tool) GUI program has been significantly
821 enhanced and stabilized. In particular, there are new table based status 
822 commands; it can now be easily localized using Qt4 Linguist.
823
824 The Bat communications protocol has been significantly enhanced to improve
825 GUI handling.
826
827 \subsection{RunScript Enhancements}
828 The {\bf RunScript} resource has been enhanced to permit multiple
829 commands per RunScript.  Simply specify multiple {\bf Command} directives
830 in your RunScript.
831
832 \begin{verbatim}
833 Job {
834   Name = aJob
835   RunScript {
836     Command = "/bin/echo test"
837     Command = "/bin/echo an other test"
838     Command = "/bin/echo 3 commands in the same runscript"
839     RunsWhen = Before
840   }
841  ...
842 }
843 \end{verbatim}
844
845 A new Client RunScript {\bf RunsWhen} keyword of {\bf AfterVSS} has been
846 implemented, which runs the command after the Volume Shadow Copy has been made.
847
848 Console commands can be specified within a RunScript by using:
849 {\bf Console = \lt{}command\gt{}}, however, this command has not been 
850 carefully tested and debugged and is known to easily crash the Director.
851 We would appreciate feedback.  Due to the recursive nature of this command, we
852 may remove it before the final release.
853
854 \subsection{Status Enhancements}
855 The bconsole {\bf status dir} output has been enhanced to indicate
856 Storage daemon job spooling and despooling activity.
857
858 \subsection{Connect Timeout}
859 The default connect timeout to the File
860 daemon has been set to 3 minutes. Previously it was 30 minutes.
861
862 \subsection{ftruncate for NFS Volumes}
863 If you write to a Volume mounted by NFS (say on a local file server),
864 in previous Bacula versions, when the Volume was recycled, it was not
865 properly truncated because NFS does not implement ftruncate (file 
866 truncate). This is now corrected in the new version because we have
867 written code (actually a kind user) that deletes and recreates the Volume,
868 thus accomplishing the same thing as a truncate.
869
870 \subsection{Support for Ubuntu}
871 The new version of Bacula now recognizes the Ubuntu (and Kubuntu)
872 version of Linux, and thus now provides correct autostart routines.
873 Since Ubuntu officially supports Bacula, you can also obtain any
874 recent release of Bacula from the Ubuntu repositories.
875
876 \subsection{Recycle Pool = \lt{}pool-name\gt{}}
877 The new \textbf{RecyclePool} directive defines to which pool the Volume will
878 be placed (moved) when it is recycled. Without this directive, a Volume will
879 remain in the same pool when it is recycled. With this directive, it can be
880 moved automatically to any existing pool during a recycle. This directive is
881 probably most useful when defined in the Scratch pool, so that volumes will
882 be recycled back into the Scratch pool.
883
884 \subsection{FD Version}
885 The File daemon to Director protocol now includes a version 
886 number, which although there is no visible change for users, 
887 will help us in future versions automatically determine
888 if a File daemon is not compatible.
889
890 \subsection{Max Run Sched Time = \lt{}time-period-in-seconds\gt{}}
891 The time specifies the maximum allowed time that a job may run, counted from
892 when the job was scheduled. This can be useful to prevent jobs from running
893 during working hours. We can see it like \texttt{Max Start Delay + Max Run
894   Time}.
895
896 \subsection{Max Wait Time = \lt{}time-period-in-seconds\gt{}}
897
898 Previous \textbf{MaxWaitTime} directives aren't working as expected, instead
899 of checking the maximum allowed time that a job may block for a resource,
900 those directives worked like \textbf{MaxRunTime}. Some users are reporting to
901 use \textbf{Incr/Diff/Full Max Wait Time} to control the maximum run time of
902 their job depending on the level. Now, they have to use
903 \textbf{Incr/Diff/Full Max Run Time}.  \textbf{Incr/Diff/Full Max Wait Time}
904 directives are now deprecated.
905
906 \subsection{Incremental|Differential Max Wait Time = \lt{}time-period-in-seconds\gt{}} 
907 Theses directives have been deprecated in favor of
908 \texttt{Incremental|Differential Max Run Time}.
909
910 \subsection{Max Run Time directives}
911 Using \textbf{Full/Diff/Incr Max Run Time}, it's now possible to specify the
912 maximum allowed time that a job can run depending on the level.
913
914 \addcontentsline{lof}{figure}{Job time control directives}
915 \includegraphics{\idir different_time.eps}
916
917 \subsection{Statistics Enhancements}
918 If you (or probably your boss) want to have statistics on your backups to
919 provide some \textit{Service Level Agreement} indicators, you could use a few
920 SQL queries on the Job table to report how many:
921
922 \begin{itemize}
923 \item jobs have run
924 \item jobs have been successful
925 \item files have been backed up
926 \item ...
927 \end{itemize}
928
929 However, these statistics are accurate only if your job retention is greater
930 than your statistics period. Ie, if jobs are purged from the catalog, you won't
931 be able to use them. 
932
933 Now, you can use the \textbf{update stats [days=num]} console command to fill
934 the JobHistory table with new Job records. If you want to be sure to take in
935 account only \textbf{good jobs}, ie if one of your important job has failed but
936 you have fixed the problem and restarted it on time, you probably want to
937 delete the first \textit{bad} job record and keep only the successful one. For
938 that simply let your staff do the job, and update JobHistory table after two or
939 three days depending on your organization using the \textbf{[days=num]} option.
940
941 These statistics records aren't used for restoring, but mainly for
942 capacity planning, billings, etc.
943
944 The Bweb interface provides a statistics module that can use this feature. You
945 can also use tools like Talend or extract information by yourself.
946
947 The {\textbf Statistics Retention = \lt{}time\gt{}} director directive defines
948 the length of time that Bacula will keep statistics job records in the Catalog
949 database after the Job End time. (In \texttt{JobHistory} table) When this time
950 period expires, and if user runs \texttt{prune stats} command, Bacula will
951 prune (remove) Job records that are older than the specified period.
952
953 You can use the following Job resource in your nightly \textbf{BackupCatalog}
954 job to maintain statistics.
955 \begin{verbatim}
956 Job {
957   Name = BackupCatalog
958   ...
959   RunScript {
960     Console = "update stats days=3"
961     Console = "prune stats yes"
962     RunsWhen = After
963     RunsOnClient = no
964   }
965 }
966 \end{verbatim}
967
968 \subsection{SpoolSize = \lt{}size-specification-in-bytes\gt{}}
969 A new job directive permits to specify the spool size per job. This is used
970 in advanced job tunning. {\bf SpoolSize={\it bytes}}
971
972
973 \section{Building Bacula Plugins}
974 There is currently one sample program {\bf example-plugin-fd.c} and
975 one working plugin {\bf bpipe-fd.c} that can be found in the Bacula
976 {\bf src/plugins/fd} directory.  Both are built with the following:
977
978 \begin{verbatim}
979  cd <bacula-source>
980  ./configure <your-options>
981  make
982  ...
983  cd src/plugins/fd
984  make
985  make test
986 \end{verbatim}
987
988 After building Bacula and changing into the src/plugins/fd directory,
989 the {\bf make} command will build the {\bf bpipe-fd.so} plugin, which 
990 is a very useful and working program.
991
992 The {\bf make test} command will build the {\bf example-plugin-fd.so}
993 plugin and a binary named {\bf main}, which is build from the source
994 code located in {\bf src/filed/fd\_plugins.c}. 
995
996 If you execute {\bf ./main}, it will load and run the example-plugin-fd
997 plugin simulating a small number of the calling sequences that Bacula uses
998 in calling a real plugin.  This allows you to do initial testing of 
999 your plugin prior to trying it with Bacula.
1000
1001 You can get a good idea of how to write your own plugin by first 
1002 studying the example-plugin-fd, and actually running it.  Then
1003 it can also be instructive to read the bpipe-fd.c code as it is 
1004 a real plugin, which is still rather simple and small.
1005
1006 When actually writing your own plugin, you may use the example-plugin-fd.c
1007 code as a template for your code.
1008
1009
1010 %%
1011 %%
1012
1013 \chapter{Bacula FD Plugin API}
1014 To write a Bacula plugin, you create a dynamic shared object
1015 program (or dll on Win32) with a particular name and two 
1016 exported entry points, place it in the {\bf Plugins Directory}, which is defined in the
1017 {\bf bacula-fd.conf} file in the {\bf Client} resource, and when the FD
1018 starts, it will load all the plugins that end with {\bf -fd.so} (or {\bf -fd.dll}
1019 on Win32) found in that directory.
1020
1021 \section{Normal vs Command Plugins}
1022 In general, there are two ways that plugins are called. The first way, 
1023 is when a particular event is detected in Bacula, it will transfer control
1024 to each plugin that is loaded in turn informing the plugin of the event. 
1025 This is very similar to how a {\bf RunScript} works, and the events are very similar.
1026 Once the plugin gets control, it can interact with Bacula by getting and
1027 setting Bacula variables.  In this way, it behaves much like a RunScript.
1028 Currently very few Bacula variables are defined, but they will be implemented
1029 as the need arrises, and it is very extensible.
1030
1031 We plan to have plugins register to receive events that they normally would
1032 not receive, such as an event for each file examined for backup or restore.
1033 This feature is not yet implemented.
1034
1035 The second type of plugin, which is more useful and fully implemented
1036 in the current version is what we call a command plugin.  As with all
1037 plugins, it gets notified of important events as noted above (details described below),
1038 but in addition, this kind of plugin can accept a command line, which
1039 is a:
1040
1041 \begin{verbatim}
1042    Plugin = <command-string>
1043 \end{verbatim}
1044
1045 directive that is placed in the Include section of a FileSet and is very
1046 similar to the "File = " directive.  When this Plugin directive is encountered 
1047 by Bacula during backup, it passes the "command" part of the Plugin directive
1048 only to the plugin that is explicitly named in the first field of that command string.
1049 This allows that plugin to backup any file or files on the system that it wants. It can
1050 even create "virtual files" in the catalog that contain data to be restored but do
1051 not necessarily correspond to actual files on the filesystem.
1052
1053 The important features of the command plugin entry points are:
1054 \begin{itemize}
1055  \item It is triggered by a "Plugin =" directive in the FileSet
1056  \item Only a single plugin is called that is named on the "Plugin =" directive.
1057  \item The full command string after the "Plugin =" is passed to the plugin
1058     so that it can be told what to backup/restore.
1059 \end{itemize}
1060
1061
1062 \section{Loading Plugins}
1063 Once the File daemon loads the plugins, it asks the OS for the
1064 two entry points (loadPlugin and unloadPlugin) then calls the
1065 {\bf loadPlugin} entry point (see below).
1066
1067 Bacula passes information to the plugin through this call and it gets
1068 back information that it needs to use the plugin.  Later, Bacula
1069  will call particular functions that are defined by the
1070 {\bf loadPlugin} interface.  
1071
1072 When Bacula is finished with the plugin 
1073 (when Bacula is going to exit), it will call the {\bf unloadPlugin}
1074 entry point.
1075
1076 The two entry points are:
1077
1078 \begin{verbatim}
1079 bRC loadPlugin(bInfo *lbinfo, bFuncs *lbfuncs, pInfo **pinfo, pFuncs **pfuncs)
1080
1081 and
1082
1083 bRC unloadPlugin()
1084 \end{verbatim}
1085
1086 both these external entry points to the shared object are defined as C entry points
1087 to avoid name mangling complications with C++.  However, the shared object
1088 can actually be written in any language (preferrably C or C++) providing that it
1089 follows C language calling conventions.
1090
1091 The definitions for {\bf bRC} and the arguments are {\bf
1092 src/filed/fd-plugins.h} and so this header file needs to be included in
1093 your plugin.  It along with {\bf src/lib/plugins.h} define basically the whole
1094 plugin interface.  Within this header file, it includes the following
1095 files:
1096
1097 \begin{verbatim}
1098 #include <sys/types.h>
1099 #include "config.h"
1100 #include "bc_types.h"
1101 #include "lib/plugins.h"
1102 #include <sys/stat.h>
1103 \end{verbatim}
1104
1105 Aside from the {\bf bc\_types.h} and {\bf confit.h} headers, the plugin definition uses the
1106 minimum code from Bacula.  The bc\_types.h file is required to ensure that
1107 the data type defintions in arguments correspond to the Bacula core code.
1108
1109 The return codes are defined as:
1110 \begin{verbatim}
1111 typedef enum {
1112   bRC_OK    = 0,                         /* OK */
1113   bRC_Stop  = 1,                         /* Stop calling other plugins */
1114   bRC_Error = 2,                         /* Some kind of error */
1115   bRC_More  = 3,                         /* More files to backup */
1116 } bRC;
1117 \end{verbatim}
1118
1119
1120 At a future point in time, we hope to make the Bacula libbac.a into a
1121 shared object so that the plugin can use much more of Bacula's
1122 infrastructure, but for this first cut, we have tried to minimize the
1123 dependence on Bacula.
1124
1125 \section{loadPlugin}
1126 As previously mentioned, the {\bf loadPlugin} entry point in the plugin
1127 is called immediately after Bacula loads the plugin when the File daemon
1128 itself is first starting.  This entry point is only called once during the
1129 execution of the File daemon.  In calling the
1130 plugin, the first two arguments are information from Bacula that
1131 is passed to the plugin, and the last two arguments are information
1132 about the plugin that the plugin must return to Bacula.  The call is:
1133
1134 \begin{verbatim}
1135 bRC loadPlugin(bInfo *lbinfo, bFuncs *lbfuncs, pInfo **pinfo, pFuncs **pfuncs)
1136 \end{verbatim}
1137
1138 and the arguments are:
1139
1140 \begin{description}
1141 \item [lbinfo]
1142 This is information about Bacula in general. Currently, the only value
1143 defined in the bInfo structure is the version, which is the Bacula plugin 
1144 interface version, currently defined as 1.  The {\bf size} is set to the
1145 byte size of the structure. The exact definition of the bInfo structure
1146 as of this writing is: 
1147
1148 \begin{verbatim}
1149 typedef struct s_baculaInfo {
1150    uint32_t size;
1151    uint32_t version;
1152 } bInfo;
1153 \end{verbatim}
1154
1155 \item [lbfuncs]
1156 The bFuncs structure defines the callback entry points within Bacula
1157 that the plugin can use register events, get Bacula values, set
1158 Bacula values, and send messages to the Job output or debug output.
1159
1160 The exact definition as of this writing is:
1161 \begin{verbatim}
1162 typedef struct s_baculaFuncs {
1163    uint32_t size;
1164    uint32_t version;
1165    bRC (*registerBaculaEvents)(bpContext *ctx, ...);
1166    bRC (*getBaculaValue)(bpContext *ctx, bVariable var, void *value);
1167    bRC (*setBaculaValue)(bpContext *ctx, bVariable var, void *value);
1168    bRC (*JobMessage)(bpContext *ctx, const char *file, int line,
1169        int type, time_t mtime, const char *fmt, ...);
1170    bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
1171        int level, const char *fmt, ...);
1172    void *(*baculaMalloc)(bpContext *ctx, const char *file, int line,
1173        size_t size);
1174    void (*baculaFree)(bpContext *ctx, const char *file, int line, void *mem);
1175 } bFuncs;
1176 \end{verbatim}
1177
1178 We will discuss these entry points and how to use them a bit later when
1179 describing the plugin code.
1180
1181
1182 \item [pInfo]
1183 When the loadPlugin entry point is called, the plugin must initialize
1184 an information structure about the plugin and return a pointer to
1185 this structure to Bacula.
1186
1187 The exact definition as of this writing is:
1188
1189 \begin{verbatim}
1190 typedef struct s_pluginInfo {
1191    uint32_t size;
1192    uint32_t version;
1193    const char *plugin_magic;
1194    const char *plugin_license;
1195    const char *plugin_author;
1196    const char *plugin_date;
1197    const char *plugin_version;
1198    const char *plugin_description;
1199 } pInfo;
1200 \end{verbatim}
1201
1202 Where:
1203  \begin{description}
1204  \item [version] is the current Bacula defined plugin interface version, currently
1205    set to 1. If the interface version differs from the current version of 
1206    Bacula, the plugin will not be run (not yet implemented).
1207  \item [plugin\_magic] is a pointer to the text string "*FDPluginData*", a
1208    sort of sanity check.  If this value is not specified, the plugin
1209    will not be run (not yet implemented).
1210  \item [plugin\_license] is a pointer to a text string that describes the
1211    plugin license. Bacula will only accept compatible licenses (not yet
1212    implemented).
1213  \item [plugin\_author] is a pointer to the text name of the author of the program.
1214    This string can be anything but is generally the author's name.
1215  \item [plugin\_date] is the pointer text string containing the date of the plugin.
1216    This string can be anything but is generally some human readable form of 
1217    the date.
1218  \item [plugin\_version] is a pointer to a text string containing the version of
1219    the plugin.  The contents are determined by the plugin writer.
1220  \item [plugin\_description] is a pointer to a string describing what the
1221    plugin does. The contents are determined by the plugin writer.
1222  \end{description}
1223
1224 The pInfo structure must be defined in static memory because Bacula does not
1225 copy it and may refer to the values at any time while the plugin is
1226 loaded. All values must be supplied or the plugin will not run (not yet
1227 implemented).  All text strings must be either ASCII or UTF-8 strings that
1228 are terminated with a zero byte.
1229
1230 \item [pFuncs]
1231 When the loadPlugin entry point is called, the plugin must initialize
1232 an entry point structure about the plugin and return a pointer to
1233 this structure to Bacula. This structure contains pointer to each
1234 of the entry points that the plugin must provide for Bacula. When
1235 Bacula is actually running the plugin, it will call the defined
1236 entry points at particular times.  All entry points must be defined.
1237
1238 The pFuncs structure must be defined in static memory because Bacula does not
1239 copy it and may refer to the values at any time while the plugin is
1240 loaded.
1241
1242 The exact definition as of this writing is:
1243
1244 \begin{verbatim}
1245 typedef struct s_pluginFuncs {
1246    uint32_t size;
1247    uint32_t version;
1248    bRC (*newPlugin)(bpContext *ctx);
1249    bRC (*freePlugin)(bpContext *ctx);
1250    bRC (*getPluginValue)(bpContext *ctx, pVariable var, void *value);
1251    bRC (*setPluginValue)(bpContext *ctx, pVariable var, void *value);
1252    bRC (*handlePluginEvent)(bpContext *ctx, bEvent *event, void *value);
1253    bRC (*startBackupFile)(bpContext *ctx, struct save_pkt *sp);
1254    bRC (*endBackupFile)(bpContext *ctx);
1255    bRC (*startRestoreFile)(bpContext *ctx, const char *cmd);
1256    bRC (*endRestoreFile)(bpContext *ctx);
1257    bRC (*pluginIO)(bpContext *ctx, struct io_pkt *io);
1258    bRC (*createFile)(bpContext *ctx, struct restore_pkt *rp);
1259    bRC (*setFileAttributes)(bpContext *ctx, struct restore_pkt *rp);
1260 } pFuncs;
1261 \end{verbatim}
1262
1263 The details of the entry points will be presented in
1264 separate sections below. 
1265
1266 Where:
1267  \begin{description}
1268  \item [size] is the byte size of the structure.
1269  \item [version] is the plugin interface version currently set to 1.
1270  \end{description}
1271
1272 Sample code for loadPlugin:
1273 \begin{verbatim}
1274   bfuncs = lbfuncs;                  /* set Bacula funct pointers */
1275   binfo  = lbinfo;
1276   *pinfo  = &pluginInfo;             /* return pointer to our info */
1277   *pfuncs = &pluginFuncs;            /* return pointer to our functions */
1278
1279    return bRC_OK;
1280 \end{verbatim}
1281
1282 where pluginInfo and pluginFuncs are statically defined structures. 
1283 See bpipe-fd.c for details.
1284
1285
1286
1287 \end{description}
1288
1289 \section{Plugin Entry Points}
1290 This section will describe each of the entry points (subroutines) within
1291 the plugin that the plugin must provide for Bacula, when they are called
1292 and their arguments. As noted above, pointers to these subroutines are
1293 passed back to Bacula in the pFuncs structure when Bacula calls the 
1294 loadPlugin() externally defined entry point.
1295
1296 \subsection{newPlugin(bpContext *ctx)}
1297   This is the entry point that Bacula will call
1298   when a new "instance" of the plugin is created. This typically
1299   happens at the beginning of a Job.  If 10 Jobs are running
1300   simultaneously, there will be at least 10 instances of the
1301   plugin.
1302
1303   The bpContext structure will be passed to the plugin, and
1304   during this call, if the plugin needs to have its private
1305   working storage that is associated with the particular
1306   instance of the plugin, it should create it from the heap
1307   (malloc the memory) and store a pointer to
1308   its private working storage in the {\bf pContext} variable.
1309   Note: since Bacula is a multi-threaded program, you must not
1310   keep any variable data in your plugin unless it is truely meant
1311   to apply globally to the whole plugin.  In addition, you must
1312   be aware that except the first and last call to the plugin
1313   (loadPlugin and unloadPlugin) all the other calls will be 
1314   made by threads that correspond to a Bacula job.  The 
1315   bpContext that will be passed for each thread will remain the
1316   same throughout the Job thus you can keep your privat Job specific
1317   data in it ({\bf bContext}).
1318
1319 \begin{verbatim}
1320 typedef struct s_bpContext {
1321   void *pContext;   /* Plugin private context */
1322   void *bContext;   /* Bacula private context */
1323 } bpContext;
1324
1325 \end{verbatim}
1326    
1327   This context pointer will be passed as the first argument to all
1328   the entry points that Bacula calls within the plugin.  Needless
1329   to say, the plugin should not change the bContext variable, which
1330   is Bacula's private context pointer for this instance (Job) of this
1331   plugin.
1332
1333 \subsection{freePlugin(bpContext *ctx)}
1334 This entry point is called when the
1335 this instance of the plugin is no longer needed (the Job is
1336 ending), and the plugin should release all memory it may
1337 have allocated for this particular instance (Job) i.e. the pContext.  
1338 This is not the final termination
1339 of the plugin signaled by a call to {\bf unloadPlugin}. 
1340 Any other instances (Job) will
1341 continue to run, and the entry point {\bf newPlugin} may be called
1342 again if other jobs start.
1343
1344 \subsection{getPluginValue(bpContext *ctx, pVariable var, void *value)} 
1345 Bacula will call this entry point to get
1346 a value from the plugin.  This entry point is currently not called.
1347
1348 \subsection{setPluginValue(bpContext *ctx, pVariable var, void *value)}
1349 Bacula will call this entry point to set
1350 a value in the plugin.  This entry point is currently not called.
1351  
1352 \subsection{handlePluginEvent(bpContext *ctx, bEvent *event, void *value)}
1353 This entry point is called when Bacula
1354 encounters certain events (discussed below). This is, in fact, the 
1355 main way that most plugins get control when a Job runs and how
1356 they know what is happening in the job. It can be likened to the
1357 {\bf RunScript} feature that calls external programs and scripts,
1358 and is very similar to the Bacula Python interface.
1359 When the plugin is called, Bacula passes it the pointer to an event
1360 structure (bEvent), which currently has one item, the eventType:
1361
1362 \begin{verbatim}
1363 typedef struct s_bEvent {
1364    uint32_t eventType;
1365 } bEvent;
1366 \end{verbatim}
1367
1368   which defines what event has been triggered, and for each event,
1369   Bacula will pass a pointer to a value associated with that event.
1370   If no value is associated with a particular event, Bacula will 
1371   pass a NULL pointer, so the plugin must be careful to always check
1372   value pointer prior to dereferencing it.
1373   
1374   The current list of events are:
1375
1376 \begin{verbatim}
1377 typedef enum {
1378   bEventJobStart        = 1,
1379   bEventJobEnd          = 2,
1380   bEventStartBackupJob  = 3,
1381   bEventEndBackupJob    = 4,
1382   bEventStartRestoreJob = 5,
1383   bEventEndRestoreJob   = 6,
1384   bEventStartVerifyJob  = 7,
1385   bEventEndVerifyJob    = 8,
1386   bEventBackupCommand   = 9,
1387   bEventRestoreCommand  = 10,
1388   bEventLevel           = 11,
1389   bEventSince           = 12,
1390 } bEventType;
1391
1392 \end{verbatim}
1393  
1394 Most of the above are self-explanatory.
1395
1396 \begin{description}
1397  \item [bEventJobStart] is called whenever a Job starts. The value
1398    passed is a pointer to a string that contains: "Jobid=nnn 
1399    Job=job-name". Where nnn will be replaced by the JobId and job-name
1400    will be replaced by the Job name. The variable is temporary so if you
1401    need the values, you must copy them.
1402
1403  \item [bEventJobEnd] is called whenever a Job ends. No value is passed.
1404
1405  \item [bEventStartBackupJob] is called when a Backup Job begins. No value
1406    is passed.
1407
1408  \item [bEventEndBackupJob] is called when a Backup Job ends. No value is 
1409    passed.
1410
1411  \item [bEventStartRestoreJob] is called when a Restore Job starts. No value
1412    is passed.
1413
1414  \item [bEventEndRestoreJob] is called when a Restore Job ends. No value is
1415    passed.
1416
1417  \item [bEventStartVerifyJob] is called when a Verify Job starts. No value
1418    is passed.
1419
1420  \item [bEventEndVerifyJob] is called when a Verify Job ends. No value
1421    is passed.
1422
1423  \item [bEventBackupCommand] is called prior to the bEventStartBackupJob and
1424    the plugin is passed the command string (everything after the equal sign
1425    in "Plugin =" as the value.
1426
1427    Note, if you intend to backup a file, this is an important first point to
1428    write code that copies the command string passed into your pContext area
1429    so that you will know that a backup is being performed and you will know
1430    the full contents of the "Plugin =" command (i.e. what to backup and
1431    what virtual filename the user wants to call it.
1432
1433  \item [bEventRestoreCommand] is called prior to the bEventStartRestoreJob and
1434    the plugin is passed the command string (everything after the equal sign
1435    in "Plugin =" as the value.
1436
1437    See the notes above concerning backup and the command string. This is the
1438    point at which Bacula passes you the original command string that was
1439    specified during the backup, so you will want to save it in your pContext
1440    area for later use when Bacula calls the plugin again.
1441
1442  \item [bEventLevel] is called when the level is set for a new Job. The value
1443    is a 32 bit integer stored in the void*, which represents the Job Level code.
1444
1445  \item [bEventSince] is called when the since time is set for a new Job. The 
1446    value is a time\_t time at which the last job was run.
1447 \end{description}
1448
1449 During each of the above calls, the plugin receives either no specific value or
1450 only one value, which in some cases may not be sufficient.  However, knowing the
1451 context of the event, the plugin can call back to the Bacula entry points it
1452 was passed during the {\bf loadPlugin} call and get to a number of Bacula variables.
1453 (at the current time few Bacula variables are implemented, but it easily extended
1454 at a future time and as needs require).
1455
1456 \subsection{startBackupFile(bpContext *ctx, struct save\_pkt *sp)}
1457 This entry point is called only if your plugin is a command plugin, and 
1458 it is called when Bacula encounters the "Plugin = " directive in
1459 the Include section of the FileSet.
1460 Called when beginning the backup of a file. Here Bacula provides you
1461 with a pointer to the {\bf save\_pkt} structure and you must fill in 
1462 this packet with the "attribute" data of the file.
1463
1464 \begin{verbatim}
1465 struct save_pkt {
1466    int32_t pkt_size;                  /* size of this packet */
1467    char *fname;                       /* Full path and filename */
1468    char *link;                        /* Link name if any */
1469    struct stat statp;                 /* System stat() packet for file */
1470    int32_t type;                      /* FT_xx for this file */
1471    uint32_t flags;                    /* Bacula internal flags */
1472    bool portable;                     /* set if data format is portable */
1473    char *cmd;                         /* command */
1474    int32_t pkt_end;                   /* end packet sentinel */
1475 };
1476 \end{verbatim}
1477
1478 The second argument is a pointer to the {\bf save\_pkt} structure for the file
1479 to be backed up.  The plugin is responsible for filling in all the fields 
1480 of the {\bf save\_pkt}. If you are backing up
1481 a real file, then generally, the statp structure can be filled in by doing
1482 a {\bf stat} system call on the file.  
1483
1484 If you are backing up a database or
1485 something that is more complex, you might want to create a virtual file.
1486 That is a file that does not actually exist on the filesystem, but represents 
1487 say an object that you are backing up.  In that case, you need to ensure
1488 that the {\bf fname} string that you pass back is unique so that it
1489 does not conflict with a real file on the system, and you need to 
1490 artifically create values in the statp packet.
1491
1492 Example programs such as {\bf bpipe-fd.c} show how to set these fields.
1493 You must take care not to store pointers the stack in the pointer fields such
1494 as fname and link, because when you return from your function, your stack entries
1495 will be destroyed. The solution in that case is to malloc() and return the pointer
1496 to it. In order to not have memory leaks, you should store a pointer to all memory
1497 allocated in your pContext structure so that in subsequent calls or at termination,
1498 you can release it back to the system.
1499
1500 Once the backup has begun, Bacula will call your plugin at the {\bf pluginIO}
1501 entry point to "read" the data to be backed up.  Please see the {\bf bpipe-fd.c}
1502 plugin for how to do I/O.
1503
1504 Example of filling in the save\_pkt as used in bpipe-fd.c:
1505
1506 \begin{verbatim}
1507    struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
1508    time_t now = time(NULL);
1509    sp->fname = p_ctx->fname;
1510    sp->statp.st_mode = 0700 | S_IFREG;
1511    sp->statp.st_ctime = now;
1512    sp->statp.st_mtime = now;
1513    sp->statp.st_atime = now;
1514    sp->statp.st_size = -1;
1515    sp->statp.st_blksize = 4096;
1516    sp->statp.st_blocks = 1;
1517    p_ctx->backup = true;
1518    return bRC_OK; 
1519 \end{verbatim}
1520
1521 Note: the filename to be created has already been created from the 
1522 command string previously sent to the plugin and is in the plugin 
1523 context (p\_ctx->fname) and is a malloc()ed string.  This example
1524 creates a regular file (S\_IFREG), with various fields being created.
1525
1526 In general, the sequence of commands issued from Bacula to the plugin
1527 to do a backup while processing the "Plugin = " directive are:
1528
1529 \begin{enumerate}
1530  \item generate a bEventBackupCommand event to the specified plugin
1531        and pass it the command string.
1532  \item make a startPluginBackup call to the plugin, which
1533        fills in the data needed in save\_pkt to save as the file
1534        attributes and to put on the Volume and in the catalog.
1535  \item call Bacula's internal save\_file() subroutine to save the specified
1536        file.  The plugin will then be called at pluginIO() to "open"
1537        the file, and then to read the file data.
1538        Note, if you are dealing with a virtual file, the "open" operation
1539        is something the plugin does internally and it doesn't necessarily
1540        mean opening a file on the filesystem.  For example in the case of
1541        the bpipe-fd.c program, it initiates a pipe to the requested program.
1542        Finally when the plugin signals to Bacula that all the data was read,
1543        Bacula will call the plugin with the "close" pluginIO() function.
1544 \end{enumerate}
1545
1546
1547 \subsection{endBackupFile(bpContext *ctx)}
1548 Called at the end of backing up a file for a command plugin.  If the plugin's work
1549 is done, it should return bRC\_OK.  If the plugin wishes to create another
1550 file and back it up, then it must return bRC\_More (not yet implemented).
1551 This is probably a good time to release any malloc()ed memory you used to
1552 pass back filenames.
1553
1554 \subsection{startRestoreFile(bpContext *ctx, const char *cmd)}
1555 Called when the first record is read from the Volume that was 
1556 previously written by the command plugin.
1557
1558 \subsection{createFile(bpContext *ctx, struct restore\_pkt *rp)}
1559 Called for a command plugin to create a file during a Restore job before 
1560 restoring the data. 
1561 This entry point is called before any I/O is done on the file.  After
1562 this call, Bacula will call pluginIO() to open the file for write.
1563
1564 The data in the 
1565 restore\_pkt is passed to the plugin and is based on the data that was
1566 originally given by the plugin during the backup and the current user
1567 restore settings (e.g. where, RegexWhere, replace).  This allows the
1568 plugin to first create a file (if necessary) so that the data can
1569 be transmitted to it.  The next call to the plugin will be a
1570 pluginIO command with a request to open the file write-only.
1571
1572 This call must return one of the following values:
1573
1574 \begin{verbatim}
1575  enum {
1576    CF_SKIP = 1,       /* skip file (not newer or something) */
1577    CF_ERROR,          /* error creating file */
1578    CF_EXTRACT,        /* file created, data to extract */
1579    CF_CREATED         /* file created, no data to extract */
1580 };
1581 \end{verbatim}
1582
1583 in the restore\_pkt value {\bf create\_status}.  For a normal file,
1584 unless there is an error, you must return {\bf CF\_EXTRACT}.
1585
1586 \begin{verbatim}
1587  
1588 struct restore_pkt {
1589    int32_t pkt_size;                  /* size of this packet */
1590    int32_t stream;                    /* attribute stream id */
1591    int32_t data_stream;               /* id of data stream to follow */
1592    int32_t type;                      /* file type FT */
1593    int32_t file_index;                /* file index */
1594    int32_t LinkFI;                    /* file index to data if hard link */
1595    uid_t uid;                         /* userid */
1596    struct stat statp;                 /* decoded stat packet */
1597    const char *attrEx;                /* extended attributes if any */
1598    const char *ofname;                /* output filename */
1599    const char *olname;                /* output link name */
1600    const char *where;                 /* where */
1601    const char *RegexWhere;            /* regex where */
1602    int replace;                       /* replace flag */
1603    int create_status;                 /* status from createFile() */
1604    int32_t pkt_end;                   /* end packet sentinel */
1605
1606 };
1607 \end{verbatim}
1608
1609 Typical code to create a regular file would be the following:
1610
1611 \begin{verbatim}
1612    struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
1613    time_t now = time(NULL);
1614    sp->fname = p_ctx->fname;   /* set the full path/filename I want to create */
1615    sp->type = FT_REG;
1616    sp->statp.st_mode = 0700 | S_IFREG;
1617    sp->statp.st_ctime = now;
1618    sp->statp.st_mtime = now;
1619    sp->statp.st_atime = now;
1620    sp->statp.st_size = -1;
1621    sp->statp.st_blksize = 4096;
1622    sp->statp.st_blocks = 1;
1623    return bRC_OK;
1624 \end{verbatim}
1625
1626 This will create a virtual file.  If you are creating a file that actually 
1627 exists, you will most likely want to fill the statp packet using the
1628 stat() system call.
1629
1630 Creating a directory is similar, but requires a few extra steps:
1631
1632 \begin{verbatim}
1633    struct plugin_ctx *p_ctx = (struct plugin_ctx *)ctx->pContext;
1634    time_t now = time(NULL);
1635    sp->fname = p_ctx->fname;   /* set the full path I want to create */
1636    sp->link = xxx; where xxx is p_ctx->fname with a trailing forward slash
1637    sp->type = FT_DIREND
1638    sp->statp.st_mode = 0700 | S_IFDIR;
1639    sp->statp.st_ctime = now;
1640    sp->statp.st_mtime = now;
1641    sp->statp.st_atime = now;
1642    sp->statp.st_size = -1;
1643    sp->statp.st_blksize = 4096;
1644    sp->statp.st_blocks = 1;
1645    return bRC_OK;
1646 \end{verbatim}
1647
1648 The link field must be set with the full cononical path name, which always 
1649 ends with a forward slash.  If you do not terminate it with a forward slash,
1650 you will surely have problems later.
1651
1652 As with the example that creates a file, if you are backing up a real
1653 directory, you will want to do an stat() on the directory.  
1654
1655 Note, if you want the directory permissions and times to be correctly
1656 restored, you must create the directory {\bf after} all the file directories
1657 have been sent to Bacula. That allows the restore process to restore all the
1658 files in a directory using default directory options, then at the end, restore
1659 the directory permissions.  If you do it the other way around, each time you
1660 restore a file, the OS will modify the time values for the directory entry.
1661
1662 \subsection{setFileAttributes(bpContext *ctx, struct restore\_pkt *rp)}
1663 This is call not yet implemented.  Called for a command plugin.
1664
1665 See the definition of {\bf restre\_pkt} in the above section.
1666
1667 \subsection{endRestoreFile(bpContext *ctx)}
1668 Called when a command plugin is done restoring a file.
1669
1670 \subsection{pluginIO(bpContext *ctx, struct io\_pkt *io)}
1671 Called to do the input (backup) or output (restore) of data from or to a
1672 file for a command plugin. These routines simulate the Unix read(), write(), open(), close(), 
1673 and lseek() I/O calls, and the arguments are passed in the packet and
1674 the return values are also placed in the packet.  In addition for Win32
1675 systems the plugin must return two additional values (described below).
1676
1677 \begin{verbatim}
1678  enum {
1679    IO_OPEN = 1,
1680    IO_READ = 2,
1681    IO_WRITE = 3,
1682    IO_CLOSE = 4,
1683    IO_SEEK = 5
1684 };
1685
1686 struct io_pkt {
1687    int32_t pkt_size;                  /* Size of this packet */
1688    int32_t func;                      /* Function code */
1689    int32_t count;                     /* read/write count */
1690    mode_t mode;                       /* permissions for created files */
1691    int32_t flags;                     /* Open flags */
1692    char *buf;                         /* read/write buffer */
1693    const char *fname;                 /* open filename */
1694    int32_t status;                    /* return status */
1695    int32_t io_errno;                  /* errno code */
1696    int32_t lerror;                    /* Win32 error code */
1697    int32_t whence;                    /* lseek argument */
1698    boffset_t offset;                  /* lseek argument */
1699    bool win32;                        /* Win32 GetLastError returned */
1700    int32_t pkt_end;                   /* end packet sentinel */
1701 };
1702 \end{verbatim}
1703
1704 The particular Unix function being simulated is indicated by the {\bf func}, 
1705 which will have one of the IO\_OPEN, IO\_READ, ... codes listed above.  
1706 The status code that would be returned from a Unix call is returned in
1707 {\bf status} for IO\_OPEN, IO\_CLOSE, IO\_READ, and IO\_WRITE. The return value for 
1708 IO\_SEEK is returned in {\bf offset} which in general is a 64 bit value.
1709
1710 When there is an error on Unix systems, you must always set io\_error, and
1711 on a Win32 system, you must always set win32, and the returned value from
1712 the OS call GetLastError() in lerror.
1713
1714 For all except IO\_SEEK, {\bf status} is the return result.  In general it is
1715 a positive integer unless there is an error in which case it is -1.
1716
1717 The following describes each call and what you get and what you
1718 should return:
1719
1720 \begin{description}
1721  \item [IO\_OPEN]
1722    You will be passed fname, mode, and flags.
1723    You must set on return: status, and if there is a Unix error
1724    io\_errno must be set to the errno value, and if there is a 
1725    Win32 error win32 and lerror. 
1726
1727  \item [IO\_READ]
1728   You will be passed: count, and buf (buffer of size count).
1729   You must set on return: status to the number of bytes 
1730   read into the buffer (buf) or -1 on an error, 
1731   and if there is a Unix error
1732   io\_errno must be set to the errno value, and if there is a
1733   Win32 error, win32 and lerror must be set.
1734
1735  \item [IO\_WRITE]
1736   You will be passed: count, and buf (buffer of size count).
1737   You must set on return: status to the number of bytes 
1738   written from the buffer (buf) or -1 on an error, 
1739   and if there is a Unix error
1740   io\_errno must be set to the errno value, and if there is a
1741   Win32 error, win32 and lerror must be set.
1742
1743  \item [IO\_CLOSE]
1744   Nothing will be passed to you.  On return you must set 
1745   status to 0 on success and -1 on failure.  If there is a Unix error
1746   io\_errno must be set to the errno value, and if there is a
1747   Win32 error, win32 and lerror must be set.
1748
1749  \item [IO\_LSEEK]
1750   You will be passed: offset, and whence. offset is a 64 bit value
1751   and is the position to seek to relative to whence.  whence is one
1752   of the following SEEK\_SET, SEEK\_CUR, or SEEK\_END indicating to
1753   either to seek to an absolute possition, relative to the current 
1754   position or relative to the end of the file.
1755   You must pass back in offset the absolute location to which you 
1756   seeked. If there is an error, offset should be set to -1.
1757   If there is a Unix error
1758   io\_errno must be set to the errno value, and if there is a
1759   Win32 error, win32 and lerror must be set.
1760
1761   Note: Bacula will call IO\_SEEK only when writing a sparse file.
1762   
1763 \end{description}
1764
1765 \section{Bacula Plugin Entrypoints}
1766 When Bacula calls one of your plugin entrypoints, you can call back to
1767 the entrypoints in Bacula that were supplied during the xxx plugin call
1768 to get or set information within Bacula.
1769
1770 \subsection{bRC registerBaculaEvents(bpContext *ctx, ...)}
1771 This Bacula entrypoint will allow you to register to receive events
1772 that are not autmatically passed to your plugin by default. This 
1773 entrypoint currently is unimplemented.
1774
1775 \subsection{bRC getBaculaValue(bpContext *ctx, bVariable var, void *value)}
1776 Calling this entrypoint, you can obtain specific values that are available
1777 in Bacula.
1778
1779 \subsection{bRC setBaculaValue(bpContext *ctx, bVariable var, void *value)}
1780 Calling this entrypoint allows you to set particular values in
1781 Bacula.
1782
1783 \subsection{bRC JobMessage(bpContext *ctx, const char *file, int line,
1784        int type, time\_t mtime, const char *fmt, ...)}
1785 This call permits you to put a message in the Job Report.
1786
1787
1788 \subsection{bRC DebugMessage(bpContext *ctx, const char *file, int line,
1789        int level, const char *fmt, ...)}
1790 This call permits you to print a debug message.
1791
1792
1793 \subsection{void baculaMalloc(bpContext *ctx, const char *file, int line,
1794        size\_t size)}
1795 This call permits you to obtain memory from Bacula's memory allocator.
1796
1797
1798 \subsection{void baculaFree(bpContext *ctx, const char *file, int line, void *mem)}
1799 This call permits you to free memory obtained from Bacula's memory allocator.