1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
3
<!--Converted with LaTeX2HTML 2002-2-1 (1.70)
4
original version by: Nikos Drakos, CBLU, University of Leeds
5
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
6
* with significant contributions from:
7
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
10
<TITLE>It comes in the night and sucks the essence from your computers. </TITLE>
11
<META NAME="description" CONTENT="It comes in the night and sucks the essence from your computers. ">
12
<META NAME="keywords" CONTENT="developers">
13
<META NAME="resource-type" CONTENT="document">
14
<META NAME="distribution" CONTENT="global">
16
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
17
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
19
<LINK REL="STYLESHEET" HREF="developers.css">
24
<!--Navigation Panel-->
25
<IMG WIDTH="81" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next_inactive"
26
SRC="file:/usr/share/latex2html/icons/nx_grp_g.png">
27
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
28
SRC="file:/usr/share/latex2html/icons/up_g.png">
29
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
30
SRC="file:/usr/share/latex2html/icons/prev_g.png">
34
<!--End of Navigation Panel-->
41
<H1 ALIGN="CENTER"><IMG
42
WIDTH="458" HEIGHT="99" ALIGN="BOTTOM" BORDER="0"
44
ALT="\includegraphics{./bacula-logo.eps}">
48
<FONT SIZE="+1">It comes in the night and sucks
49
the essence from your computers.
54
<P ALIGN="CENTER"><STRONG>Kern Sibbald</STRONG></P>
55
<P ALIGN="CENTER"><STRONG>
65
This manual documents Bacula version 1.38.11 (01 July 2006)
71
Copyright ©1999-2006, Kern Sibbald
75
Permission is granted to copy, distribute and/or modify this document under the terms of the
77
GNU Free Documentation License, Version 1.2 published by the Free Software Foundation;
79
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
81
A copy of the license is included in the section entitled "GNU Free Documentation License".
89
<H2><A NAME="SECTION00010000000000000000">
92
<!--Table of Contents-->
95
<LI><A NAME="tex2html190"
96
HREF="developers.html#SECTION00020000000000000000">List of Figures</A>
97
<LI><A NAME="tex2html191"
98
HREF="developers.html#SECTION00030000000000000000">List of Tables</A>
99
<LI><A NAME="tex2html192"
100
HREF="developers.html#SECTION00040000000000000000">Bacula Developer Notes</A>
102
<LI><A NAME="tex2html193"
103
HREF="developers.html#SECTION00041000000000000000">General</A>
104
<LI><A NAME="tex2html194"
105
HREF="developers.html#SECTION00042000000000000000">Basic CVS Usage</A>
106
<LI><A NAME="tex2html195"
107
HREF="developers.html#SECTION00043000000000000000">The Development Cycle</A>
108
<LI><A NAME="tex2html196"
109
HREF="developers.html#SECTION00044000000000000000">Developing Bacula</A>
112
<LI><A NAME="tex2html197"
113
HREF="developers.html#SECTION00050000000000000000">Platform Support</A>
115
<LI><A NAME="tex2html198"
116
HREF="developers.html#SECTION00051000000000000000">General</A>
117
<LI><A NAME="tex2html199"
118
HREF="developers.html#SECTION00052000000000000000">Requirements to become a Supported Platform</A>
121
<LI><A NAME="tex2html200"
122
HREF="developers.html#SECTION00060000000000000000">Daemon Protocol</A>
124
<LI><A NAME="tex2html201"
125
HREF="developers.html#SECTION00061000000000000000">General</A>
126
<LI><A NAME="tex2html202"
127
HREF="developers.html#SECTION00062000000000000000">Low Level Network Protocol</A>
128
<LI><A NAME="tex2html203"
129
HREF="developers.html#SECTION00063000000000000000">General Daemon Protocol</A>
130
<LI><A NAME="tex2html204"
131
HREF="developers.html#SECTION00064000000000000000">The Protocol Used Between the Director and the Storage Daemon</A>
132
<LI><A NAME="tex2html205"
133
HREF="developers.html#SECTION00065000000000000000">The Protocol Used Between the Director and the File Daemon</A>
134
<LI><A NAME="tex2html206"
135
HREF="developers.html#SECTION00066000000000000000">The Save Protocol Between the File Daemon and the Storage Daemon</A>
138
<LI><A NAME="tex2html207"
139
HREF="developers.html#SECTION00070000000000000000">Director Services Daemon</A>
140
<LI><A NAME="tex2html208"
141
HREF="developers.html#SECTION00080000000000000000">File Services Daemon</A>
143
<LI><A NAME="tex2html209"
144
HREF="developers.html#SECTION00081000000000000000">Commands Received from the Director for a Backup</A>
145
<LI><A NAME="tex2html210"
146
HREF="developers.html#SECTION00082000000000000000">Commands Received from the Director for a Restore</A>
149
<LI><A NAME="tex2html211"
150
HREF="developers.html#SECTION00090000000000000000">Storage Daemon Design</A>
152
<LI><A NAME="tex2html212"
153
HREF="developers.html#SECTION00091000000000000000">SD Design Introduction</A>
154
<LI><A NAME="tex2html213"
155
HREF="developers.html#SECTION00092000000000000000">SD Development Outline</A>
156
<LI><A NAME="tex2html214"
157
HREF="developers.html#SECTION00093000000000000000">SD Connections and Sessions</A>
158
<LI><A NAME="tex2html215"
159
HREF="developers.html#SECTION00094000000000000000">SD Data Structures</A>
162
<LI><A NAME="tex2html216"
163
HREF="developers.html#SECTION000100000000000000000">Catalog Services</A>
165
<LI><A NAME="tex2html217"
166
HREF="developers.html#SECTION000101000000000000000">General</A>
167
<LI><A NAME="tex2html218"
168
HREF="developers.html#SECTION000102000000000000000">Sequence of Creation of Records for a Save Job</A>
169
<LI><A NAME="tex2html219"
170
HREF="developers.html#SECTION000103000000000000000">Database Tables</A>
173
<LI><A NAME="tex2html220"
174
HREF="developers.html#SECTION000110000000000000000">Storage Media Output Format</A>
176
<LI><A NAME="tex2html221"
177
HREF="developers.html#SECTION000111000000000000000">General</A>
178
<LI><A NAME="tex2html222"
179
HREF="developers.html#SECTION000112000000000000000">Definitions</A>
180
<LI><A NAME="tex2html223"
181
HREF="developers.html#SECTION000113000000000000000">Storage Daemon File Output Format</A>
182
<LI><A NAME="tex2html224"
183
HREF="developers.html#SECTION000114000000000000000">Overall Format</A>
184
<LI><A NAME="tex2html225"
185
HREF="developers.html#SECTION000115000000000000000">Serialization</A>
186
<LI><A NAME="tex2html226"
187
HREF="developers.html#SECTION000116000000000000000">Block Header</A>
188
<LI><A NAME="tex2html227"
189
HREF="developers.html#SECTION000117000000000000000">Record Header</A>
190
<LI><A NAME="tex2html228"
191
HREF="developers.html#SECTION000118000000000000000">Version BB02 Block Header</A>
192
<LI><A NAME="tex2html229"
193
HREF="developers.html#SECTION000119000000000000000">Version 2 Record Header</A>
194
<LI><A NAME="tex2html230"
195
HREF="developers.html#SECTION0001110000000000000000">Volume Label Format</A>
196
<LI><A NAME="tex2html231"
197
HREF="developers.html#SECTION0001111000000000000000">Session Label</A>
198
<LI><A NAME="tex2html232"
199
HREF="developers.html#SECTION0001112000000000000000">Overall Storage Format</A>
200
<LI><A NAME="tex2html233"
201
HREF="developers.html#SECTION0001113000000000000000">Unix File Attributes</A>
202
<LI><A NAME="tex2html234"
203
HREF="developers.html#SECTION0001114000000000000000">Old Depreciated Tape Format</A>
206
<LI><A NAME="tex2html235"
207
HREF="developers.html#SECTION000120000000000000000">Bacula Porting Notes</A>
209
<LI><A NAME="tex2html236"
210
HREF="developers.html#SECTION000121000000000000000">Porting Requirements</A>
211
<LI><A NAME="tex2html237"
212
HREF="developers.html#SECTION000122000000000000000">Steps to Take for Porting</A>
215
<LI><A NAME="tex2html238"
216
HREF="developers.html#SECTION000130000000000000000">Implementing a Bacula GUI Interface</A>
218
<LI><A NAME="tex2html239"
219
HREF="developers.html#SECTION000131000000000000000">General</A>
222
<LI><A NAME="tex2html240"
223
HREF="developers.html#SECTION000140000000000000000">TLS</A>
225
<LI><A NAME="tex2html241"
226
HREF="developers.html#SECTION000141000000000000000">Introduction to TLS</A>
227
<LI><A NAME="tex2html242"
228
HREF="developers.html#SECTION000142000000000000000">New Configuration Directives</A>
229
<LI><A NAME="tex2html243"
230
HREF="developers.html#SECTION000143000000000000000">TLS API Implementation</A>
231
<LI><A NAME="tex2html244"
232
HREF="developers.html#SECTION000144000000000000000">Bnet API Changes</A>
233
<LI><A NAME="tex2html245"
234
HREF="developers.html#SECTION000145000000000000000">Authentication Negotiation</A>
237
<LI><A NAME="tex2html246"
238
HREF="developers.html#SECTION000150000000000000000">Bacula Regression Testing</A>
240
<LI><A NAME="tex2html247"
241
HREF="developers.html#SECTION000151000000000000000">General</A>
242
<LI><A NAME="tex2html248"
243
HREF="developers.html#SECTION000152000000000000000">Running the Regression Script</A>
244
<LI><A NAME="tex2html249"
245
HREF="developers.html#SECTION000153000000000000000">Writing a Regression Test</A>
248
<LI><A NAME="tex2html250"
249
HREF="developers.html#SECTION000160000000000000000">Bacula MD5 Algorithm</A>
251
<LI><A NAME="tex2html251"
252
HREF="developers.html#SECTION000161000000000000000">Command Line Message Digest Utility </A>
253
<LI><A NAME="tex2html252"
254
HREF="developers.html#SECTION000162000000000000000">Download md5.zip
259
<LI><A NAME="tex2html253"
260
HREF="developers.html#SECTION000170000000000000000">Bacula Memory Management</A>
262
<LI><A NAME="tex2html254"
263
HREF="developers.html#SECTION000171000000000000000">General</A>
266
<LI><A NAME="tex2html255"
267
HREF="developers.html#SECTION000180000000000000000">TCP/IP Network Protocol</A>
269
<LI><A NAME="tex2html256"
270
HREF="developers.html#SECTION000181000000000000000">General</A>
271
<LI><A NAME="tex2html257"
272
HREF="developers.html#SECTION000182000000000000000">bnet and Threads</A>
273
<LI><A NAME="tex2html258"
274
HREF="developers.html#SECTION000183000000000000000">bnet_open</A>
275
<LI><A NAME="tex2html259"
276
HREF="developers.html#SECTION000184000000000000000">bnet_send</A>
277
<LI><A NAME="tex2html260"
278
HREF="developers.html#SECTION000185000000000000000">bnet_fsend</A>
279
<LI><A NAME="tex2html261"
280
HREF="developers.html#SECTION000186000000000000000">Additional Error information</A>
281
<LI><A NAME="tex2html262"
282
HREF="developers.html#SECTION000187000000000000000">bnet_recv</A>
283
<LI><A NAME="tex2html263"
284
HREF="developers.html#SECTION000188000000000000000">bnet_sig</A>
285
<LI><A NAME="tex2html264"
286
HREF="developers.html#SECTION000189000000000000000">bnet_strerror</A>
287
<LI><A NAME="tex2html265"
288
HREF="developers.html#SECTION0001810000000000000000">bnet_close</A>
289
<LI><A NAME="tex2html266"
290
HREF="developers.html#SECTION0001811000000000000000">Becoming a Server</A>
291
<LI><A NAME="tex2html267"
292
HREF="developers.html#SECTION0001812000000000000000">Higher Level Conventions</A>
295
<LI><A NAME="tex2html268"
296
HREF="developers.html#SECTION000190000000000000000">Smart Memory Allocation With Orphaned Buffer Detection </A>
298
<LI><A NAME="tex2html269"
299
HREF="developers.html#SECTION000191000000000000000">Download smartall.zip
303
<LI><A NAME="tex2html270"
304
HREF="developers.html#SECTION000200000000000000000">GNU Free Documentation License</A>
305
<LI><A NAME="tex2html271"
306
HREF="developers.html#SECTION000210000000000000000">General Index</A>
307
<LI><A NAME="tex2html272"
308
HREF="developers.html#SECTION000220000000000000000">About this document ...</A>
310
<!--End of Table of Contents-->
313
<H2><A NAME="SECTION00020000000000000000">
316
<LI><A HREF="developers.html#4963">Smart Memory Allocation with Orphaned BufferDetection</A>
320
<H2><A NAME="SECTION00030000000000000000">
323
<LI><A HREF="developers.html#361">Message Error Code Classes</A>
324
<LI><A HREF="developers.html#1676">Filename Table Layout</A>
325
<LI><A HREF="developers.html#1701">Path Table Layout</A>
326
<LI><A HREF="developers.html#1726">File Table Layout</A>
327
<LI><A HREF="developers.html#1770">Job Table Layout</A>
328
<LI><A HREF="developers.html#1855">Job Types</A>
329
<LI><A HREF="developers.html#1879">Job Statuses</A>
330
<LI><A HREF="developers.html#1929">File Sets Table Layout</A>
331
<LI><A HREF="developers.html#1960">JobMedia Table Layout</A>
332
<LI><A HREF="developers.html#2009">Media Table Layout</A>
333
<LI><A HREF="developers.html#2097">Pool Table Layout</A>
334
<LI><A HREF="developers.html#2164">Client Table Layout</A>
335
<LI><A HREF="developers.html#2201">Unsaved Files Table Layout</A>
336
<LI><A HREF="developers.html#2232">Counter Table Layout</A>
337
<LI><A HREF="developers.html#2266">Version Table Layout</A>
338
<LI><A HREF="developers.html#2288">Base Files Table Layout</A>
339
<LI><A HREF="developers.html#2843">File Attributes</A>
346
<H1><A NAME="SECTION00040000000000000000"></A>
347
<A NAME="_ChapterStart10"></A><A NAME="60"></A>
350
Bacula Developer Notes
356
<H2><A NAME="SECTION00041000000000000000"></A>
364
This document is intended mostly for developers and describes the the general
365
framework of making Bacula source changes.
369
<H3><A NAME="SECTION00041100000000000000"></A>
377
Contributions from programmers are broken into two groups. The first are
378
contributions that are aids and not essential to Bacula. In general, these
379
will be scripts or will go into and examples or contributions directory.
380
For these kinds of non-essential contributions there is no obligation to do
381
a copyright assignment as described below. However, a copyright assignment
382
would still be appreciated.
385
The second class of contributions are those which will be integrated with
386
Bacula and become an essential part. Within this class of contributions, there
387
are two hurdles to surmount. One is getting your patch accepted, and two is
388
dealing with copyright issues. The following text describes some of the
389
requirements for such code.
393
<H3><A NAME="SECTION00041200000000000000"></A>
401
Subject to the copyright assignment described below, your patches should be
402
sent in <B>diff -u</B> format relative to the current contents of the Source
403
Forge CVS, which is the easiest to understand and integrate.
404
If you have checked out the source with CVS, you can get a diff using:
408
cvs diff -u > change.patch
412
If you plan on doing significant development work over a period of time,
413
after having your first patch reviewed and approved, you will be eligible
414
for having developer CVS access so that you can commit your changes
415
directly to the CVS repository. To do so, you will need a userid on Source
420
<H3><A NAME="SECTION00041300000000000000"></A>
428
To avoid future problems concerning changing licensing or copyrights, all
429
code contributions more than a hand full of lines must be in the Public
430
Domain or have the copyright assigned to Kern Sibbald as in the current
431
code. Note, prior to November 2004, the code was copyrighted by Kern
432
Sibbald and John Walker.
435
Your name should be clearly indicated as the author of the code, and you
436
must be extremely careful not to violate any copyrights or use other
437
people's code without acknowledging it. The purpose of this requirement is
438
to avoid future copyright, patent, or intellectual property problems. To
439
understand on possible source of future problems, please examine the
440
difficulties Mozilla is (was?) having finding previous contributors at
442
HREF="http://www.mozilla.org/MPL/missing.html">http://www.mozilla.org/MPL/missing.html</A>. The other important issue is to
443
avoid copyright, patent, or intellectual property violations as are currently
444
(May 2003) being claimed by SCO against IBM.
447
Although the copyright will be held by Kern, each developer is expected to
448
indicate that he wrote and/or modified a particular module (or file) and
449
any other sources. The copyright assignment may seem a bit unusual, but in
450
reality, it is not. Most large projects require this. In fact, the
451
paperwork associated with making contributions to the Free Software
452
Foundation, was for me unsurmountable, so hopefully the rather
453
simplified procedure we have will not create any difficulties for
457
If you have any doubts about this, please don't hesitate to ask. The
458
objective is to assure the long term servival of the Bacula project. There
459
is no consideration of personal gain in this request. Our (John and my)
460
track records with Autodesk are easily available; early
461
programmers/founders/contributors and later employees had substantial
462
shares of the company, and no one founder had a controlling part of the
463
company. Even though Microsoft created many millionaires among early
464
employees, the politics of Autodesk (during our time at the helm) is in
465
stark contrast to Microsoft where the majority of the company is still
466
tightly held among a few.
469
Items not needing a copyright assignment are: most small changes,
470
enhancements, or bug fixes of 5-10 lines of code, and documentation.
474
<H3><A NAME="SECTION00041400000000000000"></A>
483
Since this is not a commercial enterprise, and I prefer to believe in
484
everyone's good faith, developers can assign the copyright by explicitly
485
acknowledging that they do so in their first submission. This is
486
sufficient if the developer is independent, or an employee of a
487
not-for-profit organization or a university. Any developer who wants to
488
contribute and is employed by a company must get a copyright assignment
489
from his employer. This is to avoid misunderstandings between the
490
employee, the company, and the Bacula project. A good number of
491
companies have already followed this procedure.
495
<H3><A NAME="SECTION00041500000000000000"></A>
499
Corporate Assignment Statement
504
The following statement must be filled out by the employer, signed, and mailed
505
to my address (please ask me for my address and I will email it -- I'd prefer
506
not to include it here).
510
Copyright release and transfer statement.
511
<On company letter head>
514
Concerning: Copyright release and transfer
516
<Company, Inc> is hereby agrees that <names-of-developers> and
517
other employees of <Company, Inc> are authorized to develop
518
code for and contribute code to the Bacula project for an
519
undetermined period of time. The copyright as well as all
520
other rights to and interests in such contributed code are
521
hereby transferred to Kern Sibbald.
523
Signed in <City, Country> on <Date>:
525
<Name of Person>, <Position in Company, Inc>
528
This release/transfer statement must be sent to:
533
If you wish to retain the full rights to use the software you
534
have contributed in different projects, this is not a problem. Just
535
request a perpetual non-exclusive license before sending in your
536
copyright assignment.
540
<H2><A NAME="SECTION00042000000000000000"></A>
549
The Bacula CVS is kept at Source Forge. If you are not a developer,
550
you only be able to access the public CVS, which runs about 6 hours behind
551
the developer's CVS. If you are a developer, then you will have immediate
552
access to "the" CVS and any changes ("commit") that you make will be
553
immediately seen by other developers.
556
For developer access to the CVS, go to the Bacula page on Source Forge
557
and click on the CVS menu item. Then follow the instructions for
558
installing your SSH public key. It may take a few hours until the
559
key is actually installed, and then you will have access to the CVS.
562
The Bacula CVS is divided into the following CVS "projects" or "modules".
566
bacula (Bacula source code)
567
docs (Bacula documentation)
568
gui (Some of the GUI programs that do not use
569
the Bacula core code)
570
rescue (Bacula CDROM rescue code)
571
regress (Bacula regression scripts)
572
ryol (Roll your own Linux -- incomplete project)
576
Most of you will want either the Bacula source (bacula) and/or the
580
To get the source for a project, you must check it out ("checkout"), which
585
<H3><A NAME="SECTION00042100000000000000"></A>
593
The first time you checkout the code for each project, you will need to
594
tell the cvs program where the CVS repository is. The procedure for
595
checking out code from the public CVS is:
599
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/bacula login
601
Then when it prompts for the password for <B>anonymous</B>, simply
602
press the Enter key. The above command is necessary only once
603
the very first time you login. Then enter the following command:
607
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/bacula co -P bacula
611
The above will place the contents of the bacula module in a directory
612
named <B>bacula</B> in the current directory. This data will come
613
from the public CVS, which typically runs 6 hours to a day behind the
614
developer's CVS. Once you have created a copy of the CVS, you can use
615
the commands listed below under the title CVS Usage.
619
<H3><A NAME="SECTION00042200000000000000"></A>
627
If you are registered as a Bacula developer (contact Kern about this),
628
you may access the developer's CVS using:
633
export CVSROOT=:ext:<nnnn>@cvs.bacula.sourceforge.net:/cvsroot/bacula
637
where you replace <nnnn> by your Source Forge user name.
644
cvs -z3 checkout -d <directory> bacula
648
where you replace <directory> by the name of the directory you want
649
to contain the Bacula source code. If you want the docs, replace the
650
word "bacula" on the above line by "docs" and be sure to put it in
651
a different directory. The -z3 just tells CVS to use compression during
652
the transmission, which makes things go faster. There is no need to
653
do the anonymous login as is the case for non-developers.
656
The above command should generate output that looks a bit like the
661
cvs checkout: Updating bacula
671
<H3><A NAME="SECTION00042300000000000000"></A>
679
The commands that follow with the exception of the <B>commit</B>
680
work the same whether you are accessing the public CVS or
684
Let's assume you used the name "bacula" for the directory, so your
689
cvs -z3 checkout -d bacula bacula
693
When the command is done, simply do:
701
and then build Bacula. You will notice a lot of extra CVS directories
702
in the source code. Don't ever change or delete them, or you will mess up
703
your copy of the project. Also, do not rename or delete any of the files
704
in your copy of the repository or you may have problems. Any files that
705
you change will remain only on your system until you do a "commit", which
709
Let's say you are working in the directory scripts. You would then do:
718
when you are happy with your changes, you can do the following:
722
cd bacula (to your top level directory)
723
cvs diff -u >my-changes.patch
727
When the command is done, you can look in the file my-changes.patch
728
and you will see all the changes you have made to your copy of the
729
repository. Make sure that you understand all the changes that
730
it reports before proceeding. If you modified files that you do
731
do not want to commit to the main repository, you can simply delete
732
them from your local directory, and they will be restored from the
733
repository with the "cvs update" that is shown below. Normally, you
734
should not find changes to files that you do not want to commit, and
735
if you find yourself in that position a lot, you are probably doing
739
Let's assume that now you want to commit your changes to the main CVS
752
When you do this, it will pull any changes made by other developers into
753
your local copy of the repository, and it will check for conflicts. If there
754
are any, it will tell you, and you will need to resolve them. The problems
755
of resolving conflicts are a bit more than this document can cover, but
756
you can examine the files it claims have conflicts and look for <<<<
757
or look in the .rej files that it creates. If you have problems, just ask
758
on the developer's list.
761
Note, doing the above "cvs update" is not absolutely necessary. There are
762
times when you may be working on code and you want to commit it, but you
763
explicitly do not want to move up to the latest version of the code in
764
the CVS. If that is the case, you can simply skip the "cvs update" and
765
do the commit shown below. If the commit fails because of a conflict, it
766
will tell you, and you must resolve the conflict before it will permit
767
you to do the commit.
770
Once your local copy of the repository has been updated, you can now
775
cvs commit -m "Some comment about what you changed"
779
or if you really only want to commit a single file, you can
784
cvs commit -m "comment" scripts/file-I-edited
788
Note, if you have done a build in your directory, or you have added
789
other new files, the commit will update only the files that are
790
actually in the repository. For example, none of the object files
791
are stored in the repository, so when you do a commit, those object
792
files will simply be ignored.
795
If you want to add new files or remove files from the main CVS
796
repository, and you are not experienced with CVS, please ask Kern
797
to do it. If you follow the simple steps above, it is unlikely that
798
you will do any damage to the repository, and if you do, it is always
799
possible for us to recover, but it can be painful.
802
If you are only working in one subdirectory of say the bacula project,
803
for example, the scripts directory, you can do your commit from
804
that subdirectory, and only the changes in that directory and all its
805
subdirectories will be committed. This can be helpful for translators.
806
If you are doing a French translation, you will be working in
807
docs/manual-fr, and if you are always cd'ed into that directory when
808
doing your commits, your commit will effect only that directory. As
809
long as you are careful only to change files that you want changed,
810
you have little to worry about.
814
<H2><A NAME="SECTION00043000000000000000"></A>
818
The Development Cycle
823
As I noted in the 1.38 ReleaseNotes, version 1.38 was different from prior
824
versions because it had a lot more contributions. I expect that this trend
825
will continue. As a consequence, I am going to modify how I normally do
826
development, and instead of making a list of all the features that I will
827
implement in the next version, I will personally sign up for one (maybe
828
two) projects at a time, and when they are complete, I will release a new
832
The difference is that I will have more time to review the new code that is
833
being contributed, and will be able to devote more time to a smaller number
834
of projects (1.38 had too many new features for me to handle correctly).
837
I expect that future release schedules will be much the same, and the
838
number of new features will also be much the same providing that the
839
contributions continue to come -- and they show no signs of let up :-)
843
<B>Feature Requests:</B>
845
In addition, I would like to "formalize" the feature requests a bit.
848
Instead of me maintaining an informal list of everything I run into
849
(kernstodo), I would like to maintain a "formal" list of projects. This
850
means that all new feature requests, including those recently discussed on
851
the email lists, must be formally submitted and approved.
854
Formal submission of feature requests will take two forms:
856
1. non-mandatory, but highly recommended is to discuss proposed new features
859
2. Formal submission of an Feature Request in a special format.
860
I'll give an example of this below, but you can also find it on the web
861
site under "Support -> Feature Requests". Since it takes a bit of time to
862
properly fill out a Feature Request form, you probably should check on the email list
866
Once I receive the Feature Request, I will either accept it, send it back
867
asking for clarification, send it to the email list asking for opinions, or
871
If it is accepted, it will go in the "projects" file (a simple ASCII file)
872
maintained in the main Bacula source directory.
875
<B>Implementation of Feature Requests:</B>
877
Any qualified developer can sign up for a project. The project must have
878
an entry in the projects file, and the developer's name will appear in the
882
<B>How Feature Requests are accepted:</B>
884
Acceptance of Feature Requests depends on several things:
886
1. feedback from users. If it is negative, the Feature Request will probably not be
889
2. the difficulty of the project. A project that is so
890
difficult that I cannot imagine finding someone to implement probably won't
893
3. whether or not the Feature Request fits within the
894
current stategy of Bacula (for example an Feature Request that requests changing the
895
tape to tar format would not be accepted, ...)
898
<B>How Feature Requests are prioritized:</B>
900
Once an Feature Request is accepted, it needs to be implemented. If you
901
can find a developer for it, or one signs up for implementing it, then the
902
Feature Request becomes top priority (at least for that developer).
905
Between releases of Bacula, I will generally solicit Feature Request input
906
for the next version, and by way of this email, I suggest that you send
907
discuss and send in your Feature Requests for the next release. Please
908
verify that the Feature Request is not in the current list (attached to this email).
911
Once users have had several weeks to submit Feature Requests, I will
912
organize them, and request users to vote on them. This will allow fixing
913
prioritizing the Feature Requests. Having a priority is one thing, but
914
getting it implement is another thing -- I am hoping that the Bacula
915
community will take more responsibility for assuring the implementation of
916
accepted Feature Requests.
919
Feature Request format:
921
============= Empty Feature Request form ===========
922
Item n: One line summary ...
924
Origin: Name and email of originator.
927
What: More detailed explanation ...
929
Why: Why it is important ...
931
Notes: Additional notes or features (omit if not used)
932
============== End Feature Request form ==============
937
============= Example Completed Feature Request form ===========
938
Item 1: Implement a Migration job type that will move the job
939
data from one device to another.
940
Origin: Sponsored by Riege Sofware International GmbH. Contact:
941
Daniel Holtkamp <holtkamp at riege dot com>
942
Date: 28 October 2005
943
Status: Partially coded in 1.37 -- much more to do. Assigned to
946
What: The ability to copy, move, or archive data that is on a
947
device to another device is very important.
949
Why: An ISP might want to backup to disk, but after 30 days
950
migrate the data to tape backup and delete it from
951
disk. Bacula should be able to handle this
952
automatically. It needs to know what was put where,
953
and when, and what to migrate -- it is a bit like
954
retention periods. Doing so would allow space to be
955
freed up for current backups while maintaining older
958
Notes: Migration could be triggered by:
962
Highwater size (keep total size)
964
=================================================
969
<H2><A NAME="SECTION00044000000000000000"></A>
978
Typically the simplest way to develop Bacula is to open one xterm window
979
pointing to the source directory you wish to update; a second xterm window at
980
the top source directory level, and a third xterm window at the bacula
981
directory <top>/src/bacula. After making source changes in one of the
982
directories, in the top source directory xterm, build the source, and start
983
the daemons by entering:
989
./startit then in the enter:
995
./gnome-console to start the Console program. Enter any commands for testing.
996
For example: run kernsverify full.
999
Note, the instructions here to use <B>./startit</B> are different from using a
1000
production system where the administrator starts Bacula by entering <B>./bacula start</B>. This difference allows a development version of <B>Bacula</B>
1001
to be run on a computer at the same time that a production system is running.
1002
The <B>./startit</B> strip starts <B>Bacula</B> using a different set of
1003
configuration files, and thus permits avoiding conflicts with any production
1007
To make additional source changes, exit from the Console program, and in the
1008
top source directory, stop the daemons by entering:
1011
./stopit then repeat the process.
1015
<H3><A NAME="SECTION00044100000000000000"></A>
1023
Probably the first thing to do is to turn on debug output.
1026
A good place to start is with a debug level of 20 as in <B>./startit -d20</B>.
1027
The startit command starts all the daemons with the same debug level.
1028
Alternatively, you can start the appropriate daemon with the debug level you
1029
want. If you really need more info, a debug level of 60 is not bad, and for
1030
just about everything a level of 200.
1034
<H3><A NAME="SECTION00044200000000000000"></A>
1043
If you have a serious problem such as a segmentation fault, it can usually be
1044
found quickly using a good multiple thread debugger such as <B>gdb</B>. For
1045
example, suppose you get a segmentation violation in <B>bacula-dir</B>. You
1046
might use the following to find the problem:
1049
<start the Storage and File daemons>
1052
run -f -s -c ./dird.conf
1053
<it dies with a segmentation fault>
1055
The <B>-f</B> option is specified on the <B>run</B> command to inhibit <B>dird</B> from going into the background. You may also want to add the <B>-s</B>
1056
option to the run command to disable signals which can potentially interfere
1060
As an alternative to using the debugger, each <B>Bacula</B> daemon has a built
1061
in back trace feature when a serious error is encountered. It calls the
1062
debugger on itself, produces a back trace, and emails the report to the
1063
developer. For more details on this, please see the chapter in the main Bacula
1064
manual entitled ``What To Do When Bacula Crashes (Kaboom)''.
1068
<H3><A NAME="SECTION00044300000000000000"></A>
1077
Because Bacula runs routinely and unattended on client and server machines, it
1078
may run for a long time. As a consequence, from the very beginning, Bacula
1079
uses SmartAlloc to ensure that there are no memory leaks. To make detection of
1080
memory leaks effective, all Bacula code that dynamically allocates memory MUST
1081
have a way to release it. In general when the memory is no longer needed, it
1082
should be immediately released, but in some cases, the memory will be held
1083
during the entire time that Bacula is executing. In that case, there MUST be a
1084
routine that can be called at termination time that releases the memory. In
1085
this way, we will be able to detect memory leaks. Be sure to immediately
1086
correct any and all memory leaks that are printed at the termination of the
1091
<H3><A NAME="SECTION00044400000000000000"></A>
1100
Kern uses files named 1, 2, ... 9 with any extension as scratch files. Thus
1101
any files with these names are subject to being rudely deleted at any time.
1105
<H3><A NAME="SECTION00044500000000000000"></A>
1109
When Implementing Incomplete Code
1114
Please identify all incomplete code with a comment that contains
1122
where there are three asterisks (*) before and after the word
1123
FIXME (in capitals) and no intervening spaces. This is important as it allows
1124
new programmers to easily recognize where things are partially implemented.
1128
<H3><A NAME="SECTION00044600000000000000"></A>
1132
Bacula Source File Structure
1137
The distribution generally comes as a tar file of the form <B>bacula.x.y.z.tar.gz</B> where x, y, and z are the version, release, and update
1138
numbers respectively.
1141
Once you detar this file, you will have a directory structure as follows:
1148
|- mtx (autochanger control program + tape drive info)
1149
|- sqlite (SQLite database program)
1153
|- pthreads (Native win32 pthreads library -- dll)
1154
|- zlib (Native win32 zlib library)
1155
|- wx (wxWidgets source code)
1158
|- bacula (main source directory containing configuration
1159
| and installation files)
1160
|- autoconf (automatic configuration files, not normally used
1162
|- intl (programs used to translate)
1163
|- platforms (OS specific installation files)
1164
|- redhat (Red Hat installation)
1165
|- solaris (Sun installation)
1166
|- freebsd (FreeBSD installation)
1167
|- irix (Irix installation -- not tested)
1168
|- unknown (Default if system not identified)
1169
|- po (translations of source strings)
1170
|- src (source directory; contains global header files)
1171
|- cats (SQL catalog database interface directory)
1172
|- console (bacula user agent directory)
1173
|- dird (Director daemon)
1174
|- filed (Unix File daemon)
1175
|- win32 (Win32 files to make bacula-fd be a service)
1176
|- findlib (Unix file find library for File daemon)
1177
|- gnome-console (GNOME version of console program)
1178
|- lib (General Bacula library)
1179
|- stored (Storage daemon)
1180
|- tconsole (Tcl/tk console program -- not yet working)
1181
|- testprogs (test programs -- normally only in Kern's tree)
1182
|- tools (Various tool programs)
1183
|- win32 (Native Win32 File daemon)
1184
|- baculafd (Visual Studio project file)
1185
|- compat (compatibility interface library)
1186
|- filed (links to src/filed)
1187
|- findlib (links to src/findlib)
1188
|- lib (links to src/lib)
1189
|- console (beginning of native console program)
1190
|- wx-console (wxWidget console Win32 specific parts)
1191
|- wx-console (wxWidgets console main source program)
1194
|- regress (Regression scripts)
1195
|- bin (temporary directory to hold Bacula installed binaries)
1196
|- build (temporary directory to hold Bacula source)
1197
|- scripts (scripts and .conf files)
1198
|- tests (test scripts)
1199
|- tmp (temporary directory for temp files)
1202
|- docs (documentation directory)
1203
|- developers (Developer's guide)
1204
|- home-page (Bacula's home page source)
1205
|- manual (html document directory)
1206
|- manual-fr (French translation)
1207
|- manual-de (German translation)
1208
|- techlogs (Technical development notes);
1211
|- rescue (Bacula rescue CDROM)
1212
|- linux (Linux rescue CDROM)
1213
|- cdrom (Linux rescue CDROM code)
1215
|- solaris (Solaris rescue -- incomplete)
1216
|- freebsd (FreeBSD rescue -- incomplete)
1219
|- gui (Bacula GUI projects)
1220
|- bacula-web (Bacula web php management code)
1221
|- bimagemgr (Web application for burning CDROMs)
1225
<H3><A NAME="SECTION00044700000000000000"></A>
1234
Please carefully follow the scheme defined below as it permits in general only
1235
two header file includes per C file, and thus vastly simplifies programming.
1236
With a large complex project like Bacula, it isn't always easy to ensure that
1237
the right headers are invoked in the right order (there are a few kludges to
1238
make this happen -- i.e. in a few include files because of the chicken and egg
1239
problem, certain references to typedefs had to be replaced with <B>void</B> ).
1242
Every file should include <B>bacula.h</B>. It pulls in just about everything,
1243
with very few exceptions. If you have system dependent ifdefing, please do it
1244
in <B>baconfig.h</B>. The version number and date are kept in <B>version.h</B>.
1247
Each of the subdirectories (console, cats, dird, filed, findlib, lib, stored,
1248
...) contains a single directory dependent include file generally the name of
1249
the directory, which should be included just after the include of <B>bacula.h</B>. This file (for example, for the dird directory, it is <B>dird.h</B>)
1250
contains either definitions of things generally needed in this directory, or
1251
it includes the appropriate header files. It always includes <B>protos.h</B>.
1255
Each subdirectory contains a header file named <B>protos.h</B>, which contains
1256
the prototypes for subroutines exported by files in that directory. <B>protos.h</B> is always included by the main directory dependent include file.
1260
<H3><A NAME="SECTION00044800000000000000"></A>
1264
Programming Standards
1269
For the most part, all code should be written in C unless there is a burning
1270
reason to use C++, and then only the simplest C++ constructs will be used.
1271
Note, Bacula is slowly evolving to use more and more C++.
1274
Code should have some documentation -- not a lot, but enough so that I can
1275
understand it. Look at the current code, and you will see that I document more
1276
than most, but am definitely not a fanatic.
1279
I prefer simple linear code where possible. Gotos are strongly discouraged
1280
except for handling an error to either bail out or to retry some code, and
1281
such use of gotos can vastly simplify the program.
1284
Remember this is a C program that is migrating to a <B>tiny</B> subset of C++,
1285
so be conservative in your use of C++ features.
1289
<H3><A NAME="SECTION00044900000000000000"></A>
1300
<LI>STL -- it is totally incomprehensible.
1307
<H3><A NAME="SECTION000441000000000000000"></A>
1318
<LI>Using <B>void *</B> because this generally means that one must
1319
using casting, and in C++ casting is rather ugly. It is OK to use
1320
void * to pass structure address where the structure is not known
1321
to the routines accepting the packet (typically callback routines).
1322
However, declaring "void *buf" is a bad idea. Please use the
1323
correct types whenever possible.
1325
<LI>Using undefined storage specifications such as (short, int, long,
1326
long long, size_t ...). The problem with all these is that the number of bytes
1327
they allocate depends on the compiler and the system. Instead use
1328
Bacula's types (int8_t, uint8_t, int32_t, uint32_t, int64_t, and
1329
uint64_t). This guarantees that the variables are given exactly the
1330
size you want. Please try at all possible to avoid using size_t ssize_t
1331
and the such. They are very system dependent. However, some system
1332
routines may need them, so their use is often unavoidable.
1334
<LI>Returning a malloc'ed buffer from a subroutine -- someone will forget
1337
<LI>Using reference variables -- it allows subroutines to create side
1338
effects. Reference variables are OK, if you are sure the variable
1339
*always* exists, and you are sure you can handle the side effects of
1340
a subroutine changing the "pointer".
1342
<LI>Heap allocation (malloc) unless needed -- it is expensive.
1344
<LI>Templates -- they can create portability problems.
1346
<LI>Fancy or tricky C or C++ code, unless you give a good explanation of
1349
<LI>Too much inheritance -- it can complicate the code, and make reading it
1350
difficult (unless you are in love with colons)
1357
<H3><A NAME="SECTION000441100000000000000"></A>
1361
Do Use Whenever Possible
1368
<LI>Locking and unlocking within a single subroutine.
1370
<LI>Malloc and free within a single subroutine.
1372
<LI>Comments and global explanations on what your code or algorithm does.
1379
<H3><A NAME="SECTION000441200000000000000"></A>
1388
I cannot stand code indented 8 columns at a time. This makes the code
1389
unreadable. Even 4 at a time uses a lot of space, so I have adopted indenting
1390
3 spaces at every level. Note, indention is the visual appearance of the
1391
source on the page, while tabbing is replacing a series of up to 8 spaces from
1395
The closest set of parameters for the Linux <B>indent</B> program that will
1396
produce reasonably indented code are:
1400
-nbad -bap -bbo -nbc -br -brs -c36 -cd36 -ncdb -ce -ci3 -cli0
1401
-cp36 -d0 -di1 -ndj -nfc1 -nfca -hnl -i3 -ip0 -l85 -lp -npcs
1402
-nprs -npsl -saf -sai -saw -nsob -nss -nbc -ncs -nbfda
1405
You can put the above in your .indent.pro file, and then just invoke indent on
1406
your file. However, be warned. This does not produce perfect indenting, and it
1407
will mess up C++ class statements pretty badly.
1410
Braces are required in all if statements (missing in some very old code). To
1411
avoid generating too many lines, the first brace appears on the first line
1412
(e.g. of an if), and the closing brace is on a line by itself. E.g.
1421
Just follow the convention in the code. Originally I indented case clauses
1422
under a switch(), but now I prefer non-indented cases.
1438
Avoid using // style comments except for temporary code or turning off debug
1439
code. Standard C comments are preferred (this also keeps the code closer to
1443
Attempt to keep all lines less than 85 characters long so that the whole line
1444
of code is readable at one time. This is not a rigid requirement.
1447
Always put a brief description at the top of any new file created describing
1448
what it does and including your name and the date it was first written. Please
1449
don't forget any Copyrights and acknowledgments if it isn't 100% your code.
1450
Also, include the Bacula copyright notice that is in <B>src/c</B>.
1453
In general you should have two includes at the top of the an include for the
1454
particular directory the code is in, for includes are needed, but this should
1458
In general (except for self-contained packages), prototypes should all be put
1459
in <B>protos.h</B> in each directory.
1462
Always put space around assignment and comparison operators.
1472
but your can compress things in a <B>for</B> statement:
1476
for (i=0; i < del.num_ids; i++) {
1480
Don't overuse the inline if (?:). A full <B>if</B> is preferred, except in a
1481
print statement, e.g.:
1485
if (ua->verbose \&& del.num_del != 0) {
1486
bsendmsg(ua, _("Pruned %d %s on Volume %s from catalog.\n"), del.num_del,
1487
del.num_del == 1 ? "Job" : "Jobs", mr->VolumeName);
1491
Leave a certain amount of debug code (Dmsg) in code you submit, so that future
1492
problems can be identified. This is particularly true for complicated code
1493
likely to break. However, try to keep the debug code to a minimum to avoid
1494
bloating the program and above all to keep the code readable.
1497
Please keep the same style in all new code you develop. If you include code
1498
previously written, you have the option of leaving it with the old indenting
1499
or re-indenting it. If the old code is indented with 8 spaces, then please
1500
re-indent it to Bacula standards.
1503
If you are using <B>vim</B>, simply set your tabstop to 8 and your shiftwidth
1508
<H3><A NAME="SECTION000441300000000000000"></A>
1516
Tabbing (inserting the tab character in place of spaces) is as normal on all
1517
Unix systems -- a tab is converted space up to the next column multiple of 8.
1518
My editor converts strings of spaces to tabs automatically -- this results in
1519
significant compression of the files. Thus, you can remove tabs by replacing
1520
them with spaces if you wish. Please don't confuse tabbing (use of tab
1521
characters) with indenting (visual alignment of the code).
1525
<H3><A NAME="SECTION000441400000000000000"></A>
1545
They are system dependent and un-safe. These should be replaced by the Bacula
1550
char *bstrncpy(char *dest, char *source, int dest_size);
1551
char *bstrncat(char *dest, char *source, int dest_size);
1552
int bsnprintf(char *buf, int32_t buf_len, const char *fmt, ...);
1553
int bvsnprintf(char *str, int32_t size, const char *format, va_list ap);
1556
See src/lib/bsys.c for more details on these routines.
1559
Don't use the <B>%lld</B> or the <B>%q</B> printf format editing types to edit
1560
64 bit integers -- they are not portable. Instead, use <B>%s</B> with <B>edit_uint64()</B>. For example:
1565
uint64_t num = something;
1567
bsnprintf(buf, sizeof(buf), "Num=%s\n", edit_uint64(num, ed1));
1570
The edit buffer <B>ed1</B> must be at least 27 bytes long to avoid overflow.
1571
See src/lib/edit.c for more details. If you look at the code, don't start
1572
screaming that I use <B>lld</B>. I actually use subtle trick taught to me by
1573
John Walker. The <B>lld</B> that appears in the editing routine is actually
1574
<B>#define</B> to a what is needed on your OS (usually ``lld'' or ``q'') and
1575
is defined in autoconf/configure.in for each OS. C string concatenation causes
1576
the appropriate string to be concatenated to the ``%''.
1579
Also please don't use the STL or Templates or any complicated C++ code.
1583
<H3><A NAME="SECTION000441500000000000000"></A>
1592
Currently, there are five classes of messages: Debug, Error, Job, Memory,
1597
<H3><A NAME="SECTION000441600000000000000"></A>
1606
Debug messages are designed to be turned on at a specified debug level and are
1607
always sent to STDOUT. There are designed to only be used in the development
1608
debug process. They are coded as:
1611
DmsgN(level, message, arg1, ...) where the N is a number indicating how many
1612
arguments are to be substituted into the message (i.e. it is a count of the
1613
number arguments you have in your message -- generally the number of percent
1614
signs (%)). <B>level</B> is the debug level at which you wish the message to
1615
be printed. message is the debug message to be printed, and arg1, ... are the
1616
arguments to be substituted. Since not all compilers support #defines with
1617
varargs, you must explicitly specify how many arguments you have.
1620
When the debug message is printed, it will automatically be prefixed by the
1621
name of the daemon which is running, the filename where the Dmsg is, and the
1622
line number within the file.
1625
Some actual examples are:
1628
Dmsg2(20, ``MD5len=%d MD5=%s\n'', strlen(buf), buf);
1631
Dmsg1(9, ``Created client %s record\n'', client->hdr.name);
1635
<H3><A NAME="SECTION000441700000000000000"></A>
1644
Error messages are messages that are related to the daemon as a whole rather
1645
than a particular job. For example, an out of memory condition my generate an
1646
error message. They should be very rarely needed. In general, you should be
1647
using Job and Job Queued messages (Jmsg and Qmsg). They are coded as:
1650
EmsgN(error-code, level, message, arg1, ...) As with debug messages, you must
1651
explicitly code the of arguments to be substituted in the message. error-code
1652
indicates the severity or class of error, and it may be one of the following:
1656
<TABLE CELLPADDING=3>
1657
<TR><TD ALIGN="LEFT"><B>M_ABORT</B></TD>
1658
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=216>Causes the daemon to immediately abort. This should be
1659
used only in extreme cases. It attempts to produce a traceback.</TD>
1661
<TR><TD ALIGN="LEFT"><B>M_ERROR_TERM</B></TD>
1662
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=216>Causes the daemon to immediately terminate. This
1663
should be used only in extreme cases. It does not produce a traceback.</TD>
1665
<TR><TD ALIGN="LEFT"><B>M_FATAL</B></TD>
1666
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=216>Causes the daemon to terminate the current job, but the
1667
daemon keeps running</TD>
1669
<TR><TD ALIGN="LEFT"><B>M_ERROR</B></TD>
1670
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=216>Reports the error. The daemon and the job continue
1673
<TR><TD ALIGN="LEFT"><B>M_WARNING</B></TD>
1674
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=216>Reports an warning message. The daemon and the job
1675
continue running</TD>
1677
<TR><TD ALIGN="LEFT"><B>M_INFO</B></TD>
1678
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=216>Reports an informational message.
1685
There are other error message classes, but they are in a state of being
1686
redesigned or deprecated, so please do not use them. Some actual examples are:
1689
Emsg1(M_ABORT, 0, ``Cannot create message thread: %s\n'',
1693
Emsg3(M_WARNING, 0, ``Connect to File daemon %s at %s:%d failed. Retrying
1694
...\n'', client->hdr.name, client->address,
1698
Emsg3(M_FATAL, 0, ``bdird<filed: bad response from Filed to %s command:
1699
%d %s\n'', cmd, n, strerror(errno));
1703
<H3><A NAME="SECTION000441800000000000000"></A>
1712
Job messages are messages that pertain to a particular job such as a file that
1713
could not be saved, or the number of files and bytes that were saved. They
1716
Jmsg(jcr, M\_FATAL, 0, "Text of message");
1718
A Jmsg with M_FATAL will fail the job. The Jmsg() takes varargs so can
1719
have any number of arguments for substituted in a printf like format.
1720
Output from the Jmsg() will go to the Job report.
1722
If the Jmsg is followed with a number such as Jmsg1(...), the number
1723
indicates the number of arguments to be substituted (varargs is not
1724
standard for #defines), and what is more important is that the file and
1725
line number will be prefixed to the message. This permits a sort of debug
1730
<H3><A NAME="SECTION000441900000000000000"></A>
1737
Queued Job messages are similar to Jmsg()s except that the message is
1738
Queued rather than immediately dispatched. This is necessary within the
1739
network subroutines and in the message editing routines. This is to prevent
1740
recursive loops, and to ensure that messages can be delivered even in the
1741
event of a network error.
1745
<H3><A NAME="SECTION000442000000000000000"></A>
1754
Memory messages are messages that are edited into a memory buffer. Generally
1755
they are used in low level routines such as the low level device file dev.c in
1756
the Storage daemon or in the low level Catalog routines. These routines do not
1757
generally have access to the Job Control Record and so they return error
1758
messages reformatted in a memory buffer. Mmsg() is the way to do this.
1762
<H1><A NAME="SECTION00050000000000000000"></A>
1763
<A NAME="_PlatformChapter"></A><A NAME="937"></A>
1772
<H2><A NAME="SECTION00051000000000000000"></A>
1780
This chapter describes the requirements for having a
1781
supported platform (Operating System). In general, Bacula is
1782
quite portable. It supports 32 and 64 bit architectures as well
1783
as bigendian and littleendian machines. For full
1784
support, the platform (Operating System) must implement POSIX Unix
1785
system calls. However, for File daemon support only, a small
1786
compatibility library can be written to support almost any
1790
Currently Linux, FreeBSD, and Solaris are fully supported
1791
platforms, which means that the code has been tested on those
1792
machines and passes a full set of regression tests.
1795
In addition, the Windows File daemon is supported on most versions
1796
of Windows, and finally, there are a number of other platforms
1797
where the File daemon (client) is known to run: NetBSD, OpenBSD,
1802
<H2><A NAME="SECTION00052000000000000000"></A>
1806
Requirements to become a Supported Platform
1811
As mentioned above, in order to become a fully supported platform, it
1812
must support POSIX Unix system calls. In addition, the following
1813
requirements must be met:
1818
<LI>The principal developer (currently Kern) must have
1819
non-root ssh access to a test machine running the platform.
1821
<LI>The ideal requirements and minimum requirements
1822
for this machine are given below.
1824
<LI>There must be a defined platform champion who is normally
1825
a system administrator for the machine that is available. This
1826
person need not be a developer/programmer but must be familiar
1827
with system administration of the platform.
1829
<LI>There must be at least one person designated who will
1830
run regression tests prior to each release. Releases occur
1831
approximately once every 6 months, but can be more frequent.
1832
It takes at most a day's effort to setup the regression scripts
1833
in the beginning, and after that, they can either be run daily
1834
or on demand before a release. Running the regression scripts
1835
involves only one or two command line commands and is fully
1838
<LI>Ideally there are one or more persons who will package
1839
each Bacula release.
1841
<LI>Ideally there are one or more developers who can respond to
1842
and fix platform specific bugs.
1847
Ideal requirements for a test machine:
1850
<LI>The principal developer will have non-root ssh access to
1851
the test machine at all times.
1853
<LI>The pricipal developer will have a root password.
1855
<LI>The test machine will provide approximately 200 MB of
1856
disk space for continual use.
1858
<LI>The test machine will have approximately 500 MB of free
1859
disk space for temporary use.
1861
<LI>The test machine will run the most common version of the OS.
1863
<LI>The test machine will have an autochanger of DDS-4 technology
1864
or later having two or more tapes.
1866
<LI>The test machine will have MySQL and/or PostgreSQL database
1867
access for account "bacula" available.
1869
<LI>The test machine will have sftp access.
1871
<LI>The test machine will provide an smtp server.
1876
Minimum requirements for a test machine:
1879
<LI>The principal developer will have non-root ssh access to
1880
the test machine when requested approximately once a month.
1882
<LI>The pricipal developer not have root access.
1884
<LI>The test machine will provide approximately 80 MB of
1885
disk space for continual use.
1887
<LI>The test machine will have approximately 300 MB of free
1888
disk space for temporary use.
1890
<LI>The test machine will run the the OS.
1892
<LI>The test machine will have a tape drive of DDS-4 technology
1893
or later that can be scheduled for access.
1895
<LI>The test machine will not have MySQL and/or PostgreSQL database
1898
<LI>The test machine will have no sftp access.
1900
<LI>The test machine will provide no email access.
1905
Bare bones test machine requirements:
1908
<LI>The test machine is available only to a designated
1909
test person (your own machine).
1911
<LI>The designated test person runs the regession
1914
<LI>The test machine has a tape drive available.
1920
<H1><A NAME="SECTION00060000000000000000"></A>
1921
<A NAME="_ChapterStart2"></A><A NAME="985"></A>
1930
<H2><A NAME="SECTION00061000000000000000"></A>
1938
This document describes the protocols used between the various daemons. As
1939
Bacula has developed, it has become quite out of date. The general idea still
1940
holds true, but the details of the fields for each command, and indeed the
1941
commands themselves have changed considerably.
1944
It is intended to be a technical discussion of the general daemon protocols
1945
and as such is not targeted at end users but rather at developers and system
1946
administrators that want or need to know more of the working details of <B>Bacula</B>.
1950
<H2><A NAME="SECTION00062000000000000000"></A>
1954
Low Level Network Protocol
1959
At the lowest level, the network protocol is handled by <B>BSOCK</B> packets
1960
which contain a lot of information about the status of the network connection:
1961
who is at the other end, etc. Each basic <B>Bacula</B> network read or write
1962
actually consists of two low level network read/writes. The first write always
1963
sends four bytes of data in machine independent byte order. If data is to
1964
follow, the first four bytes are a positive non-zero integer indicating the
1965
length of the data that follow in the subsequent write. If the four byte
1966
integer is zero or negative, it indicates a special request, a sort of network
1967
signaling capability. In this case, no data packet will follow. The low level
1968
BSOCK routines expect that only a single thread is accessing the socket at a
1969
time. It is advised that multiple threads do not read/write the same socket.
1970
If you must do this, you must provide some sort of locking mechanism. It would
1971
not be appropriate for efficiency reasons to make every call to the BSOCK
1972
routines lock and unlock the packet.
1976
<H2><A NAME="SECTION00063000000000000000"></A>
1980
General Daemon Protocol
1985
In general, all the daemons follow the following global rules. There may be
1986
exceptions depending on the specific case. Normally, one daemon will be
1987
sending commands to another daemon (specifically, the Director to the Storage
1988
daemon and the Director to the File daemon).
1993
<LI>Commands are always ASCII commands that are upper/lower case dependent
1994
as well as space sensitive.
1996
<LI>All binary data is converted into ASCII (either with printf statements
1997
or using base64 encoding).
1999
<LI>All responses to commands sent are always prefixed with a return
2000
numeric code where codes in the 1000's are reserved for the Director, the
2001
2000's are reserved for the File daemon, and the 3000's are reserved for the
2004
<LI>Any response that is not prefixed with a numeric code is a command (or
2005
subcommand if you like) coming from the other end. For example, while the
2006
Director is corresponding with the Storage daemon, the Storage daemon can
2007
request Catalog services from the Director. This convention permits each side
2008
to send commands to the other daemon while simultaneously responding to
2011
<LI>Any response that is of zero length, depending on the context, either
2012
terminates the data stream being sent or terminates command mode prior to
2013
closing the connection.
2015
<LI>Any response that is of negative length is a special sign that normally
2016
requires a response. For example, during data transfer from the File daemon
2017
to the Storage daemon, normally the File daemon sends continuously without
2018
intervening reads. However, periodically, the File daemon will send a packet
2019
of length -1 indicating that the current data stream is complete and that the
2020
Storage daemon should respond to the packet with an OK, ABORT JOB, PAUSE,
2021
etc. This permits the File daemon to efficiently send data while at the same
2022
time occasionally ``polling'' the Storage daemon for his status or any
2026
Currently, these negative lengths are specific to the daemon, but shortly,
2027
the range 0 to -999 will be standard daemon wide signals, while -1000 to
2028
-1999 will be for Director user, -2000 to -2999 for the File daemon, and
2029
-3000 to -3999 for the Storage daemon.
2035
<H2><A NAME="SECTION00064000000000000000"></A>
2039
The Protocol Used Between the Director and the Storage Daemon
2044
Before sending commands to the File daemon, the Director opens a Message
2045
channel with the Storage daemon, identifies itself and presents its password.
2046
If the password check is OK, the Storage daemon accepts the Director. The
2047
Director then passes the Storage daemon, the JobId to be run as well as the
2048
File daemon authorization (append, read all, or read for a specific session).
2049
The Storage daemon will then pass back to the Director a enabling key for this
2050
JobId that must be presented by the File daemon when opening the job. Until
2051
this process is complete, the Storage daemon is not available for use by File
2057
DR: makes connection
2058
DR: Hello <Director-name> calling <password>
2060
DR: JobId=nnn Allow=(append, read) Session=(*, SessionId)
2061
(Session not implemented yet)
2062
SD: 3000 OK Job Authorization=<password>
2063
DR: use device=<device-name> media_type=<media-type>
2064
pool_name=<pool-name> pool_type=<pool_type>
2065
SD: 3000 OK use device
2068
For the Director to be authorized, the <Director-name> and the
2069
<password> must match the values in one of the Storage daemon's
2070
Director resources (there may be several Directors that can access a single
2075
<H2><A NAME="SECTION00065000000000000000"></A>
2079
The Protocol Used Between the Director and the File Daemon
2084
A typical conversation might look like the following:
2089
DR: makes connection
2090
DR: Hello <Director-name> calling <password>
2092
DR: JobId=nnn Authorization=<password>
2094
DR: storage address = <Storage daemon address> port = <port-number>
2095
name = <DeviceName> mediatype = <MediaType>
2098
DR: <directory1>
2099
DR: <directory2>
2104
DR: <directory1>
2105
DR: <directory2>
2113
FD: Attribute record for each file as sent to the
2114
Storage daemon (described above).
2116
FD: <append close responses from Storage daemon>
2118
3000 OK Volumes = <number of volumes>
2119
3001 Volume = <volume-id> <start file> <start block>
2120
<end file> <end block> <volume session-id>
2121
3002 Volume data = <date/time of last write> <Number bytes written>
2122
<number errors>
2123
... additional Volume / Volume data pairs for volumes 2 .. n
2129
<H2><A NAME="SECTION00066000000000000000"></A>
2133
The Save Protocol Between the File Daemon and the Storage Daemon
2138
Once the Director has send a <B>save</B> command to the File daemon, the File
2139
daemon will contact the Storage daemon to begin the save.
2142
In what follows: FD: refers to information set via the network from the File
2143
daemon to the Storage daemon, and SD: refers to information set from the
2144
Storage daemon to the File daemon.
2148
<H3><A NAME="SECTION00066100000000000000"></A>
2152
Command and Control Information
2157
Command and control information is exchanged in human readable ASCII commands.
2162
SD: makes connection
2163
FD: append open session = <JobId> [<password>]
2164
SD: 3000 OK ticket = <number>
2165
FD: append data <ticket-number>
2166
SD: 3000 OK data address = <IPaddress> port = <port>
2170
<H3><A NAME="SECTION00066200000000000000"></A>
2179
The Data information consists of the file attributes and data to the Storage
2180
daemon. For the most part, the data information is sent one way: from the File
2181
daemon to the Storage daemon. This allows the File daemon to transfer
2182
information as fast as possible without a lot of handshaking and network
2186
However, from time to time, the File daemon needs to do a sort of checkpoint
2187
of the situation to ensure that everything is going well with the Storage
2188
daemon. To do so, the File daemon sends a packet with a negative length
2189
indicating that he wishes the Storage daemon to respond by sending a packet of
2190
information to the File daemon. The File daemon then waits to receive a packet
2191
from the Storage daemon before continuing.
2194
All data sent are in binary format except for the header packet, which is in
2195
ASCII. There are two packet types used data transfer mode: a header packet,
2196
the contents of which are known to the Storage daemon, and a data packet, the
2197
contents of which are never examined by the Storage daemon.
2200
The first data packet to the Storage daemon will be an ASCII header packet
2201
consisting of the following data.
2204
<File-Index> <Stream-Id> <Info> where <B><File-Index></B> is a sequential number beginning from one that
2205
increments with each file (or directory) sent.
2208
where <B><Stream-Id></B> will be 1 for the Attributes record and 2 for
2209
uncompressed File data. 3 is reserved for the MD5 signature for the file.
2212
where <B><Info></B> transmit information about the Stream to the
2213
Storage Daemon. It is a character string field where each character has a
2214
meaning. The only character currently defined is 0 (zero), which is simply a
2215
place holder (a no op). In the future, there may be codes indicating
2216
compressed data, encrypted data, etc.
2219
Immediately following the header packet, the Storage daemon will expect any
2220
number of data packets. The series of data packets is terminated by a zero
2221
length packet, which indicates to the Storage daemon that the next packet will
2222
be another header packet. As previously mentioned, a negative length packet is
2223
a request for the Storage daemon to temporarily enter command mode and send a
2224
reply to the File daemon. Thus an actual conversation might contain the
2225
following exchanges:
2229
FD: <1 1 0> (header packet)
2230
FD: <data packet containing file-attributes>
2233
FD: <multiple data packets containing the file data>
2234
FD: Packet length = -1
2237
FD: <data packet containing file-attributes>
2240
FD: <multiple data packets containing the file data>
2243
FD: append end session <ticket-number>
2245
FD: append close session <ticket-number>
2246
SD: 3000 OK Volumes = <number of volumes>
2247
SD: 3001 Volume = <volumeid> <start file> <start block>
2248
<end file> <end block> <volume session-id>
2249
SD: 3002 Volume data = <date/time of last write> <Number bytes written>
2250
<number errors>
2251
SD: ... additional Volume / Volume data pairs for
2256
The information returned to the File daemon by the Storage daemon in response
2257
to the <B>append close session</B> is transmit in turn to the Director.
2261
<H1><A NAME="SECTION00070000000000000000"></A>
2262
<A NAME="_ChapterStart6"></A><A NAME="1173"></A>
2265
Director Services Daemon
2270
This chapter is intended to be a technical discussion of the Director services
2271
and as such is not targeted at end users but rather at developers and system
2272
administrators that want or need to know more of the working details of <B>Bacula</B>.
2275
The <B>Bacula Director</B> services consist of the program that supervises all
2276
the backup and restore operations.
2283
<H1><A NAME="SECTION00080000000000000000"></A>
2284
<A NAME="_ChapterStart11"></A><A NAME="1194"></A>
2287
File Services Daemon
2292
Please note, this section is somewhat out of date as the code has evolved
2293
significantly. The basic idea has not changed though.
2296
This chapter is intended to be a technical discussion of the File daemon
2297
services and as such is not targeted at end users but rather at developers and
2298
system administrators that want or need to know more of the working details of
2302
The <B>Bacula File Services</B> consist of the programs that run on the system
2303
to be backed up and provide the interface between the Host File system and
2304
Bacula -- in particular, the Director and the Storage services.
2307
When time comes for a backup, the Director gets in touch with the File daemon
2308
on the client machine and hands it a set of ``marching orders'' which, if
2309
written in English, might be something like the following:
2312
OK, <B>File daemon</B>, it's time for your daily incremental backup. I want you
2313
to get in touch with the Storage daemon on host archive.mysite.com and perform
2314
the following save operations with the designated options. You'll note that
2315
I've attached include and exclude lists and patterns you should apply when
2316
backing up the file system. As this is an incremental backup, you should save
2317
only files modified since the time you started your last backup which, as you
2318
may recall, was 2000-11-19-06:43:38. Please let me know when you're done and
2319
how it went. Thank you.
2322
So, having been handed everything it needs to decide what to dump and where to
2323
store it, the File daemon doesn't need to have any further contact with the
2324
Director until the backup is complete providing there are no errors. If there
2325
are errors, the error messages will be delivered immediately to the Director.
2326
While the backup is proceeding, the File daemon will send the file coordinates
2327
and data for each file being backed up to the Storage daemon, which will in
2328
turn pass the file coordinates to the Director to put in the catalog.
2331
During a <B>Verify</B> of the catalog, the situation is different, since the
2332
File daemon will have an exchange with the Director for each file, and will
2333
not contact the Storage daemon.
2336
A <B>Restore</B> operation will be very similar to the <B>Backup</B> except that
2337
during the <B>Restore</B> the Storage daemon will not send storage coordinates
2338
to the Director since the Director presumably already has them. On the other
2339
hand, any error messages from either the Storage daemon or File daemon will
2340
normally be sent directly to the Directory (this, of course, depends on how
2341
the Message resource is defined).
2345
<H2><A NAME="SECTION00081000000000000000"></A>
2349
Commands Received from the Director for a Backup
2358
<H2><A NAME="SECTION00082000000000000000"></A>
2362
Commands Received from the Director for a Restore
2371
<H1><A NAME="SECTION00090000000000000000"></A>
2372
<A NAME="_ChapterStart3"></A><A NAME="1260"></A>
2375
Storage Daemon Design
2380
This chapter is intended to be a technical discussion of the Storage daemon
2381
services and as such is not targeted at end users but rather at developers and
2382
system administrators that want or need to know more of the working details of
2386
This document is somewhat out of date.
2390
<H2><A NAME="SECTION00091000000000000000"></A>
2394
SD Design Introduction
2399
The Bacula Storage daemon provides storage resources to a Bacula installation.
2400
An individual Storage daemon is associated with a physical permanent storage
2401
device (for example, a tape drive, CD writer, tape changer or jukebox, etc.),
2402
and may employ auxiliary storage resources (such as space on a hard disk file
2403
system) to increase performance and/or optimize use of the permanent storage
2407
Any number of storage daemons may be run on a given machine; each associated
2408
with an individual storage device connected to it, and BACULA operations may
2409
employ storage daemons on any number of hosts connected by a network, local or
2410
remote. The ability to employ remote storage daemons (with appropriate
2411
security measures) permits automatic off-site backup, possibly to publicly
2412
available backup repositories.
2416
<H2><A NAME="SECTION00092000000000000000"></A>
2420
SD Development Outline
2425
In order to provide a high performance backup and restore solution that scales
2426
to very large capacity devices and networks, the storage daemon must be able
2427
to extract as much performance from the storage device and network with which
2428
it interacts. In order to accomplish this, storage daemons will eventually
2429
have to sacrifice simplicity and painless portability in favor of techniques
2430
which improve performance. My goal in designing the storage daemon protocol
2431
and developing the initial prototype storage daemon is to provide for these
2432
additions in the future, while implementing an initial storage daemon which is
2433
very simple and portable to almost any POSIX-like environment. This original
2434
storage daemon (and its evolved descendants) can serve as a portable solution
2435
for non-demanding backup requirements (such as single servers of modest size,
2436
individual machines, or small local networks), while serving as the starting
2437
point for development of higher performance configurable derivatives which use
2438
techniques such as POSIX threads, shared memory, asynchronous I/O, buffering
2439
to high-speed intermediate media, and support for tape changers and jukeboxes.
2443
<H2><A NAME="SECTION00093000000000000000"></A>
2447
SD Connections and Sessions
2452
A client connects to a storage server by initiating a conventional TCP
2453
connection. The storage server accepts the connection unless its maximum
2454
number of connections has been reached or the specified host is not granted
2455
access to the storage server. Once a connection has been opened, the client
2456
may make any number of Query requests, and/or initiate (if permitted), one or
2457
more Append sessions (which transmit data to be stored by the storage daemon)
2458
and/or Read sessions (which retrieve data from the storage daemon).
2461
Most requests and replies sent across the connection are simple ASCII strings,
2462
with status replies prefixed by a four digit status code for easier parsing.
2463
Binary data appear in blocks stored and retrieved from the storage. Any
2464
request may result in a single-line status reply of ``<TT>3201 Notification pending</TT>'', which indicates the client must send a ``Query notification''
2465
request to retrieve one or more notifications posted to it. Once the
2466
notifications have been returned, the client may then resubmit the request
2467
which resulted in the 3201 status.
2470
The following descriptions omit common error codes, yet to be defined, which
2471
can occur from most or many requests due to events like media errors,
2472
restarting of the storage daemon, etc. These details will be filled in, along
2473
with a comprehensive list of status codes along with which requests can
2474
produce them in an update to this document.
2478
<H3><A NAME="SECTION00093100000000000000"></A>
2488
<DT><STRONG>append open session = <JobId> [ <Password> ] </STRONG></DT>
2489
<DD><A NAME="1296"></A>
2490
A data append session is opened with the Job ID given by <I>JobId</I> with
2491
client password (if required) given by <I>Password</I>. If the session is
2492
successfully opened, a status of <TT>3000 OK</TT> is returned with a ``<TT>ticket = </TT><I>number</I>'' reply used to identify subsequent messages in the
2493
session. If too many sessions are open, or a conflicting session (for
2494
example, a read in progress when simultaneous read and append sessions are
2495
not permitted), a status of ``<TT>3502 Volume busy</TT>'' is returned. If no
2496
volume is mounted, or the volume mounted cannot be appended to, a status of
2497
``<TT>3503 Volume not mounted</TT>'' is returned.
2501
<DT><STRONG>append data = <ticket-number> </STRONG></DT>
2502
<DD><A NAME="1306"></A>
2503
If the append data is accepted, a status of <TT>3000 OK data address =
2504
<IPaddress> port = <port></TT> is returned, where the <TT>IPaddress</TT> and <TT>port</TT> specify the IP address and port number of the data
2505
channel. Error status codes are <TT>3504 Invalid ticket number</TT> and <TT>3505 Session aborted</TT>, the latter of which indicates the entire append
2506
session has failed due to a daemon or media error.
2509
Once the File daemon has established the connection to the data channel
2510
opened by the Storage daemon, it will transfer a header packet followed by
2511
any number of data packets. The header packet is of the form:
2514
<TT><file-index> <stream-id> <info></TT>
2517
The details are specified in the
2518
<A HREF="#_ChapterStart2">Daemon Protocol</A> section of this
2523
<DT><STRONG>*append abort session = <ticket-number> </STRONG></DT>
2524
<DD><A NAME="1325"></A>
2525
The open append session with ticket <I>ticket-number</I> is aborted; any blocks
2526
not yet written to permanent media are discarded. Subsequent attempts to
2527
append data to the session will receive an error status of <TT>3505 Session aborted</TT>.
2531
<DT><STRONG>append end session = <ticket-number> </STRONG></DT>
2532
<DD><A NAME="1330"></A>
2533
The open append session with ticket <I>ticket-number</I> is marked complete; no
2534
further blocks may be appended. The storage daemon will give priority to
2535
saving any buffered blocks from this session to permanent media as soon as
2540
<DT><STRONG>append close session = <ticket-number> </STRONG></DT>
2541
<DD><A NAME="1334"></A>
2542
The append session with ticket <I>ticket</I> is closed. This message does not
2543
receive an <TT>3000 OK</TT> reply until all of the content of the session are
2544
stored on permanent media, at which time said reply is given, followed by a
2545
list of volumes, from first to last, which contain blocks from the session,
2546
along with the first and last file and block on each containing session data
2547
and the volume session key identifying data from that session in lines with
2548
the following format:
2551
<TT><TT>Volume = </TT><Volume-id> <start-file>
2552
<start-block> <end-file> <end-block>
2553
<volume-session-id></TT>where <I>Volume-id</I> is the volume label, <I>start-file</I> and <I>start-block</I> are the file and block containing the first
2554
data from that session on the volume, <I>end-file</I> and <I>end-block</I> are
2555
the file and block with the last data from the session on the volume and <I>volume-session-id</I> is the volume session ID for blocks from the session
2556
stored on that volume.
2562
<H3><A NAME="SECTION00093200000000000000"></A>
2572
<DT><STRONG>Read open session = <JobId> <Volume-id>
2573
<start-file> <start-block> <end-file>
2574
<end-block> <volume-session-id> <password> </STRONG></DT>
2575
<DD><A NAME="1380"></A>
2576
where <I>Volume-id</I> is the volume label, <I>start-file</I> and <I>start-block</I> are the file and block containing the first data from that
2577
session on the volume, <I>end-file</I> and <I>end-block</I> are the file and
2578
block with the last data from the session on the volume and <I>volume-session-id</I> is the volume session ID for blocks from the session
2579
stored on that volume.
2582
If the session is successfully opened, a status of
2585
<TT><TT>3100 OK Ticket = </TT><I>number</I>``</TT>
2588
is returned with a reply used to identify subsequent messages in the session.
2589
If too many sessions are open, or a conflicting session (for example, an
2590
append in progress when simultaneous read and append sessions are not
2591
permitted), a status of ''<TT>3502 Volume busy</TT>`` is returned. If no
2592
volume is mounted, or the volume mounted cannot be appended to, a status of
2593
''<TT>3503 Volume not mounted</TT>`` is returned. If no block with the given
2594
volume session ID and the correct client ID number appears in the given first
2595
file and block for the volume, a status of ''<TT>3505 Session not found</TT>`` is returned.
2599
<DT><STRONG>Read data = <Ticket> > <Block> </STRONG></DT>
2600
<DD><A NAME="1397"></A>
2601
The specified Block of data from open read session with the specified Ticket
2602
number is returned, with a status of <TT>3000 OK</TT> followed by a ''<TT>Length = </TT><I>size</I>`` line giving the length in bytes of the block data
2603
which immediately follows. Blocks must be retrieved in ascending order, but
2604
blocks may be skipped. If a block number greater than the largest stored on
2605
the volume is requested, a status of ''<TT>3201 End of volume</TT>`` is
2606
returned. If a block number greater than the largest in the file is
2607
requested, a status of ''<TT>3401 End of file</TT>`` is returned.
2611
<DT><STRONG>Read close session = <Ticket> </STRONG></DT>
2612
<DD><A NAME="1405"></A>
2613
The read session with Ticket number is closed. A read session may be closed
2614
at any time; you needn't read all its blocks before closing it.
2621
HREF="http://www.fourmilab.ch/">John Walker</A>
2622
January 30th, MM </I>
2626
<H2><A NAME="SECTION00094000000000000000"></A>
2634
In the Storage daemon, there is a Device resource (i.e. from conf file)
2635
that describes each physical device. When the physical device is used it
2636
is controled by the DEVICE structure (defined in dev.h), and typically
2637
refered to as dev in the C++ code. Anyone writing or reading a physical
2638
device must ultimately get a lock on the DEVICE structure -- this controls
2639
the device. However, multiple Jobs (defined by a JCR structure src/jcr.h)
2640
can be writing a physical DEVICE at the same time (of course they are
2641
sequenced by locking the DEVICE structure). There are a lot of job
2642
dependent "device" variables that may be different for each Job such as
2643
spooling (one job may spool and another may not, and when a job is
2644
spooling, it must have an i/o packet open, each job has its own record and
2645
block structures, ...), so there is a device control record or DCR that is
2646
the primary way of interfacing to the physical device. The DCR contains
2647
all the job specific data as well as a pointer to the Device resource
2648
(DEVRES structure) and the physical DEVICE structure.
2651
Now if a job is writing to two devices (it could be writing two separate
2652
streams to the same device), it must have two DCRs. Today, the code only
2653
permits one. This won't be hard to change, but it is new code.
2656
Today three jobs (threads), two physical devices each job
2657
writes to only one device:
2661
Job1 -> DCR1 -> DEVICE1
2662
Job2 -> DCR2 -> DEVICE1
2663
Job3 -> DCR3 -> DEVICE2
2667
To be implemented three jobs, three physical devices, but
2668
job1 is writing simultaneously to three devices:
2672
Job1 -> DCR1 -> DEVICE1
2673
-> DCR4 -> DEVICE2
2674
-> DCR5 -> DEVICE3
2675
Job2 -> DCR2 -> DEVICE1
2676
Job3 -> DCR3 -> DEVICE2
2678
Job = job control record
2679
DCR = Job contorl data for a specific device
2680
DEVICE = Device only control data
2687
<H1><A NAME="SECTION000100000000000000000"></A>
2688
<A NAME="_ChapterStart30"></A>
2698
<H2><A NAME="SECTION000101000000000000000">
2705
This chapter is intended to be a technical discussion of the Catalog services
2706
and as such is not targeted at end users but rather at developers and system
2707
administrators that want or need to know more of the working details of <B>Bacula</B>.
2710
The <B>Bacula Catalog</B> services consist of the programs that provide the SQL
2711
database engine for storage and retrieval of all information concerning files
2712
that were backed up and their locations on the storage media.
2715
We have investigated the possibility of using the following SQL engines for
2716
Bacula: Beagle, mSQL, GNU SQL, PostgreSQL, SQLite, Oracle, and MySQL. Each
2717
presents certain problems with either licensing or maturity. At present, we
2718
have chosen for development purposes to use MySQL, PostgreSQL and SQLite.
2719
MySQL was chosen because it is fast, proven to be reliable, widely used, and
2720
actively being developed. MySQL is released under the GNU GPL license.
2721
PostgreSQL was chosen because it is a full-featured, very mature database, and
2722
because Dan Langille did the Bacula driver for it. PostgreSQL is distributed
2723
under the BSD license. SQLite was chosen because it is small, efficient, and
2724
can be directly embedded in <B>Bacula</B> thus requiring much less effort from
2725
the system administrator or person building <B>Bacula</B>. In our testing
2726
SQLite has performed very well, and for the functions that we use, it has
2727
never encountered any errors except that it does not appear to handle
2728
databases larger than 2GBytes. That said, we would not recommend it for
2729
serious production use.
2732
The Bacula SQL code has been written in a manner that will allow it to be
2733
easily modified to support any of the current SQL database systems on the
2734
market (for example: mSQL, iODBC, unixODBC, Solid, OpenLink ODBC, EasySoft
2735
ODBC, InterBase, Oracle8, Oracle7, and DB2).
2738
If you do not specify either <B><code>--</code>with-mysql</B> or <B><code>--</code>with-postgresql</B> or
2739
<B><code>--</code>with-sqlite</B> on the ./configure line, Bacula will use its minimalist
2740
internal database. This database is kept for build reasons but is no longer
2741
supported. Bacula <B>requires</B> one of the three databases (MySQL,
2742
PostgreSQL, or SQLite) to run.
2746
<H3><A NAME="SECTION000101100000000000000">
2747
Filenames and Maximum Filename Length</A>
2754
In general, either MySQL, PostgreSQL or SQLite permit storing arbitrary long
2755
path names and file names in the catalog database. In practice, there still
2756
may be one or two places in the Catalog interface code that restrict the
2757
maximum path length to 512 characters and the maximum file name length to 512
2758
characters. These restrictions are believed to have been removed. Please note,
2759
these restrictions apply only to the Catalog database and thus to your ability
2760
to list online the files saved during any job. All information received and
2761
stored by the Storage daemon (normally on tape) allows and handles arbitrarily
2762
long path and filenames.
2766
<H3><A NAME="SECTION000101200000000000000">
2767
Installing and Configuring MySQL</A>
2774
For the details of installing and configuring MySQL, please see the
2775
<A HREF="#_ChapterStart">Installing and Configuring MySQL</A> chapter of
2780
<H3><A NAME="SECTION000101300000000000000">
2781
Installing and Configuring PostgreSQL</A>
2788
For the details of installing and configuring PostgreSQL, please see the
2789
<A HREF="#_ChapterStart10">Installing and Configuring PostgreSQL</A>
2790
chapter of this manual.
2794
<H3><A NAME="SECTION000101400000000000000">
2795
Installing and Configuring SQLite</A>
2802
For the details of installing and configuring SQLite, please see the
2803
<A HREF="#_ChapterStart33">Installing and Configuring SQLite</A> chapter of
2808
<H3><A NAME="SECTION000101500000000000000">
2809
Internal Bacula Catalog</A>
2817
<A HREF="#_ChapterStart42">Internal Bacula Database</A> chapter of this
2818
manual for more details.
2822
<H3><A NAME="SECTION000101600000000000000">
2823
Database Table Design</A>
2830
All discussions that follow pertain to the MySQL database. The details for the
2831
PostgreSQL and SQLite databases are essentially identical except for that all
2832
fields in the SQLite database are stored as ASCII text and some of the
2833
database creation statements are a bit different. The details of the internal
2834
Bacula catalog are not discussed here.
2837
Because the Catalog database may contain very large amounts of data for large
2838
sites, we have made a modest attempt to normalize the data tables to reduce
2839
redundant information. While reducing the size of the database significantly,
2840
it does, unfortunately, add some complications to the structures.
2843
In simple terms, the Catalog database must contain a record of all Jobs run by
2844
Bacula, and for each Job, it must maintain a list of all files saved, with
2845
their File Attributes (permissions, create date, ...), and the location and
2846
Media on which the file is stored. This is seemingly a simple task, but it
2847
represents a huge amount interlinked data. Note: the list of files and their
2848
attributes is not maintained when using the internal Bacula database. The data
2849
stored in the File records, which allows the user or administrator to obtain a
2850
list of all files backed up during a job, is by far the largest volume of
2851
information put into the Catalog database.
2854
Although the Catalog database has been designed to handle backup data for
2855
multiple clients, some users may want to maintain multiple databases, one for
2856
each machine to be backed up. This reduces the risk of confusion of accidental
2857
restoring a file to the wrong machine as well as reducing the amount of data
2858
in a single database, thus increasing efficiency and reducing the impact of a
2859
lost or damaged database.
2863
<H2><A NAME="SECTION000102000000000000000">
2864
Sequence of Creation of Records for a Save Job</A>
2871
Start with StartDate, ClientName, Filename, Path, Attributes, MediaName,
2872
MediaCoordinates. (PartNumber, NumParts). In the steps below, ``Create new''
2873
means to create a new record whether or not it is unique. ``Create unique''
2874
means each record in the database should be unique. Thus, one must first
2875
search to see if the record exists, and only if not should a new one be
2876
created, otherwise the existing RecordId should be used.
2881
<LI>Create new Job record with StartDate; save JobId
2883
<LI>Create unique Media record; save MediaId
2885
<LI>Create unique Client record; save ClientId
2887
<LI>Create unique Filename record; save FilenameId
2889
<LI>Create unique Path record; save PathId
2891
<LI>Create unique Attribute record; save AttributeId
2892
store ClientId, FilenameId, PathId, and Attributes
2894
<LI>Create new File record
2895
store JobId, AttributeId, MediaCoordinates, etc
2897
<LI>Repeat steps 4 through 8 for each file
2899
<LI>Create a JobMedia record; save MediaId
2901
<LI>Update Job record filling in EndDate and other Job statistics
2908
<H2><A NAME="SECTION000103000000000000000">
2917
<TABLE CELLPADDING=3 BORDER="1">
2918
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Filename </B></TD>
2920
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
2921
<TD ALIGN="LEFT" COLSPAN=1><B>Data Type </B></TD>
2922
<TD ALIGN="LEFT" COLSPAN=1><B>Remark </B></TD>
2924
<TR><TD ALIGN="LEFT">FilenameId</TD>
2925
<TD ALIGN="LEFT">integer</TD>
2926
<TD ALIGN="LEFT">Primary Key</TD>
2928
<TR><TD ALIGN="LEFT">Name</TD>
2929
<TD ALIGN="LEFT">Blob</TD>
2930
<TD ALIGN="LEFT">Filename</TD>
2935
The <B>Filename</B> table shown above contains the name of each file backed up
2936
with the path removed. If different directories or machines contain the same
2937
filename, only one copy will be saved in this table.
2943
<TABLE CELLPADDING=3 BORDER="1">
2944
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Path </B></TD>
2946
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
2947
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
2949
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
2951
<TR><TD ALIGN="LEFT">PathId</TD>
2952
<TD ALIGN="LEFT">integer</TD>
2953
<TD ALIGN="LEFT">Primary Key</TD>
2955
<TR><TD ALIGN="LEFT">Path</TD>
2956
<TD ALIGN="LEFT">Blob</TD>
2957
<TD ALIGN="LEFT">Full Path</TD>
2962
The <B>Path</B> table contains shown above the path or directory names of all
2963
directories on the system or systems. The filename and any MSDOS disk name are
2964
stripped off. As with the filename, only one copy of each directory name is
2965
kept regardless of how many machines or drives have the same directory. These
2966
path names should be stored in Unix path name format.
2969
Some simple testing on a Linux file system indicates that separating the
2970
filename and the path may be more complication than is warranted by the space
2971
savings. For example, this system has a total of 89,097 files, 60,467 of which
2972
have unique filenames, and there are 4,374 unique paths.
2975
Finding all those files and doing two stats() per file takes an average wall
2976
clock time of 1 min 35 seconds on a 400MHz machine running RedHat 6.1 Linux.
2979
Finding all those files and putting them directly into a MySQL database with
2980
the path and filename defined as TEXT, which is variable length up to 65,535
2981
characters takes 19 mins 31 seconds and creates a 27.6 MByte database.
2984
Doing the same thing, but inserting them into Blob fields with the filename
2985
indexed on the first 30 characters and the path name indexed on the 255 (max)
2986
characters takes 5 mins 18 seconds and creates a 5.24 MB database. Rerunning
2987
the job (with the database already created) takes about 2 mins 50 seconds.
2990
Running the same as the last one (Path and Filename Blob), but Filename
2991
indexed on the first 30 characters and the Path on the first 50 characters
2992
(linear search done there after) takes 5 mins on the average and creates a 3.4
2993
MB database. Rerunning with the data already in the DB takes 3 mins 35
2997
Finally, saving only the full path name rather than splitting the path and the
2998
file, and indexing it on the first 50 characters takes 6 mins 43 seconds and
2999
creates a 7.35 MB database.
3005
<TABLE CELLPADDING=3 BORDER="1">
3006
<TR><TD ALIGN="LEFT" COLSPAN=3><B>File </B></TD>
3008
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3009
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3011
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3013
<TR><TD ALIGN="LEFT">FileId</TD>
3014
<TD ALIGN="LEFT">integer</TD>
3015
<TD ALIGN="LEFT">Primary Key</TD>
3017
<TR><TD ALIGN="LEFT">FileIndex</TD>
3018
<TD ALIGN="LEFT">integer</TD>
3019
<TD ALIGN="LEFT">The sequential file number in the Job</TD>
3021
<TR><TD ALIGN="LEFT">JobId</TD>
3022
<TD ALIGN="LEFT">integer</TD>
3023
<TD ALIGN="LEFT">Link to Job Record</TD>
3025
<TR><TD ALIGN="LEFT">PathId</TD>
3026
<TD ALIGN="LEFT">integer</TD>
3027
<TD ALIGN="LEFT">Link to Path Record</TD>
3029
<TR><TD ALIGN="LEFT">FilenameId</TD>
3030
<TD ALIGN="LEFT">integer</TD>
3031
<TD ALIGN="LEFT">Link to Filename Record</TD>
3033
<TR><TD ALIGN="LEFT">MarkId</TD>
3034
<TD ALIGN="LEFT">integer</TD>
3035
<TD ALIGN="LEFT">Used to mark files during Verify Jobs</TD>
3037
<TR><TD ALIGN="LEFT">LStat</TD>
3038
<TD ALIGN="LEFT">tinyblob</TD>
3039
<TD ALIGN="LEFT">File attributes in base64 encoding</TD>
3041
<TR><TD ALIGN="LEFT">MD5</TD>
3042
<TD ALIGN="LEFT">tinyblob</TD>
3043
<TD ALIGN="LEFT">MD5 signature in base64 encoding</TD>
3048
The <B>File</B> table shown above contains one entry for each file backed up by
3049
Bacula. Thus a file that is backed up multiple times (as is normal) will have
3050
multiple entries in the File table. This will probably be the table with the
3051
most number of records. Consequently, it is essential to keep the size of this
3052
record to an absolute minimum. At the same time, this table must contain all
3053
the information (or pointers to the information) about the file and where it
3054
is backed up. Since a file may be backed up many times without having changed,
3055
the path and filename are stored in separate tables.
3058
This table contains by far the largest amount of information in the Catalog
3059
database, both from the stand point of number of records, and the stand point
3060
of total database size. As a consequence, the user must take care to
3061
periodically reduce the number of File records using the <B>retention</B>
3062
command in the Console program.
3068
<TABLE CELLPADDING=3 BORDER="1">
3069
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Job </B></TD>
3071
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3072
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3074
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3076
<TR><TD ALIGN="LEFT">JobId</TD>
3077
<TD ALIGN="LEFT">integer</TD>
3078
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Primary Key</TD>
3080
<TR><TD ALIGN="LEFT">Job</TD>
3081
<TD ALIGN="LEFT">tinyblob</TD>
3082
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Unique Job Name</TD>
3084
<TR><TD ALIGN="LEFT">Name</TD>
3085
<TD ALIGN="LEFT">tinyblob</TD>
3086
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Job Name</TD>
3088
<TR><TD ALIGN="LEFT">PurgedFiles</TD>
3089
<TD ALIGN="LEFT">tinyint</TD>
3090
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Used by Bacula for purging/retention periods</TD>
3092
<TR><TD ALIGN="LEFT">Type</TD>
3093
<TD ALIGN="LEFT">binary(1)</TD>
3094
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Job Type: Backup, Copy, Clone, Archive, Migration</TD>
3096
<TR><TD ALIGN="LEFT">Level</TD>
3097
<TD ALIGN="LEFT">binary(1)</TD>
3098
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Job Level</TD>
3100
<TR><TD ALIGN="LEFT">ClientId</TD>
3101
<TD ALIGN="LEFT">integer</TD>
3102
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Client index</TD>
3104
<TR><TD ALIGN="LEFT">JobStatus</TD>
3105
<TD ALIGN="LEFT">binary(1)</TD>
3106
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Job Termination Status</TD>
3108
<TR><TD ALIGN="LEFT">SchedTime</TD>
3109
<TD ALIGN="LEFT">datetime</TD>
3110
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Time/date when Job scheduled</TD>
3112
<TR><TD ALIGN="LEFT">StartTime</TD>
3113
<TD ALIGN="LEFT">datetime</TD>
3114
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Time/date when Job started</TD>
3116
<TR><TD ALIGN="LEFT">EndTime</TD>
3117
<TD ALIGN="LEFT">datetime</TD>
3118
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Time/date when Job ended</TD>
3120
<TR><TD ALIGN="LEFT">JobTDate</TD>
3121
<TD ALIGN="LEFT">bigint</TD>
3122
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Start day in Unix format but 64 bits; used for
3123
Retention period.</TD>
3125
<TR><TD ALIGN="LEFT">VolSessionId</TD>
3126
<TD ALIGN="LEFT">integer</TD>
3127
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Unique Volume Session ID</TD>
3129
<TR><TD ALIGN="LEFT">VolSessionTime</TD>
3130
<TD ALIGN="LEFT">integer</TD>
3131
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Unique Volume Session Time</TD>
3133
<TR><TD ALIGN="LEFT">JobFiles</TD>
3134
<TD ALIGN="LEFT">integer</TD>
3135
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Number of files saved in Job</TD>
3137
<TR><TD ALIGN="LEFT">JobBytes</TD>
3138
<TD ALIGN="LEFT">bigint</TD>
3139
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Number of bytes saved in Job</TD>
3141
<TR><TD ALIGN="LEFT">JobErrors</TD>
3142
<TD ALIGN="LEFT">integer</TD>
3143
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Number of errors during Job</TD>
3145
<TR><TD ALIGN="LEFT">JobMissingFiles</TD>
3146
<TD ALIGN="LEFT">integer</TD>
3147
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Number of files not saved (not yet used)</TD>
3149
<TR><TD ALIGN="LEFT">PoolId</TD>
3150
<TD ALIGN="LEFT">integer</TD>
3151
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Link to Pool Record</TD>
3153
<TR><TD ALIGN="LEFT">FileSetId</TD>
3154
<TD ALIGN="LEFT">integer</TD>
3155
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Link to FileSet Record</TD>
3157
<TR><TD ALIGN="LEFT">PurgedFiles</TD>
3158
<TD ALIGN="LEFT">tiny integer</TD>
3159
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Set when all File records purged</TD>
3161
<TR><TD ALIGN="LEFT">HasBase</TD>
3162
<TD ALIGN="LEFT">tiny integer</TD>
3163
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Set when Base Job run</TD>
3168
The <B>Job</B> table contains one record for each Job run by Bacula. Thus
3169
normally, there will be one per day per machine added to the database. Note,
3170
the JobId is used to index Job records in the database, and it often is shown
3171
to the user in the Console program. However, care must be taken with its use
3172
as it is not unique from database to database. For example, the user may have
3173
a database for Client data saved on machine Rufus and another database for
3174
Client data saved on machine Roxie. In this case, the two database will each
3175
have JobIds that match those in another database. For a unique reference to a
3179
The Name field of the Job record corresponds to the Name resource record given
3180
in the Director's configuration file. Thus it is a generic name, and it will
3181
be normal to find many Jobs (or even all Jobs) with the same Name.
3184
The Job field contains a combination of the Name and the schedule time of the
3185
Job by the Director. Thus for a given Director, even with multiple Catalog
3186
databases, the Job will contain a unique name that represents the Job.
3189
For a given Storage daemon, the VolSessionId and VolSessionTime form a unique
3190
identification of the Job. This will be the case even if multiple Directors
3191
are using the same Storage daemon.
3194
The Job Type (or simply Type) can have one of the following values:
3198
<TABLE CELLPADDING=3 BORDER="1">
3199
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Value </B></TD>
3200
<TD ALIGN="CENTER" COLSPAN=1><B>Meaning </B></TD>
3202
<TR><TD ALIGN="LEFT">B</TD>
3203
<TD ALIGN="LEFT">Backup Job</TD>
3205
<TR><TD ALIGN="LEFT">V</TD>
3206
<TD ALIGN="LEFT">Verify Job</TD>
3208
<TR><TD ALIGN="LEFT">R</TD>
3209
<TD ALIGN="LEFT">Restore Job</TD>
3211
<TR><TD ALIGN="LEFT">C</TD>
3212
<TD ALIGN="LEFT">Console program (not in database)</TD>
3214
<TR><TD ALIGN="LEFT">D</TD>
3215
<TD ALIGN="LEFT">Admin Job</TD>
3217
<TR><TD ALIGN="LEFT">A</TD>
3218
<TD ALIGN="LEFT">Archive Job (not implemented)</TD>
3223
The JobStatus field specifies how the job terminated, and can be one of the
3228
<TABLE CELLPADDING=3 BORDER="1">
3229
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Value </B></TD>
3230
<TD ALIGN="CENTER" COLSPAN=1><B>Meaning </B></TD>
3232
<TR><TD ALIGN="LEFT">C</TD>
3233
<TD ALIGN="LEFT">Created but not yet running</TD>
3235
<TR><TD ALIGN="LEFT">R</TD>
3236
<TD ALIGN="LEFT">Running</TD>
3238
<TR><TD ALIGN="LEFT">B</TD>
3239
<TD ALIGN="LEFT">Blocked</TD>
3241
<TR><TD ALIGN="LEFT">T</TD>
3242
<TD ALIGN="LEFT">Terminated normally</TD>
3244
<TR><TD ALIGN="LEFT">E</TD>
3245
<TD ALIGN="LEFT">Terminated in Error</TD>
3247
<TR><TD ALIGN="LEFT">e</TD>
3248
<TD ALIGN="LEFT">Non-fatal error</TD>
3250
<TR><TD ALIGN="LEFT">f</TD>
3251
<TD ALIGN="LEFT">Fatal error</TD>
3253
<TR><TD ALIGN="LEFT">D</TD>
3254
<TD ALIGN="LEFT">Verify Differences</TD>
3256
<TR><TD ALIGN="LEFT">A</TD>
3257
<TD ALIGN="LEFT">Canceled by the user</TD>
3259
<TR><TD ALIGN="LEFT">F</TD>
3260
<TD ALIGN="LEFT">Waiting on the File daemon</TD>
3262
<TR><TD ALIGN="LEFT">S</TD>
3263
<TD ALIGN="LEFT">Waiting on the Storage daemon</TD>
3265
<TR><TD ALIGN="LEFT">m</TD>
3266
<TD ALIGN="LEFT">Waiting for a new Volume to be mounted</TD>
3268
<TR><TD ALIGN="LEFT">M</TD>
3269
<TD ALIGN="LEFT">Waiting for a Mount</TD>
3271
<TR><TD ALIGN="LEFT">s</TD>
3272
<TD ALIGN="LEFT">Waiting for Storage resource</TD>
3274
<TR><TD ALIGN="LEFT">j</TD>
3275
<TD ALIGN="LEFT">Waiting for Job resource</TD>
3277
<TR><TD ALIGN="LEFT">c</TD>
3278
<TD ALIGN="LEFT">Waiting for Client resource</TD>
3280
<TR><TD ALIGN="LEFT">d</TD>
3281
<TD ALIGN="LEFT">Wating for Maximum jobs</TD>
3283
<TR><TD ALIGN="LEFT">t</TD>
3284
<TD ALIGN="LEFT">Waiting for Start Time</TD>
3286
<TR><TD ALIGN="LEFT">p</TD>
3287
<TD ALIGN="LEFT">Waiting for higher priority job to finish</TD>
3295
<TABLE CELLPADDING=3 BORDER="1">
3296
<TR><TD ALIGN="LEFT" COLSPAN=3><B>FileSet </B></TD>
3298
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3299
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type </B></TD>
3300
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3302
<TR><TD ALIGN="LEFT">FileSetId</TD>
3303
<TD ALIGN="LEFT">integer</TD>
3304
<TD ALIGN="LEFT">Primary Key</TD>
3306
<TR><TD ALIGN="LEFT">FileSet</TD>
3307
<TD ALIGN="LEFT">tinyblob</TD>
3308
<TD ALIGN="LEFT">FileSet name</TD>
3310
<TR><TD ALIGN="LEFT">MD5</TD>
3311
<TD ALIGN="LEFT">tinyblob</TD>
3312
<TD ALIGN="LEFT">MD5 checksum of FileSet</TD>
3314
<TR><TD ALIGN="LEFT">CreateTime</TD>
3315
<TD ALIGN="LEFT">datetime</TD>
3316
<TD ALIGN="LEFT">Time and date Fileset created</TD>
3321
The <B>FileSet</B> table contains one entry for each FileSet that is used. The
3322
MD5 signature is kept to ensure that if the user changes anything inside the
3323
FileSet, it will be detected and the new FileSet will be used. This is
3324
particularly important when doing an incremental update. If the user deletes a
3325
file or adds a file, we need to ensure that a Full backup is done prior to the
3332
<TABLE CELLPADDING=3 BORDER="1">
3333
<TR><TD ALIGN="LEFT" COLSPAN=3><B>JobMedia </B></TD>
3335
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3336
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type </B></TD>
3337
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3339
<TR><TD ALIGN="LEFT">JobMediaId</TD>
3340
<TD ALIGN="LEFT">integer</TD>
3341
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Primary Key</TD>
3343
<TR><TD ALIGN="LEFT">JobId</TD>
3344
<TD ALIGN="LEFT">integer</TD>
3345
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Link to Job Record</TD>
3347
<TR><TD ALIGN="LEFT">MediaId</TD>
3348
<TD ALIGN="LEFT">integer</TD>
3349
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>Link to Media Record</TD>
3351
<TR><TD ALIGN="LEFT">FirstIndex</TD>
3352
<TD ALIGN="LEFT">integer</TD>
3353
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The index (sequence number) of the first file
3354
written for this Job to the Media</TD>
3356
<TR><TD ALIGN="LEFT">LastIndex</TD>
3357
<TD ALIGN="LEFT">integer</TD>
3358
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The index of the last file written for this
3359
Job to the Media</TD>
3361
<TR><TD ALIGN="LEFT">StartFile</TD>
3362
<TD ALIGN="LEFT">integer</TD>
3363
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The physical media (tape) file number of the
3364
first block written for this Job</TD>
3366
<TR><TD ALIGN="LEFT">EndFile</TD>
3367
<TD ALIGN="LEFT">integer</TD>
3368
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The physical media (tape) file number of the
3369
last block written for this Job</TD>
3371
<TR><TD ALIGN="LEFT">StartBlock</TD>
3372
<TD ALIGN="LEFT">integer</TD>
3373
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The number of the first block written for
3376
<TR><TD ALIGN="LEFT">EndBlock</TD>
3377
<TD ALIGN="LEFT">integer</TD>
3378
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The number of the last block written for this
3381
<TR><TD ALIGN="LEFT">VolIndex</TD>
3382
<TD ALIGN="LEFT">integer</TD>
3383
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=180>The Volume use sequence number within the Job</TD>
3388
The <B>JobMedia</B> table contains one entry at the following: start of
3389
the job, start of each new tape file, start of each new tape, end of the
3390
job. Since by default, a new tape file is written every 2GB, in general,
3391
you will have more than 2 JobMedia records per Job. The number can be
3392
varied by changing the "Maximum File Size" specified in the Device
3393
resource. This record allows Bacula to efficiently position close to
3394
(within 2GB) any given file in a backup. For restoring a full Job,
3395
these records are not very important, but if you want to retrieve
3396
a single file that was written near the end of a 100GB backup, the
3397
JobMedia records can speed it up by orders of magnitude by permitting
3398
forward spacing files and blocks rather than reading the whole 100GB
3405
<TABLE CELLPADDING=3 BORDER="1">
3406
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Media </B></TD>
3408
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3409
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type </B></TD>
3410
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3412
<TR><TD ALIGN="LEFT">MediaId</TD>
3413
<TD ALIGN="LEFT">integer</TD>
3414
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Primary Key</TD>
3416
<TR><TD ALIGN="LEFT">VolumeName</TD>
3417
<TD ALIGN="LEFT">tinyblob</TD>
3418
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Volume name</TD>
3420
<TR><TD ALIGN="LEFT">Slot</TD>
3421
<TD ALIGN="LEFT">integer</TD>
3422
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Autochanger Slot number or zero</TD>
3424
<TR><TD ALIGN="LEFT">PoolId</TD>
3425
<TD ALIGN="LEFT">integer</TD>
3426
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Link to Pool Record</TD>
3428
<TR><TD ALIGN="LEFT">MediaType</TD>
3429
<TD ALIGN="LEFT">tinyblob</TD>
3430
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>The MediaType supplied by the user</TD>
3432
<TR><TD ALIGN="LEFT">FirstWritten</TD>
3433
<TD ALIGN="LEFT">datetime</TD>
3434
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Time/date when first written</TD>
3436
<TR><TD ALIGN="LEFT">LastWritten</TD>
3437
<TD ALIGN="LEFT">datetime</TD>
3438
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Time/date when last written</TD>
3440
<TR><TD ALIGN="LEFT">LabelDate</TD>
3441
<TD ALIGN="LEFT">datetime</TD>
3442
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Time/date when tape labeled</TD>
3444
<TR><TD ALIGN="LEFT">VolJobs</TD>
3445
<TD ALIGN="LEFT">integer</TD>
3446
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of jobs written to this media</TD>
3448
<TR><TD ALIGN="LEFT">VolFiles</TD>
3449
<TD ALIGN="LEFT">integer</TD>
3450
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of files written to this media</TD>
3452
<TR><TD ALIGN="LEFT">VolBlocks</TD>
3453
<TD ALIGN="LEFT">integer</TD>
3454
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of blocks written to this media</TD>
3456
<TR><TD ALIGN="LEFT">VolMounts</TD>
3457
<TD ALIGN="LEFT">integer</TD>
3458
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of time media mounted</TD>
3460
<TR><TD ALIGN="LEFT">VolBytes</TD>
3461
<TD ALIGN="LEFT">bigint</TD>
3462
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of bytes saved in Job</TD>
3464
<TR><TD ALIGN="LEFT">VolErrors</TD>
3465
<TD ALIGN="LEFT">integer</TD>
3466
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of errors during Job</TD>
3468
<TR><TD ALIGN="LEFT">VolWrites</TD>
3469
<TD ALIGN="LEFT">integer</TD>
3470
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of writes to media</TD>
3472
<TR><TD ALIGN="LEFT">MaxVolBytes</TD>
3473
<TD ALIGN="LEFT">bigint</TD>
3474
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Maximum bytes to put on this media</TD>
3476
<TR><TD ALIGN="LEFT">VolCapacityBytes</TD>
3477
<TD ALIGN="LEFT">bigint</TD>
3478
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Capacity estimate for this volume</TD>
3480
<TR><TD ALIGN="LEFT">VolStatus</TD>
3481
<TD ALIGN="LEFT">enum</TD>
3482
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Status of media: Full, Archive, Append, Recycle,
3483
Read-Only, Disabled, Error, Busy</TD>
3485
<TR><TD ALIGN="LEFT">Recycle</TD>
3486
<TD ALIGN="LEFT">tinyint</TD>
3487
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Whether or not Bacula can recycle the Volumes:
3490
<TR><TD ALIGN="LEFT">VolRetention</TD>
3491
<TD ALIGN="LEFT">bigint</TD>
3492
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>64 bit seconds until expiration</TD>
3494
<TR><TD ALIGN="LEFT">VolUseDuration</TD>
3495
<TD ALIGN="LEFT">bigint</TD>
3496
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>64 bit seconds volume can be used</TD>
3498
<TR><TD ALIGN="LEFT">MaxVolJobs</TD>
3499
<TD ALIGN="LEFT">integer</TD>
3500
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>maximum jobs to put on Volume</TD>
3502
<TR><TD ALIGN="LEFT">MaxVolFiles</TD>
3503
<TD ALIGN="LEFT">integer</TD>
3504
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>maximume EOF marks to put on Volume</TD>
3509
The <B>Volume</B> table (internally referred to as the Media table) contains
3510
one entry for each volume, that is each tape, cassette (8mm, DLT, DAT, ...),
3511
or file on which information is or was backed up. There is one Volume record
3512
created for each of the NumVols specified in the Pool resource record.
3518
<TABLE CELLPADDING=3 BORDER="1">
3519
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Pool </B></TD>
3521
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3522
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3524
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3526
<TR><TD ALIGN="LEFT">PoolId</TD>
3527
<TD ALIGN="LEFT">integer</TD>
3528
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Primary Key</TD>
3530
<TR><TD ALIGN="LEFT">Name</TD>
3531
<TD ALIGN="LEFT">Tinyblob</TD>
3532
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Pool Name</TD>
3534
<TR><TD ALIGN="LEFT">NumVols</TD>
3535
<TD ALIGN="LEFT">Integer</TD>
3536
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Number of Volumes in the Pool</TD>
3538
<TR><TD ALIGN="LEFT">MaxVols</TD>
3539
<TD ALIGN="LEFT">Integer</TD>
3540
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Maximum Volumes in the Pool</TD>
3542
<TR><TD ALIGN="LEFT">UseOnce</TD>
3543
<TD ALIGN="LEFT">tinyint</TD>
3544
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Use volume once</TD>
3546
<TR><TD ALIGN="LEFT">UseCatalog</TD>
3547
<TD ALIGN="LEFT">tinyint</TD>
3548
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Set to use catalog</TD>
3550
<TR><TD ALIGN="LEFT">AcceptAnyVolume</TD>
3551
<TD ALIGN="LEFT">tinyint</TD>
3552
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Accept any volume from Pool</TD>
3554
<TR><TD ALIGN="LEFT">VolRetention</TD>
3555
<TD ALIGN="LEFT">bigint</TD>
3556
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>64 bit seconds to retain volume</TD>
3558
<TR><TD ALIGN="LEFT">VolUseDuration</TD>
3559
<TD ALIGN="LEFT">bigint</TD>
3560
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>64 bit seconds volume can be used</TD>
3562
<TR><TD ALIGN="LEFT">MaxVolJobs</TD>
3563
<TD ALIGN="LEFT">integer</TD>
3564
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>max jobs on volume</TD>
3566
<TR><TD ALIGN="LEFT">MaxVolFiles</TD>
3567
<TD ALIGN="LEFT">integer</TD>
3568
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>max EOF marks to put on Volume</TD>
3570
<TR><TD ALIGN="LEFT">MaxVolBytes</TD>
3571
<TD ALIGN="LEFT">bigint</TD>
3572
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>max bytes to write on Volume</TD>
3574
<TR><TD ALIGN="LEFT">AutoPrune</TD>
3575
<TD ALIGN="LEFT">tinyint</TD>
3576
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>yes|no for autopruning</TD>
3578
<TR><TD ALIGN="LEFT">Recycle</TD>
3579
<TD ALIGN="LEFT">tinyint</TD>
3580
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>yes|no for allowing auto recycling of Volume</TD>
3582
<TR><TD ALIGN="LEFT">PoolType</TD>
3583
<TD ALIGN="LEFT">enum</TD>
3584
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Backup, Copy, Cloned, Archive, Migration</TD>
3586
<TR><TD ALIGN="LEFT">LabelFormat</TD>
3587
<TD ALIGN="LEFT">Tinyblob</TD>
3588
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=173>Label format</TD>
3593
The <B>Pool</B> table contains one entry for each media pool controlled by
3594
Bacula in this database. One media record exists for each of the NumVols
3595
contained in the Pool. The PoolType is a Bacula defined keyword. The MediaType
3596
is defined by the administrator, and corresponds to the MediaType specified in
3597
the Director's Storage definition record. The CurrentVol is the sequence
3598
number of the Media record for the current volume.
3604
<TABLE CELLPADDING=3 BORDER="1">
3605
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Client </B></TD>
3607
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3608
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3610
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3612
<TR><TD ALIGN="LEFT">ClientId</TD>
3613
<TD ALIGN="LEFT">integer</TD>
3614
<TD ALIGN="LEFT">Primary Key</TD>
3616
<TR><TD ALIGN="LEFT">Name</TD>
3617
<TD ALIGN="LEFT">TinyBlob</TD>
3618
<TD ALIGN="LEFT">File Services Name</TD>
3620
<TR><TD ALIGN="LEFT">UName</TD>
3621
<TD ALIGN="LEFT">TinyBlob</TD>
3622
<TD ALIGN="LEFT">uname -a from Client (not yet used)</TD>
3624
<TR><TD ALIGN="LEFT">AutoPrune</TD>
3625
<TD ALIGN="LEFT">tinyint</TD>
3626
<TD ALIGN="LEFT">yes|no for autopruning</TD>
3628
<TR><TD ALIGN="LEFT">FileRetention</TD>
3629
<TD ALIGN="LEFT">bigint</TD>
3630
<TD ALIGN="LEFT">64 bit seconds to retain Files</TD>
3632
<TR><TD ALIGN="LEFT">JobRetention</TD>
3633
<TD ALIGN="LEFT">bigint</TD>
3634
<TD ALIGN="LEFT">64 bit seconds to retain Job</TD>
3639
The <B>Client</B> table contains one entry for each machine backed up by Bacula
3640
in this database. Normally the Name is a fully qualified domain name.
3646
<TABLE CELLPADDING=3 BORDER="1">
3647
<TR><TD ALIGN="LEFT" COLSPAN=3><B>UnsavedFiles </B></TD>
3649
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3650
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3652
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3654
<TR><TD ALIGN="LEFT">UnsavedId</TD>
3655
<TD ALIGN="LEFT">integer</TD>
3656
<TD ALIGN="LEFT">Primary Key</TD>
3658
<TR><TD ALIGN="LEFT">JobId</TD>
3659
<TD ALIGN="LEFT">integer</TD>
3660
<TD ALIGN="LEFT">JobId corresponding to this record</TD>
3662
<TR><TD ALIGN="LEFT">PathId</TD>
3663
<TD ALIGN="LEFT">integer</TD>
3664
<TD ALIGN="LEFT">Id of path</TD>
3666
<TR><TD ALIGN="LEFT">FilenameId</TD>
3667
<TD ALIGN="LEFT">integer</TD>
3668
<TD ALIGN="LEFT">Id of filename</TD>
3673
The <B>UnsavedFiles</B> table contains one entry for each file that was not
3674
saved. Note! This record is not yet implemented.
3680
<TABLE CELLPADDING=3 BORDER="1">
3681
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Counter </B></TD>
3683
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3684
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3686
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3688
<TR><TD ALIGN="LEFT">Counter</TD>
3689
<TD ALIGN="LEFT">tinyblob</TD>
3690
<TD ALIGN="LEFT">Counter name</TD>
3692
<TR><TD ALIGN="LEFT">MinValue</TD>
3693
<TD ALIGN="LEFT">integer</TD>
3694
<TD ALIGN="LEFT">Start/Min value for counter</TD>
3696
<TR><TD ALIGN="LEFT">MaxValue</TD>
3697
<TD ALIGN="LEFT">integer</TD>
3698
<TD ALIGN="LEFT">Max value for counter</TD>
3700
<TR><TD ALIGN="LEFT">CurrentValue</TD>
3701
<TD ALIGN="LEFT">integer</TD>
3702
<TD ALIGN="LEFT">Current counter value</TD>
3704
<TR><TD ALIGN="LEFT">WrapCounter</TD>
3705
<TD ALIGN="LEFT">tinyblob</TD>
3706
<TD ALIGN="LEFT">Name of another counter</TD>
3711
The <B>Counter</B> table contains one entry for each permanent counter defined
3718
<TABLE CELLPADDING=3 BORDER="1">
3719
<TR><TD ALIGN="LEFT" COLSPAN=3><B>Version </B></TD>
3721
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3722
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3724
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3726
<TR><TD ALIGN="LEFT">VersionId</TD>
3727
<TD ALIGN="LEFT">integer</TD>
3728
<TD ALIGN="LEFT">Primary Key</TD>
3733
The <B>Version</B> table defines the Bacula database version number. Bacula
3734
checks this number before reading the database to ensure that it is compatible
3735
with the Bacula binary file.
3741
<TABLE CELLPADDING=3 BORDER="1">
3742
<TR><TD ALIGN="LEFT" COLSPAN=3><B>BaseFiles </B></TD>
3744
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Column Name </B></TD>
3745
<TD ALIGN="CENTER" COLSPAN=1><B>Data Type
3747
<TD ALIGN="CENTER" COLSPAN=1><B>Remark </B></TD>
3749
<TR><TD ALIGN="LEFT">BaseId</TD>
3750
<TD ALIGN="LEFT">integer</TD>
3751
<TD ALIGN="LEFT">Primary Key</TD>
3753
<TR><TD ALIGN="LEFT">BaseJobId</TD>
3754
<TD ALIGN="LEFT">integer</TD>
3755
<TD ALIGN="LEFT">JobId of Base Job</TD>
3757
<TR><TD ALIGN="LEFT">JobId</TD>
3758
<TD ALIGN="LEFT">integer</TD>
3759
<TD ALIGN="LEFT">Reference to Job</TD>
3761
<TR><TD ALIGN="LEFT">FileId</TD>
3762
<TD ALIGN="LEFT">integer</TD>
3763
<TD ALIGN="LEFT">Reference to File</TD>
3765
<TR><TD ALIGN="LEFT">FileIndex</TD>
3766
<TD ALIGN="LEFT">integer</TD>
3767
<TD ALIGN="LEFT">File Index number</TD>
3772
The <B>BaseFiles</B> table contains all the File references for a particular
3773
JobId that point to a Base file -- i.e. they were previously saved and hence
3774
were not saved in the current JobId but in BaseJobId under FileId. FileIndex
3775
is the index of the file, and is used for optimization of Restore jobs to
3776
prevent the need to read the FileId record when creating the in memory tree.
3777
This record is not yet implemented.
3783
<H3><A NAME="SECTION000103100000000000000">
3784
MySQL Table Definition</A>
3791
The commands used to create the MySQL tables are as follows:
3796
CREATE TABLE Filename (
3797
FilenameId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3799
PRIMARY KEY(FilenameId),
3803
PathId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3805
PRIMARY KEY(PathId),
3809
FileId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3810
FileIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
3811
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
3812
PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
3813
FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
3814
MarkId INTEGER UNSIGNED NOT NULL DEFAULT 0,
3815
LStat TINYBLOB NOT NULL,
3816
MD5 TINYBLOB NOT NULL,
3817
PRIMARY KEY(FileId),
3823
JobId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3824
Job TINYBLOB NOT NULL,
3825
Name TINYBLOB NOT NULL,
3826
Type BINARY(1) NOT NULL,
3827
Level BINARY(1) NOT NULL,
3828
ClientId INTEGER NOT NULL REFERENCES Client,
3829
JobStatus BINARY(1) NOT NULL,
3830
SchedTime DATETIME NOT NULL,
3831
StartTime DATETIME NOT NULL,
3832
EndTime DATETIME NOT NULL,
3833
JobTDate BIGINT UNSIGNED NOT NULL,
3834
VolSessionId INTEGER UNSIGNED NOT NULL DEFAULT 0,
3835
VolSessionTime INTEGER UNSIGNED NOT NULL DEFAULT 0,
3836
JobFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
3837
JobBytes BIGINT UNSIGNED NOT NULL,
3838
JobErrors INTEGER UNSIGNED NOT NULL DEFAULT 0,
3839
JobMissingFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
3840
PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool,
3841
FileSetId INTEGER UNSIGNED NOT NULL REFERENCES FileSet,
3842
PurgedFiles TINYINT NOT NULL DEFAULT 0,
3843
HasBase TINYINT NOT NULL DEFAULT 0,
3847
CREATE TABLE FileSet (
3848
FileSetId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3849
FileSet TINYBLOB NOT NULL,
3850
MD5 TINYBLOB NOT NULL,
3851
CreateTime DATETIME NOT NULL,
3852
PRIMARY KEY(FileSetId)
3854
CREATE TABLE JobMedia (
3855
JobMediaId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3856
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
3857
MediaId INTEGER UNSIGNED NOT NULL REFERENCES Media,
3858
FirstIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
3859
LastIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
3860
StartFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
3861
EndFile INTEGER UNSIGNED NOT NULL DEFAULT 0,
3862
StartBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
3863
EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
3864
VolIndex INTEGER UNSIGNED NOT NULL DEFAULT 0,
3865
PRIMARY KEY(JobMediaId),
3866
INDEX (JobId, MediaId)
3868
CREATE TABLE Media (
3869
MediaId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3870
VolumeName TINYBLOB NOT NULL,
3871
Slot INTEGER NOT NULL DEFAULT 0,
3872
PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool,
3873
MediaType TINYBLOB NOT NULL,
3874
FirstWritten DATETIME NOT NULL,
3875
LastWritten DATETIME NOT NULL,
3876
LabelDate DATETIME NOT NULL,
3877
VolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
3878
VolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
3879
VolBlocks INTEGER UNSIGNED NOT NULL DEFAULT 0,
3880
VolMounts INTEGER UNSIGNED NOT NULL DEFAULT 0,
3881
VolBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
3882
VolErrors INTEGER UNSIGNED NOT NULL DEFAULT 0,
3883
VolWrites INTEGER UNSIGNED NOT NULL DEFAULT 0,
3884
VolCapacityBytes BIGINT UNSIGNED NOT NULL,
3885
VolStatus ENUM('Full', 'Archive', 'Append', 'Recycle', 'Purged',
3886
'Read-Only', 'Disabled', 'Error', 'Busy', 'Used', 'Cleaning') NOT NULL,
3887
Recycle TINYINT NOT NULL DEFAULT 0,
3888
VolRetention BIGINT UNSIGNED NOT NULL DEFAULT 0,
3889
VolUseDuration BIGINT UNSIGNED NOT NULL DEFAULT 0,
3890
MaxVolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
3891
MaxVolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
3892
MaxVolBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
3893
InChanger TINYINT NOT NULL DEFAULT 0,
3894
MediaAddressing TINYINT NOT NULL DEFAULT 0,
3895
VolReadTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
3896
VolWriteTime BIGINT UNSIGNED NOT NULL DEFAULT 0,
3897
PRIMARY KEY(MediaId),
3901
PoolId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3902
Name TINYBLOB NOT NULL,
3903
NumVols INTEGER UNSIGNED NOT NULL DEFAULT 0,
3904
MaxVols INTEGER UNSIGNED NOT NULL DEFAULT 0,
3905
UseOnce TINYINT NOT NULL,
3906
UseCatalog TINYINT NOT NULL,
3907
AcceptAnyVolume TINYINT DEFAULT 0,
3908
VolRetention BIGINT UNSIGNED NOT NULL,
3909
VolUseDuration BIGINT UNSIGNED NOT NULL,
3910
MaxVolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
3911
MaxVolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
3912
MaxVolBytes BIGINT UNSIGNED NOT NULL,
3913
AutoPrune TINYINT DEFAULT 0,
3914
Recycle TINYINT DEFAULT 0,
3915
PoolType ENUM('Backup', 'Copy', 'Cloned', 'Archive', 'Migration', 'Scratch') NOT NULL,
3916
LabelFormat TINYBLOB,
3917
Enabled TINYINT DEFAULT 1,
3918
ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
3919
RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
3921
PRIMARY KEY (PoolId)
3923
CREATE TABLE Client (
3924
ClientId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
3925
Name TINYBLOB NOT NULL,
3926
Uname TINYBLOB NOT NULL, /* full uname -a of client */
3927
AutoPrune TINYINT DEFAULT 0,
3928
FileRetention BIGINT UNSIGNED NOT NULL,
3929
JobRetention BIGINT UNSIGNED NOT NULL,
3931
PRIMARY KEY(ClientId)
3933
CREATE TABLE BaseFiles (
3934
BaseId INTEGER UNSIGNED AUTO_INCREMENT,
3935
BaseJobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
3936
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
3937
FileId INTEGER UNSIGNED NOT NULL REFERENCES File,
3938
FileIndex INTEGER UNSIGNED,
3941
CREATE TABLE UnsavedFiles (
3942
UnsavedId INTEGER UNSIGNED AUTO_INCREMENT,
3943
JobId INTEGER UNSIGNED NOT NULL REFERENCES Job,
3944
PathId INTEGER UNSIGNED NOT NULL REFERENCES Path,
3945
FilenameId INTEGER UNSIGNED NOT NULL REFERENCES Filename,
3946
PRIMARY KEY (UnsavedId)
3948
CREATE TABLE Version (
3949
VersionId INTEGER UNSIGNED NOT NULL
3951
-- Initialize Version
3952
INSERT INTO Version (VersionId) VALUES (7);
3953
CREATE TABLE Counters (
3954
Counter TINYBLOB NOT NULL,
3957
CurrentValue INTEGER,
3958
WrapCounter TINYBLOB NOT NULL,
3959
PRIMARY KEY (Counter(128))
3964
<H1><A NAME="SECTION000110000000000000000"></A>
3965
<A NAME="_ChapterStart9"></A><A NAME="2688"></A>
3968
Storage Media Output Format
3974
<H2><A NAME="SECTION000111000000000000000"></A>
3982
This document describes the media format written by the Storage daemon. The
3983
Storage daemon reads and writes in units of blocks. Blocks contain records.
3984
Each block has a block header followed by records, and each record has a
3985
record header followed by record data.
3988
This chapter is intended to be a technical discussion of the Media Format and
3989
as such is not targeted at end users but rather at developers and system
3990
administrators that want or need to know more of the working details of <B>Bacula</B>.
3994
<H2><A NAME="SECTION000112000000000000000"></A>
4003
<DT><STRONG>Block</STRONG></DT>
4004
<DD><A NAME="2705"></A>
4005
A block represents the primitive unit of information that the Storage daemon
4006
reads and writes to a physical device. Normally, for a tape device, it will
4007
be the same as a tape block. The Storage daemon always reads and writes
4008
blocks. A block consists of block header information followed by records.
4009
Clients of the Storage daemon (the File daemon) normally never see blocks.
4010
However, some of the Storage tools (bls, bscan, bextract, ...) may be use
4011
block header information. In older Bacula tape versions, a block could
4012
contain records (see record definition below) from multiple jobs. However,
4013
all blocks currently written by Bacula are block level BB02, and a given
4014
block contains records for only a single job. Different jobs simply have
4015
their own private blocks that are intermingled with the other blocks from
4016
other jobs on the Volume (previously the records were intermingled within
4017
the blocks). Having only records from a single job in any give block
4018
permitted moving the VolumeSessionId and VolumeSessionTime (see below) from
4019
each record heading to the Block header. This has two advantages: 1. a block
4020
can be quickly rejected based on the contents of the header without reading
4021
all the records. 2. because there is on the average more than one record per
4022
block, less data is written to the Volume for each job.
4026
<DT><STRONG>Record</STRONG></DT>
4027
<DD><A NAME="2706"></A>
4028
A record consists of a Record Header, which is managed by the Storage daemon
4029
and Record Data, which is the data received from the Client. A record is the
4030
primitive unit of information sent to and from the Storage daemon by the
4031
Client (File daemon) programs. The details are described below.
4035
<DT><STRONG>JobId</STRONG></DT>
4036
<DD><A NAME="2707"></A>
4037
A number assigned by the Director daemon for a particular job. This number
4038
will be unique for that particular Director (Catalog). The daemons use this
4039
number to keep track of individual jobs. Within the Storage daemon, the JobId
4040
may not be unique if several Directors are accessing the Storage daemon
4045
<DT><STRONG>Session</STRONG></DT>
4046
<DD><A NAME="2708"></A>
4047
A Session is a concept used in the Storage daemon corresponds one to one to a
4048
Job with the exception that each session is uniquely identified within the
4049
Storage daemon by a unique SessionId/SessionTime pair (see below).
4053
<DT><STRONG>VolSessionId</STRONG></DT>
4054
<DD><A NAME="2709"></A>
4055
A unique number assigned by the Storage daemon to a particular session (Job)
4056
it is having with a File daemon. This number by itself is not unique to the
4057
given Volume, but with the VolSessionTime, it is unique.
4061
<DT><STRONG>VolSessionTime</STRONG></DT>
4062
<DD><A NAME="2710"></A>
4063
A unique number assigned by the Storage daemon to a particular Storage daemon
4064
execution. It is actually the Unix time_t value of when the Storage daemon
4065
began execution cast to a 32 bit unsigned integer. The combination of the
4066
<B>VolSessionId</B> and the <B>VolSessionTime</B> for a given Storage daemon is
4067
guaranteed to be unique for each Job (or session).
4071
<DT><STRONG>FileIndex</STRONG></DT>
4072
<DD><A NAME="2713"></A>
4073
A sequential number beginning at one assigned by the File daemon to the files
4074
within a job that are sent to the Storage daemon for backup. The Storage
4075
daemon ensures that this number is greater than zero and sequential. Note,
4076
the Storage daemon uses negative FileIndexes to flag Session Start and End
4077
Labels as well as End of Volume Labels. Thus, the combination of
4078
VolSessionId, VolSessionTime, and FileIndex uniquely identifies the records
4079
for a single file written to a Volume.
4083
<DT><STRONG>Stream</STRONG></DT>
4084
<DD><A NAME="2714"></A>
4085
While writing the information for any particular file to the Volume, there
4086
can be any number of distinct pieces of information about that file, e.g. the
4087
attributes, the file data, ... The Stream indicates what piece of data it
4088
is, and it is an arbitrary number assigned by the File daemon to the parts
4089
(Unix attributes, Win32 attributes, data, compressed data, ...) of a file
4090
that are sent to the Storage daemon. The Storage daemon has no knowledge of
4091
the details of a Stream; it simply represents a numbered stream of bytes. The
4092
data for a given stream may be passed to the Storage daemon in single record,
4093
or in multiple records.
4097
<DT><STRONG>Block Header</STRONG></DT>
4098
<DD><A NAME="2715"></A>
4099
A block header consists of a block identification (``BB02''), a block length
4100
in bytes (typically 64,512) a checksum, and sequential block number. Each
4101
block starts with a Block Header and is followed by Records. Current block
4102
headers also contain the VolSessionId and VolSessionTime for the records
4103
written to that block.
4107
<DT><STRONG>Record Header</STRONG></DT>
4108
<DD><A NAME="2716"></A>
4109
A record header contains the Volume Session Id, the Volume Session Time, the
4110
FileIndex, the Stream, and the size of the data record which follows. The
4111
Record Header is always immediately followed by a Data Record if the size
4112
given in the Header is greater than zero. Note, for Block headers of level
4113
BB02 (version 1.27 and later), the Record header as written to tape does not
4114
contain the Volume Session Id and the Volume Session Time as these two
4115
fields are stored in the BB02 Block header. The in-memory record header does
4116
have those fields for convenience.
4120
<DT><STRONG>Data Record</STRONG></DT>
4121
<DD><A NAME="2717"></A>
4122
A data record consists of a binary stream of bytes and is always preceded by
4123
a Record Header. The details of the meaning of the binary stream of bytes are
4124
unknown to the Storage daemon, but the Client programs (File daemon) defines
4125
and thus knows the details of each record type.
4129
<DT><STRONG>Volume Label</STRONG></DT>
4130
<DD><A NAME="2718"></A>
4131
A label placed by the Storage daemon at the beginning of each storage volume.
4132
It contains general information about the volume. It is written in Record
4133
format. The Storage daemon manages Volume Labels, and if the client wants, he
4138
<DT><STRONG>Begin Session Label</STRONG></DT>
4139
<DD><A NAME="2719"></A>
4140
The Begin Session Label is a special record placed by the Storage daemon on
4141
the storage medium as the first record of an append session job with a File
4142
daemon. This record is useful for finding the beginning of a particular
4143
session (Job), since no records with the same VolSessionId and VolSessionTime
4144
will precede this record. This record is not normally visible outside of the
4145
Storage daemon. The Begin Session Label is similar to the Volume Label except
4146
that it contains additional information pertaining to the Session.
4150
<DT><STRONG>End Session Label</STRONG></DT>
4151
<DD><A NAME="2720"></A>
4152
The End Session Label is a special record placed by the Storage daemon on the
4153
storage medium as the last record of an append session job with a File
4154
daemon. The End Session Record is distinguished by a FileIndex with a value
4155
of minus two (-2). This record is useful for detecting the end of a
4156
particular session since no records with the same VolSessionId and
4157
VolSessionTime will follow this record. This record is not normally visible
4158
outside of the Storage daemon. The End Session Label is similar to the Volume
4159
Label except that it contains additional information pertaining to the
4166
<H2><A NAME="SECTION000113000000000000000"></A>
4170
Storage Daemon File Output Format
4175
The file storage and tape storage formats are identical except that tape
4176
records are by default blocked into blocks of 64,512 bytes, except for the
4177
last block, which is the actual number of bytes written rounded up to a
4178
multiple of 1024 whereas the last record of file storage is not rounded up.
4179
The default block size of 64,512 bytes may be overridden by the user (some
4180
older tape drives only support block sizes of 32K). Each Session written to
4181
tape is terminated with an End of File mark (this will be removed later).
4182
Sessions written to file are simply appended to the end of the file.
4186
<H2><A NAME="SECTION000114000000000000000"></A>
4195
A Bacula output file consists of Blocks of data. Each block contains a block
4196
header followed by records. Each record consists of a record header followed
4197
by the record data. The first record on a tape will always be the Volume Label
4201
No Record Header will be split across Bacula blocks. However, Record Data may
4202
be split across any number of Bacula blocks. Obviously this will not be the
4203
case for the Volume Label which will always be smaller than the Bacula Block
4207
To simplify reading tapes, the Start of Session (SOS) and End of Session (EOS)
4208
records are never split across blocks. If this is about to happen, Bacula will
4209
write a short block before writing the session record (actually, the SOS
4210
record should always be the first record in a block, excepting perhaps the
4214
Due to hardware limitations, the last block written to the tape may not be
4215
fully written. If your drive permits backspace record, Bacula will backup over
4216
the last record written on the tape, re-read it and verify that it was
4220
When a new tape is mounted Bacula will write the full contents of the
4221
partially written block to the new tape ensuring that there is no loss of
4222
data. When reading a tape, Bacula will discard any block that is not totally
4223
written, thus ensuring that there is no duplication of data. In addition,
4224
since Bacula blocks are sequentially numbered within a Job, it is easy to
4225
ensure that no block is missing or duplicated.
4229
<H2><A NAME="SECTION000115000000000000000"></A>
4237
All Block Headers, Record Headers, and Label Records are written using
4238
Bacula's serialization routines. These routines guarantee that the data is
4239
written to the output volume in a machine independent format.
4243
<H2><A NAME="SECTION000116000000000000000"></A>
4252
The format of the Block Header (version 1.27 and later) is:
4256
uint32_t CheckSum; /* Block check sum */
4257
uint32_t BlockSize; /* Block byte size including the header */
4258
uint32_t BlockNumber; /* Block number */
4259
char ID[4] = "BB02"; /* Identification and block level */
4260
uint32_t VolSessionId; /* Session Id for Job */
4261
uint32_t VolSessionTime; /* Session Time for Job */
4264
The Block header is a fixed length and fixed format and is followed by Record
4265
Headers and Record Data. The CheckSum field is a 32 bit checksum of the block
4266
data and the block header but not including the CheckSum field. The Block
4267
Header is always immediately followed by a Record Header. If the tape is
4268
damaged, a Bacula utility will be able to recover as much information as
4269
possible from the tape by recovering blocks which are valid. The Block header
4270
is written using the Bacula serialization routines and thus is guaranteed to
4271
be in machine independent format. See below for version 2 of the block header.
4275
<H2><A NAME="SECTION000117000000000000000"></A>
4284
Each binary data record is preceded by a Record Header. The Record Header is
4285
fixed length and fixed format, whereas the binary data record is of variable
4286
length. The Record Header is written using the Bacula serialization routines
4287
and thus is guaranteed to be in machine independent format.
4290
The format of the Record Header (version 1.27 or later) is:
4294
int32_t FileIndex; /* File index supplied by File daemon */
4295
int32_t Stream; /* Stream number supplied by File daemon */
4296
uint32_t DataSize; /* size of following data record in bytes */
4299
This record is followed by the binary Stream data of DataSize bytes, followed
4300
by another Record Header record and the binary stream data. For the definitive
4301
definition of this record, see record.h in the src/stored directory.
4304
Additional notes on the above:
4308
<DT><STRONG>The <B>VolSessionId</B> </STRONG></DT>
4309
<DD><A NAME="2757"></A>
4310
is a unique sequential number that is assigned by the Storage Daemon to a
4311
particular Job. This number is sequential since the start of execution of the
4316
<DT><STRONG>The <B>VolSessionTime</B> </STRONG></DT>
4317
<DD><A NAME="2759"></A>
4318
is the time/date that the current execution of the Storage Daemon started. It
4319
assures that the combination of VolSessionId and VolSessionTime is unique for
4320
every jobs written to the tape, even if there was a machine crash between two
4325
<DT><STRONG>The <B>FileIndex</B> </STRONG></DT>
4326
<DD><A NAME="2761"></A>
4327
is a sequential file number within a job. The Storage daemon requires this
4328
index to be greater than zero and sequential. Note, however, that the File
4329
daemon may send multiple Streams for the same FileIndex. In addition, the
4330
Storage daemon uses negative FileIndices to hold the Begin Session Label, the
4331
End Session Label, and the End of Volume Label.
4335
<DT><STRONG>The <B>Stream</B> </STRONG></DT>
4336
<DD><A NAME="2763"></A>
4337
is defined by the File daemon and is used to identify separate parts of the
4338
data saved for each file (Unix attributes, Win32 attributes, file data,
4339
compressed file data, sparse file data, ...). The Storage Daemon has no idea
4340
of what a Stream is or what it contains except that the Stream is required to
4341
be a positive integer. Negative Stream numbers are used internally by the
4342
Storage daemon to indicate that the record is a continuation of the previous
4343
record (the previous record would not entirely fit in the block).
4346
For Start Session and End Session Labels (where the FileIndex is negative),
4347
the Storage daemon uses the Stream field to contain the JobId. The current
4348
stream definitions are:
4352
#define STREAM_UNIX_ATTRIBUTES 1 /* Generic Unix attributes */
4353
#define STREAM_FILE_DATA 2 /* Standard uncompressed data */
4354
#define STREAM_MD5_SIGNATURE 3 /* MD5 signature for the file */
4355
#define STREAM_GZIP_DATA 4 /* GZip compressed file data */
4356
/* Extended Unix attributes with Win32 Extended data. Deprecated. */
4357
#define STREAM_UNIX_ATTRIBUTES_EX 5 /* Extended Unix attr for Win32 EX */
4358
#define STREAM_SPARSE_DATA 6 /* Sparse data stream */
4359
#define STREAM_SPARSE_GZIP_DATA 7
4360
#define STREAM_PROGRAM_NAMES 8 /* program names for program data */
4361
#define STREAM_PROGRAM_DATA 9 /* Data needing program */
4362
#define STREAM_SHA1_SIGNATURE 10 /* SHA1 signature for the file */
4363
#define STREAM_WIN32_DATA 11 /* Win32 BackupRead data */
4364
#define STREAM_WIN32_GZIP_DATA 12 /* Gzipped Win32 BackupRead data */
4365
#define STREAM_MACOS_FORK_DATA 13 /* Mac resource fork */
4366
#define STREAM_HFSPLUS_ATTRIBUTES 14 /* Mac OS extra attributes */
4367
#define STREAM_UNIX_ATTRIBUTES_ACCESS_ACL 15 /* Standard ACL attributes on UNIX */
4368
#define STREAM_UNIX_ATTRIBUTES_DEFAULT_ACL 16 /* Default ACL attributes on UNIX */
4372
<DT><STRONG>The <B>DataSize</B> </STRONG></DT>
4373
<DD><A NAME="2767"></A>
4374
is the size in bytes of the binary data record that follows the Session
4375
Record header. The Storage Daemon has no idea of the actual contents of the
4376
binary data record. For standard Unix files, the data record typically
4377
contains the file attributes or the file data. For a sparse file the first
4378
64 bits of the file data contains the storage address for the data block.
4383
The Record Header is never split across two blocks. If there is not enough
4384
room in a block for the full Record Header, the block is padded to the end
4385
with zeros and the Record Header begins in the next block. The data record, on
4386
the other hand, may be split across multiple blocks and even multiple physical
4387
volumes. When a data record is split, the second (and possibly subsequent)
4388
piece of the data is preceded by a new Record Header. Thus each piece of data
4389
is always immediately preceded by a Record Header. When reading a record, if
4390
Bacula finds only part of the data in the first record, it will automatically
4391
read the next record and concatenate the data record to form a full data
4396
<H2><A NAME="SECTION000118000000000000000"></A>
4400
Version BB02 Block Header
4405
Each session or Job has its own private block. As a consequence, the SessionId
4406
and SessionTime are written once in each Block Header and not in the Record
4407
Header. So, the second and current version of the Block Header BB02 is:
4411
uint32_t CheckSum; /* Block check sum */
4412
uint32_t BlockSize; /* Block byte size including the header */
4413
uint32_t BlockNumber; /* Block number */
4414
char ID[4] = "BB02"; /* Identification and block level */
4415
uint32_t VolSessionId; /* Applies to all records */
4416
uint32_t VolSessionTime; /* contained in this block */
4419
As with the previous version, the BB02 Block header is a fixed length and
4420
fixed format and is followed by Record Headers and Record Data. The CheckSum
4421
field is a 32 bit CRC checksum of the block data and the block header but not
4422
including the CheckSum field. The Block Header is always immediately followed
4423
by a Record Header. If the tape is damaged, a Bacula utility will be able to
4424
recover as much information as possible from the tape by recovering blocks
4425
which are valid. The Block header is written using the Bacula serialization
4426
routines and thus is guaranteed to be in machine independent format.
4430
<H2><A NAME="SECTION000119000000000000000"></A>
4434
Version 2 Record Header
4439
Version 2 Record Header is written to the medium when using Version BB02 Block
4440
Headers. The memory representation of the record is identical to the old BB01
4441
Record Header, but on the storage medium, the first two fields, namely
4442
VolSessionId and VolSessionTime are not written. The Block Header is filled
4443
with these values when the First user record is written (i.e. non label
4444
record) so that when the block is written, it will have the current and unique
4445
VolSessionId and VolSessionTime. On reading each record from the Block, the
4446
VolSessionId and VolSessionTime is filled in the Record Header from the Block
4451
<H2><A NAME="SECTION0001110000000000000000"></A>
4460
Tape volume labels are created by the Storage daemon in response to a <B>label</B> command given to the Console program, or alternatively by the <B>btape</B> program. created. Each volume is labeled with the following information
4461
using the Bacula serialization routines, which guarantee machine byte order
4465
For Bacula versions 1.27 and later, the Volume Label Format is:
4469
char Id[32]; /* Bacula 1.0 Immortal\n */
4470
uint32_t VerNum; /* Label version number */
4471
/* VerNum 11 and greater Bacula 1.27 and later */
4472
btime_t label_btime; /* Time/date tape labeled */
4473
btime_t write_btime; /* Time/date tape first written */
4474
/* The following are 0 in VerNum 11 and greater */
4475
float64_t write_date; /* Date this label written */
4476
float64_t write_time; /* Time this label written */
4477
char VolName[128]; /* Volume name */
4478
char PrevVolName[128]; /* Previous Volume Name */
4479
char PoolName[128]; /* Pool name */
4480
char PoolType[128]; /* Pool type */
4481
char MediaType[128]; /* Type of this media */
4482
char HostName[128]; /* Host name of writing computer */
4483
char LabelProg[32]; /* Label program name */
4484
char ProgVersion[32]; /* Program version */
4485
char ProgDate[32]; /* Program build date/time */
4488
Note, the LabelType (Volume Label, Volume PreLabel, Session Start Label, ...)
4489
is stored in the record FileIndex field of the Record Header and does not
4490
appear in the data part of the record.
4494
<H2><A NAME="SECTION0001111000000000000000"></A>
4503
The Session Label is written at the beginning and end of each session as well
4504
as the last record on the physical medium. It has the following binary format:
4508
char Id[32]; /* Bacula Immortal ... */
4509
uint32_t VerNum; /* Label version number */
4510
uint32_t JobId; /* Job id */
4511
uint32_t VolumeIndex; /* sequence no of vol */
4512
/* Prior to VerNum 11 */
4513
float64_t write_date; /* Date this label written */
4514
/* VerNum 11 and greater */
4515
btime_t write_btime; /* time/date record written */
4516
/* The following is zero VerNum 11 and greater */
4517
float64_t write_time; /* Time this label written */
4518
char PoolName[128]; /* Pool name */
4519
char PoolType[128]; /* Pool type */
4520
char JobName[128]; /* base Job name */
4521
char ClientName[128];
4522
/* Added in VerNum 10 */
4523
char Job[128]; /* Unique Job name */
4524
char FileSetName[128]; /* FileSet name */
4529
In addition, the EOS label contains:
4533
/* The remainder are part of EOS label only */
4536
uint32_t start_block;
4538
uint32_t start_file;
4543
In addition, for VerNum greater than 10, the EOS label contains (in addition
4548
uint32_t JobStatus /* Job termination code */
4551
: Note, the LabelType (Volume Label, Volume PreLabel, Session Start Label,
4552
...) is stored in the record FileIndex field and does not appear in the data
4553
part of the record. Also, the Stream field of the Record Header contains the
4554
JobId. This permits quick filtering without actually reading all the session
4559
<H2><A NAME="SECTION0001112000000000000000"></A>
4563
Overall Storage Format
4569
Current Bacula Tape Format
4571
Version BB02 added 28 September 2002
4572
Version BB01 is the old deprecated format.
4573
A Bacula tape is composed of tape Blocks. Each block
4574
has a Block header followed by the block data. Block
4575
Data consists of Records. Records consist of Record
4576
Headers followed by Record Data.
4577
:=======================================================:
4579
| Block Header (24 bytes) |
4581
|-------------------------------------------------------|
4583
| Record Header (12 bytes) |
4585
|-------------------------------------------------------|
4589
|-------------------------------------------------------|
4591
| Record Header (12 bytes) |
4593
|-------------------------------------------------------|
4596
Block Header: the first item in each block. The format is
4598
Partial Data block: occurs if the data from a previous
4599
block spills over to this block (the normal case except
4600
for the first block on a tape). However, this partial
4601
data block is always preceded by a record header.
4602
Record Header: identifies the Volume Session, the Stream
4603
and the following Record Data size. See below for format.
4604
Record data: arbitrary binary data.
4605
Block Header Format BB02
4606
:=======================================================:
4607
| CheckSum (uint32_t) |
4608
|-------------------------------------------------------|
4609
| BlockSize (uint32_t) |
4610
|-------------------------------------------------------|
4611
| BlockNumber (uint32_t) |
4612
|-------------------------------------------------------|
4613
| "BB02" (char [4]) |
4614
|-------------------------------------------------------|
4615
| VolSessionId (uint32_t) |
4616
|-------------------------------------------------------|
4617
| VolSessionTime (uint32_t) |
4618
:=======================================================:
4619
BBO2: Serves to identify the block as a
4620
Bacula block and also servers as a block format identifier
4621
should we ever need to change the format.
4622
BlockSize: is the size in bytes of the block. When reading
4623
back a block, if the BlockSize does not agree with the
4624
actual size read, Bacula discards the block.
4625
CheckSum: a checksum for the Block.
4626
BlockNumber: is the sequential block number on the tape.
4627
VolSessionId: a unique sequential number that is assigned
4628
by the Storage Daemon to a particular Job.
4629
This number is sequential since the start
4630
of execution of the daemon.
4631
VolSessionTime: the time/date that the current execution
4632
of the Storage Daemon started. It assures
4633
that the combination of VolSessionId and
4634
VolSessionTime is unique for all jobs
4635
written to the tape, even if there was a
4636
machine crash between two writes.
4637
Record Header Format BB02
4638
:=======================================================:
4639
| FileIndex (int32_t) |
4640
|-------------------------------------------------------|
4641
| Stream (int32_t) |
4642
|-------------------------------------------------------|
4643
| DataSize (uint32_t) |
4644
:=======================================================:
4645
FileIndex: a sequential file number within a job. The
4646
Storage daemon enforces this index to be
4647
greater than zero and sequential. Note,
4648
however, that the File daemon may send
4649
multiple Streams for the same FileIndex.
4650
The Storage Daemon uses negative FileIndices
4651
to identify Session Start and End labels
4652
as well as the End of Volume labels.
4653
Stream: defined by the File daemon and is intended to be
4654
used to identify separate parts of the data
4655
saved for each file (attributes, file data,
4656
...). The Storage Daemon has no idea of
4657
what a Stream is or what it contains.
4658
DataSize: the size in bytes of the binary data record
4659
that follows the Session Record header.
4660
The Storage Daemon has no idea of the
4661
actual contents of the binary data record.
4662
For standard Unix files, the data record
4663
typically contains the file attributes or
4664
the file data. For a sparse file
4665
the first 64 bits of the data contains
4666
the storage address for the data block.
4668
:=======================================================:
4670
|-------------------------------------------------------|
4671
| VerNum (uint32_t) |
4672
|-------------------------------------------------------|
4673
| label_date (float64_t) |
4674
| label_btime (btime_t VerNum 11 |
4675
|-------------------------------------------------------|
4676
| label_time (float64_t) |
4677
| write_btime (btime_t VerNum 11 |
4678
|-------------------------------------------------------|
4679
| write_date (float64_t) |
4680
| 0 (float64_t) VerNum 11 |
4681
|-------------------------------------------------------|
4682
| write_time (float64_t) |
4683
| 0 (float64_t) VerNum 11 |
4684
|-------------------------------------------------------|
4685
| VolName (128 bytes) |
4686
|-------------------------------------------------------|
4687
| PrevVolName (128 bytes) |
4688
|-------------------------------------------------------|
4689
| PoolName (128 bytes) |
4690
|-------------------------------------------------------|
4691
| PoolType (128 bytes) |
4692
|-------------------------------------------------------|
4693
| MediaType (128 bytes) |
4694
|-------------------------------------------------------|
4695
| HostName (128 bytes) |
4696
|-------------------------------------------------------|
4697
| LabelProg (32 bytes) |
4698
|-------------------------------------------------------|
4699
| ProgVersion (32 bytes) |
4700
|-------------------------------------------------------|
4701
| ProgDate (32 bytes) |
4702
|-------------------------------------------------------|
4703
:=======================================================:
4705
Id: 32 byte Bacula identifier "Bacula 1.0 immortal\n"
4706
(old version also recognized:)
4707
Id: 32 byte Bacula identifier "Bacula 0.9 mortal\n"
4708
LabelType (Saved in the FileIndex of the Header record).
4709
PRE_LABEL -1 Volume label on unwritten tape
4710
VOL_LABEL -2 Volume label after tape written
4711
EOM_LABEL -3 Label at EOM (not currently implemented)
4712
SOS_LABEL -4 Start of Session label (format given below)
4713
EOS_LABEL -5 End of Session label (format given below)
4715
label_date: Julian day tape labeled
4716
label_time: Julian time tape labeled
4717
write_date: Julian date tape first used (data written)
4718
write_time: Julian time tape first used (data written)
4719
VolName: "Physical" Volume name
4720
PrevVolName: The VolName of the previous tape (if this tape is
4721
a continuation of the previous one).
4724
MediaType: Media Type
4725
HostName: Name of host that is first writing the tape
4726
LabelProg: Name of the program that labeled the tape
4727
ProgVersion: Version of the label program
4728
ProgDate: Date Label program built
4730
:=======================================================:
4732
|-------------------------------------------------------|
4733
| VerNum (uint32_t) |
4734
|-------------------------------------------------------|
4735
| JobId (uint32_t) |
4736
|-------------------------------------------------------|
4737
| write_btime (btime_t) VerNum 11 |
4738
|-------------------------------------------------------|
4739
| 0 (float64_t) VerNum 11 |
4740
|-------------------------------------------------------|
4741
| PoolName (128 bytes) |
4742
|-------------------------------------------------------|
4743
| PoolType (128 bytes) |
4744
|-------------------------------------------------------|
4745
| JobName (128 bytes) |
4746
|-------------------------------------------------------|
4747
| ClientName (128 bytes) |
4748
|-------------------------------------------------------|
4750
|-------------------------------------------------------|
4751
| FileSetName (128 bytes) |
4752
|-------------------------------------------------------|
4753
| JobType (uint32_t) |
4754
|-------------------------------------------------------|
4755
| JobLevel (uint32_t) |
4756
|-------------------------------------------------------|
4757
| FileSetMD5 (50 bytes) VerNum 11 |
4758
|-------------------------------------------------------|
4759
Additional fields in End Of Session Label
4760
|-------------------------------------------------------|
4761
| JobFiles (uint32_t) |
4762
|-------------------------------------------------------|
4763
| JobBytes (uint32_t) |
4764
|-------------------------------------------------------|
4765
| start_block (uint32_t) |
4766
|-------------------------------------------------------|
4767
| end_block (uint32_t) |
4768
|-------------------------------------------------------|
4769
| start_file (uint32_t) |
4770
|-------------------------------------------------------|
4771
| end_file (uint32_t) |
4772
|-------------------------------------------------------|
4773
| JobErrors (uint32_t) |
4774
|-------------------------------------------------------|
4775
| JobStatus (uint32_t) VerNum 11 |
4776
:=======================================================:
4777
* => fields deprecated
4778
Id: 32 byte Bacula Identifier "Bacula 1.0 immortal\n"
4779
LabelType (in FileIndex field of Header):
4780
EOM_LABEL -3 Label at EOM
4781
SOS_LABEL -4 Start of Session label
4782
EOS_LABEL -5 End of Session label
4785
write_btime: Bacula time/date this tape record written
4786
write_date: Julian date tape this record written - deprecated
4787
write_time: Julian time tape this record written - deprecated.
4790
MediaType: Media Type
4791
ClientName: Name of File daemon or Client writing this session
4792
Not used for EOM_LABEL.
4796
<H2><A NAME="SECTION0001113000000000000000"></A>
4800
Unix File Attributes
4805
The Unix File Attributes packet consists of the following:
4808
<File-Index> <Type>
4809
<Filename>@<File-Attributes>@<Link>
4810
@<Extended-Attributes@> where
4814
<DT><STRONG>@</STRONG></DT>
4815
<DD>represents a byte containing a binary zero.
4819
<DT><STRONG>FileIndex</STRONG></DT>
4820
<DD><A NAME="2832"></A>
4821
is the sequential file index starting from one assigned by the File daemon.
4825
<DT><STRONG>Type</STRONG></DT>
4826
<DD><A NAME="2833"></A>
4827
is one of the following:
4831
#define FT_LNKSAVED 1 /* hard link to file already saved */
4832
#define FT_REGE 2 /* Regular file but empty */
4833
#define FT_REG 3 /* Regular file */
4834
#define FT_LNK 4 /* Soft Link */
4835
#define FT_DIR 5 /* Directory */
4836
#define FT_SPEC 6 /* Special file -- chr, blk, fifo, sock */
4837
#define FT_NOACCESS 7 /* Not able to access */
4838
#define FT_NOFOLLOW 8 /* Could not follow link */
4839
#define FT_NOSTAT 9 /* Could not stat file */
4840
#define FT_NOCHG 10 /* Incremental option, file not changed */
4841
#define FT_DIRNOCHG 11 /* Incremental option, directory not changed */
4842
#define FT_ISARCH 12 /* Trying to save archive file */
4843
#define FT_NORECURSE 13 /* No recursion into directory */
4844
#define FT_NOFSCHG 14 /* Different file system, prohibited */
4845
#define FT_NOOPEN 15 /* Could not open directory */
4846
#define FT_RAW 16 /* Raw block device */
4847
#define FT_FIFO 17 /* Raw fifo device */
4851
<DT><STRONG>Filename</STRONG></DT>
4852
<DD><A NAME="2836"></A>
4853
is the fully qualified filename.
4857
<DT><STRONG>File-Attributes</STRONG></DT>
4858
<DD><A NAME="2837"></A>
4859
consists of the 13 fields of the stat() buffer in ASCII base64 format
4860
separated by spaces. These fields and their meanings are shown below. This
4861
stat() packet is in Unix format, and MUST be provided (constructed) for ALL
4866
<DT><STRONG>Link</STRONG></DT>
4867
<DD><A NAME="2838"></A>
4868
when the FT code is FT_LNK or FT_LNKSAVED, the item in question is a Unix
4869
link, and this field contains the fully qualified link name. When the FT code
4870
is not FT_LNK or FT_LNKSAVED, this field is null.
4874
<DT><STRONG>Extended-Attributes</STRONG></DT>
4875
<DD><A NAME="2839"></A>
4876
The exact format of this field is operating system dependent. It contains
4877
additional or extended attributes of a system dependent nature. Currently,
4878
this field is used only on WIN32 systems where it contains a ASCII base64
4879
representation of the WIN32_FILE_ATTRIBUTE_DATA structure as defined by
4880
Windows. The fields in the base64 representation of this structure are like
4881
the File-Attributes separated by spaces.
4886
The File-attributes consist of the following:
4890
<TABLE CELLPADDING=3 BORDER="1">
4891
<TR><TD ALIGN="CENTER" COLSPAN=1><B>Field No. </B></TD>
4892
<TD ALIGN="CENTER" COLSPAN=1><B>Stat Name </B></TD>
4893
<TD ALIGN="CENTER" COLSPAN=1><B>Unix </B></TD>
4894
<TD ALIGN="CENTER" COLSPAN=1><B>Win98/NT </B></TD>
4895
<TD ALIGN="CENTER" COLSPAN=1><B>MacOS </B></TD>
4897
<TR><TD ALIGN="CENTER" COLSPAN=1>1</TD>
4898
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_dev</TD>
4899
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Device number of filesystem</TD>
4900
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Drive number</TD>
4901
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>vRefNum</TD>
4903
<TR><TD ALIGN="CENTER" COLSPAN=1>2</TD>
4904
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_ino</TD>
4905
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Inode number</TD>
4906
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Always 0</TD>
4907
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>fileID/dirID</TD>
4909
<TR><TD ALIGN="CENTER" COLSPAN=1>3</TD>
4910
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_mode</TD>
4911
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>File mode</TD>
4912
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>File mode</TD>
4913
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>777 dirs/apps; 666 docs; 444 locked docs</TD>
4915
<TR><TD ALIGN="CENTER" COLSPAN=1>4</TD>
4916
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_nlink</TD>
4917
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Number of links to the file</TD>
4918
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Number of link (only on NTFS)</TD>
4919
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Always 1</TD>
4921
<TR><TD ALIGN="CENTER" COLSPAN=1>5</TD>
4922
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_uid</TD>
4923
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Owner ID</TD>
4924
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Always 0</TD>
4925
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Always 0</TD>
4927
<TR><TD ALIGN="CENTER" COLSPAN=1>6</TD>
4928
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_gid</TD>
4929
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Group ID</TD>
4930
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Always 0</TD>
4931
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Always 0</TD>
4933
<TR><TD ALIGN="CENTER" COLSPAN=1>7</TD>
4934
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_rdev</TD>
4935
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Device ID for special files</TD>
4936
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Drive No.</TD>
4937
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Always 0</TD>
4939
<TR><TD ALIGN="CENTER" COLSPAN=1>8</TD>
4940
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_size</TD>
4941
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>File size in bytes</TD>
4942
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>File
4944
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Data fork file size in bytes</TD>
4946
<TR><TD ALIGN="CENTER" COLSPAN=1>9</TD>
4947
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_blksize</TD>
4948
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Preferred block size</TD>
4949
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Always 0</TD>
4950
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Preferred block size</TD>
4952
<TR><TD ALIGN="CENTER" COLSPAN=1>10</TD>
4953
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_blocks</TD>
4954
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Number of blocks allocated</TD>
4955
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Always 0</TD>
4956
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Number of blocks allocated</TD>
4958
<TR><TD ALIGN="CENTER" COLSPAN=1>11</TD>
4959
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_atime</TD>
4960
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Last access time since epoch</TD>
4961
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Last access time since epoch</TD>
4962
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Last access time -66 years</TD>
4964
<TR><TD ALIGN="CENTER" COLSPAN=1>12</TD>
4965
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_mtime</TD>
4966
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Last modify time since epoch</TD>
4967
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Last modify time since epoch</TD>
4968
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>Last access time -66 years</TD>
4970
<TR><TD ALIGN="CENTER" COLSPAN=1>13</TD>
4971
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=50>st_ctime</TD>
4972
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>Inode change time since epoch</TD>
4973
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=72>File create time since epoch</TD>
4974
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=101>File create time -66 years</TD>
4980
<H2><A NAME="SECTION0001114000000000000000"></A>
4984
Old Depreciated Tape Format
4989
The format of the Block Header (version 1.26 and earlier) is:
4993
uint32_t CheckSum; /* Block check sum */
4994
uint32_t BlockSize; /* Block byte size including the header */
4995
uint32_t BlockNumber; /* Block number */
4996
char ID[4] = "BB01"; /* Identification and block level */
4999
The format of the Record Header (version 1.26 or earlier) is:
5003
uint32_t VolSessionId; /* Unique ID for this session */
5004
uint32_t VolSessionTime; /* Start time/date of session */
5005
int32_t FileIndex; /* File index supplied by File daemon */
5006
int32_t Stream; /* Stream number supplied by File daemon */
5007
uint32_t DataSize; /* size of following data record in bytes */
5011
Current Bacula Tape Format
5013
Version BB01 is the old deprecated format.
5014
A Bacula tape is composed of tape Blocks. Each block
5015
has a Block header followed by the block data. Block
5016
Data consists of Records. Records consist of Record
5017
Headers followed by Record Data.
5018
:=======================================================:
5021
| (16 bytes version BB01) |
5022
|-------------------------------------------------------|
5025
| (20 bytes version BB01) |
5026
|-------------------------------------------------------|
5030
|-------------------------------------------------------|
5033
| (20 bytes version BB01) |
5034
|-------------------------------------------------------|
5037
Block Header: the first item in each block. The format is
5039
Partial Data block: occurs if the data from a previous
5040
block spills over to this block (the normal case except
5041
for the first block on a tape). However, this partial
5042
data block is always preceded by a record header.
5043
Record Header: identifies the Volume Session, the Stream
5044
and the following Record Data size. See below for format.
5045
Record data: arbitrary binary data.
5046
Block Header Format BB01 (deprecated)
5047
:=======================================================:
5048
| CheckSum (uint32_t) |
5049
|-------------------------------------------------------|
5050
| BlockSize (uint32_t) |
5051
|-------------------------------------------------------|
5052
| BlockNumber (uint32_t) |
5053
|-------------------------------------------------------|
5054
| "BB01" (char [4]) |
5055
:=======================================================:
5056
BBO1: Serves to identify the block as a
5057
Bacula block and also servers as a block format identifier
5058
should we ever need to change the format.
5059
BlockSize: is the size in bytes of the block. When reading
5060
back a block, if the BlockSize does not agree with the
5061
actual size read, Bacula discards the block.
5062
CheckSum: a checksum for the Block.
5063
BlockNumber: is the sequential block number on the tape.
5064
VolSessionId: a unique sequential number that is assigned
5065
by the Storage Daemon to a particular Job.
5066
This number is sequential since the start
5067
of execution of the daemon.
5068
VolSessionTime: the time/date that the current execution
5069
of the Storage Daemon started. It assures
5070
that the combination of VolSessionId and
5071
VolSessionTime is unique for all jobs
5072
written to the tape, even if there was a
5073
machine crash between two writes.
5074
Record Header Format BB01 (deprecated)
5075
:=======================================================:
5076
| VolSessionId (uint32_t) |
5077
|-------------------------------------------------------|
5078
| VolSessionTime (uint32_t) |
5079
|-------------------------------------------------------|
5080
| FileIndex (int32_t) |
5081
|-------------------------------------------------------|
5082
| Stream (int32_t) |
5083
|-------------------------------------------------------|
5084
| DataSize (uint32_t) |
5085
:=======================================================:
5086
VolSessionId: a unique sequential number that is assigned
5087
by the Storage Daemon to a particular Job.
5088
This number is sequential since the start
5089
of execution of the daemon.
5090
VolSessionTime: the time/date that the current execution
5091
of the Storage Daemon started. It assures
5092
that the combination of VolSessionId and
5093
VolSessionTime is unique for all jobs
5094
written to the tape, even if there was a
5095
machine crash between two writes.
5096
FileIndex: a sequential file number within a job. The
5097
Storage daemon enforces this index to be
5098
greater than zero and sequential. Note,
5099
however, that the File daemon may send
5100
multiple Streams for the same FileIndex.
5101
The Storage Daemon uses negative FileIndices
5102
to identify Session Start and End labels
5103
as well as the End of Volume labels.
5104
Stream: defined by the File daemon and is intended to be
5105
used to identify separate parts of the data
5106
saved for each file (attributes, file data,
5107
...). The Storage Daemon has no idea of
5108
what a Stream is or what it contains.
5109
DataSize: the size in bytes of the binary data record
5110
that follows the Session Record header.
5111
The Storage Daemon has no idea of the
5112
actual contents of the binary data record.
5113
For standard Unix files, the data record
5114
typically contains the file attributes or
5115
the file data. For a sparse file
5116
the first 64 bits of the data contains
5117
the storage address for the data block.
5119
:=======================================================:
5121
|-------------------------------------------------------|
5122
| VerNum (uint32_t) |
5123
|-------------------------------------------------------|
5124
| label_date (float64_t) |
5125
|-------------------------------------------------------|
5126
| label_time (float64_t) |
5127
|-------------------------------------------------------|
5128
| write_date (float64_t) |
5129
|-------------------------------------------------------|
5130
| write_time (float64_t) |
5131
|-------------------------------------------------------|
5132
| VolName (128 bytes) |
5133
|-------------------------------------------------------|
5134
| PrevVolName (128 bytes) |
5135
|-------------------------------------------------------|
5136
| PoolName (128 bytes) |
5137
|-------------------------------------------------------|
5138
| PoolType (128 bytes) |
5139
|-------------------------------------------------------|
5140
| MediaType (128 bytes) |
5141
|-------------------------------------------------------|
5142
| HostName (128 bytes) |
5143
|-------------------------------------------------------|
5144
| LabelProg (32 bytes) |
5145
|-------------------------------------------------------|
5146
| ProgVersion (32 bytes) |
5147
|-------------------------------------------------------|
5148
| ProgDate (32 bytes) |
5149
|-------------------------------------------------------|
5150
:=======================================================:
5152
Id: 32 byte Bacula identifier "Bacula 1.0 immortal\n"
5153
(old version also recognized:)
5154
Id: 32 byte Bacula identifier "Bacula 0.9 mortal\n"
5155
LabelType (Saved in the FileIndex of the Header record).
5156
PRE_LABEL -1 Volume label on unwritten tape
5157
VOL_LABEL -2 Volume label after tape written
5158
EOM_LABEL -3 Label at EOM (not currently implemented)
5159
SOS_LABEL -4 Start of Session label (format given below)
5160
EOS_LABEL -5 End of Session label (format given below)
5161
label_date: Julian day tape labeled
5162
label_time: Julian time tape labeled
5163
write_date: Julian date tape first used (data written)
5164
write_time: Julian time tape first used (data written)
5165
VolName: "Physical" Volume name
5166
PrevVolName: The VolName of the previous tape (if this tape is
5167
a continuation of the previous one).
5170
MediaType: Media Type
5171
HostName: Name of host that is first writing the tape
5172
LabelProg: Name of the program that labeled the tape
5173
ProgVersion: Version of the label program
5174
ProgDate: Date Label program built
5176
:=======================================================:
5178
|-------------------------------------------------------|
5179
| VerNum (uint32_t) |
5180
|-------------------------------------------------------|
5181
| JobId (uint32_t) |
5182
|-------------------------------------------------------|
5183
| *write_date (float64_t) VerNum 10 |
5184
|-------------------------------------------------------|
5185
| *write_time (float64_t) VerNum 10 |
5186
|-------------------------------------------------------|
5187
| PoolName (128 bytes) |
5188
|-------------------------------------------------------|
5189
| PoolType (128 bytes) |
5190
|-------------------------------------------------------|
5191
| JobName (128 bytes) |
5192
|-------------------------------------------------------|
5193
| ClientName (128 bytes) |
5194
|-------------------------------------------------------|
5196
|-------------------------------------------------------|
5197
| FileSetName (128 bytes) |
5198
|-------------------------------------------------------|
5199
| JobType (uint32_t) |
5200
|-------------------------------------------------------|
5201
| JobLevel (uint32_t) |
5202
|-------------------------------------------------------|
5203
| FileSetMD5 (50 bytes) VerNum 11 |
5204
|-------------------------------------------------------|
5205
Additional fields in End Of Session Label
5206
|-------------------------------------------------------|
5207
| JobFiles (uint32_t) |
5208
|-------------------------------------------------------|
5209
| JobBytes (uint32_t) |
5210
|-------------------------------------------------------|
5211
| start_block (uint32_t) |
5212
|-------------------------------------------------------|
5213
| end_block (uint32_t) |
5214
|-------------------------------------------------------|
5215
| start_file (uint32_t) |
5216
|-------------------------------------------------------|
5217
| end_file (uint32_t) |
5218
|-------------------------------------------------------|
5219
| JobErrors (uint32_t) |
5220
|-------------------------------------------------------|
5221
| JobStatus (uint32_t) VerNum 11 |
5222
:=======================================================:
5223
* => fields deprecated
5224
Id: 32 byte Bacula Identifier "Bacula 1.0 immortal\n"
5225
LabelType (in FileIndex field of Header):
5226
EOM_LABEL -3 Label at EOM
5227
SOS_LABEL -4 Start of Session label
5228
EOS_LABEL -5 End of Session label
5231
write_btime: Bacula time/date this tape record written
5232
write_date: Julian date tape this record written - deprecated
5233
write_time: Julian time tape this record written - deprecated.
5236
MediaType: Media Type
5237
ClientName: Name of File daemon or Client writing this session
5238
Not used for EOM_LABEL.
5242
<H1><A NAME="SECTION000120000000000000000"></A>
5243
<A NAME="_ChapterStart1"></A><A NAME="3236"></A>
5246
Bacula Porting Notes
5251
This document is intended mostly for developers who wish to port Bacula to a
5252
system that is not <B>officially</B> supported.
5255
It is hoped that Bacula clients will eventually run on every imaginable system
5256
that needs backing up (perhaps even a Palm). It is also hoped that the Bacula
5257
Directory and Storage daemons will run on every system capable of supporting
5262
<H2><A NAME="SECTION000121000000000000000"></A>
5266
Porting Requirements
5271
In General, the following holds true:
5276
<LI><B>Bacula</B> has been compiled and run on Linux RedHat, FreeBSD, and
5279
<LI>In addition, clients exist on Win32, and Irix
5281
<LI>It requires GNU C++ to compile. You can try with other compilers, but
5282
you are on your own. The Irix client is built with the Irix complier, but, in
5283
general, you will need GNU.
5285
<LI>Your compiler must provide support for 64 bit signed and unsigned
5288
<LI>You will need a recent copy of the <B>autoconf</B> tools loaded on your
5289
system (version 2.13 or later). The <B>autoconf</B> tools are used to build
5290
the configuration program, but are not part of the Bacula source
5293
<LI>There are certain third party packages that Bacula needs. Except for
5294
MySQL, they can all be found in the <B>depkgs</B> and <B>depkgs1</B> releases.
5296
<LI>To build the Win32 binaries, we use Microsoft VC++ standard
5297
2003. Please see the instructions in
5298
bacula-source/src/win32/README.win32 for more details. If you
5299
want to use VC++ Express, please see README.vc8. Our build is
5300
done under the most recent version of Cygwin, but Cygwin is
5301
not used in the Bacula binaries that are produced.
5302
Unfortunately, we do not have the resources to help you build
5303
your own version of the Win32 FD, so you are pretty much on
5304
your own. You can ask the bacula-devel list for help, but
5305
please don't expect much.
5307
<LI><B>Bacula</B> requires a good implementation of pthreads to work.
5309
<LI>The source code has been written with portability in mind and is mostly
5310
POSIX compatible. Thus porting to any POSIX compatible operating system
5311
should be relatively easy.
5317
<H2><A NAME="SECTION000122000000000000000"></A>
5321
Steps to Take for Porting
5328
<LI>The first step is to ensure that you have version 2.13 or later of the
5329
<B>autoconf</B> tools loaded. You can skip this step, but making changes to
5330
the configuration program will be difficult or impossible.
5332
<LI>The run a <B>./configure</B> command in the main source directory and
5333
examine the output. It should look something like the following:
5337
Configuration on Mon Oct 28 11:42:27 CET 2002:
5338
Host: i686-pc-linux-gnu -- redhat 7.3
5339
Bacula version: 1.27 (26 October 2002)
5340
Source code location: .
5341
Install binaries: /sbin
5342
Install config files: /etc/bacula
5345
Compiler flags: -g -O2
5347
Libraries: -lpthread
5348
Statically Linked Tools: no
5350
Database type: Internal
5352
Job Output Email: root@localhost
5353
Traceback Email: root@localhost
5354
SMTP Host Address: localhost
5356
File daemon Port 9102
5357
Storage daemon Port 9103
5358
Working directory /etc/bacula/working
5359
SQL binaries Directory
5360
Large file support: yes
5361
readline support: yes
5362
cweb support: yes /home/kern/bacula/depkgs/cweb
5363
TCP Wrappers support: no
5365
enable-smartalloc: yes
5370
The details depend on your system. The first thing to check is that it
5371
properly identified your host on the <B>Host:</B> line. The first part (added
5372
in version 1.27) is the GNU four part identification of your system. The part
5373
after the -- is your system and the system version. Generally, if your system
5374
is not yet supported, you must correct these.
5376
<LI>If the <B>./configure</B> does not function properly, you must determine
5377
the cause and fix it. Generally, it will be because some required system
5378
routine is not available on your machine.
5380
<LI>To correct problems with detection of your system type or with routines
5381
and libraries, you must edit the file <B> <bacula-src>/autoconf/configure.in</B>. This is the ``source'' from
5382
which <B>configure</B> is built. In general, most of the changes for your
5383
system will be made in <B>autoconf/aclocal.m4</B> in the routine <B>BA_CHECK_OPSYS</B> or in the routine <B>BA_CHECK_OPSYS_DISTNAME</B>. I have
5384
already added the necessary code for most systems, but if yours shows up as
5385
<B>unknown</B> you will need to make changes. Then as mentioned above, you
5386
will need to set a number of system dependent items in <B>configure.in</B> in
5387
the <B>case</B> statement at approximately line 1050 (depending on the Bacula
5390
<LI>The items to in the case statement that corresponds to your system are
5396
<LI>DISTVER -- set to the version of your operating system. Typically some
5397
form of <B>uname</B> obtains it.
5399
<LI>TAPEDRIVE -- the default tape drive. Not too important as the user can
5400
set it as an option.
5402
<LI>PSCMD -- set to the <B>ps</B> command that will provide the PID in the
5403
first field and the program name in the second field. If this is not set
5404
properly, the <B>bacula stop</B> script will most likely not be able to stop
5405
Bacula in all cases.
5407
<LI>hostname -- command to return the base host name (non-qualified) of
5408
your system. This is generally the machine name. Not too important as the
5409
user can correct this in his configuration file.
5411
<LI>CFLAGS -- set any special compiler flags needed. Many systems need a
5412
special flag to make pthreads work. See cygwin for an example.
5414
<LI>LDFLAGS -- set any special loader flags. See cygwin for an example.
5416
<LI>PTHREAD_LIB -- set for any special pthreads flags needed during
5417
linking. See freebsd as an example.
5419
<LI>lld -- set so that a ``long long int'' will be properly edited in a
5422
<LI>llu -- set so that a ``long long unsigned'' will be properly edited in
5425
<LI>PFILES -- set to add any files that you may define is your platform
5426
subdirectory. These files are used for installation of automatic system
5427
startup of Bacula daemons.
5433
<LI>To rebuild a new version of <B>configure</B> from a changed <B> autoconf/configure.in</B> you enter <B>make configure</B> in the top level Bacula
5434
source directory. You must have done a ./configure prior to trying to rebuild
5435
the configure script or it will get into an infinite loop.
5437
<LI>If the <B>make configure</B> gets into an infinite loop, ctl-c it, then
5438
do <B>./configure</B> (no options are necessary) and retry the <B>make
5439
configure</B>, which should now work.
5441
<LI>To rebuild <B>configure</B> you will need to have <B>autoconf</B> version
5442
2.57-3 or higher loaded. Older versions of autoconf will complain about
5443
unknown or bad options, and won't work.
5445
<LI>After you have a working <B>configure</B> script, you may need to make a
5446
few system dependent changes to the way Bacula works. Generally, these are
5447
done in <B>src/baconfig.h</B>. You can find a few examples of system dependent
5448
changes toward the end of this file. For example, on Irix systems, there is
5449
no definition for <B>socklen_t</B>, so it is made in this file. If your
5450
system has structure alignment requirements, check the definition of BALIGN
5451
in this file. Currently, all Bacula allocated memory is aligned on a <B>double</B> boundary.
5453
<LI>If you are having problems with Bacula's type definitions, you might
5454
look at <B>src/bc_types.h</B> where all the types such as <B>uint32_t</B>,
5455
<B>uint64_t</B>, etc. that Bacula uses are defined.
5461
<H1><A NAME="SECTION000130000000000000000"></A>
5462
<A NAME="_ChapterStart"></A>
5464
Implementing a Bacula GUI Interface
5472
<H2><A NAME="SECTION000131000000000000000">
5479
This document is intended mostly for developers who wish to develop a new GUI
5480
interface to <B>Bacula</B>.
5484
<H3><A NAME="SECTION000131100000000000000">
5485
Minimal Code in Console Program</A>
5492
Until now, I have kept all the Catalog code in the Directory (with the
5493
exception of dbcheck and bscan). This is because at some point I would like to
5494
add user level security and access. If we have code spread everywhere such as
5495
in a GUI this will be more difficult. The other advantage is that any code you
5496
add to the Director is automatically available to both the tty console program
5497
and the GNOME program. The major disadvantage is it increases the size of the
5498
code -- however, compared to Networker the Bacula Director is really tiny.
5502
<H3><A NAME="SECTION000131200000000000000">
5503
GUI Interface is Difficult</A>
5510
Interfacing to an interactive program such as Bacula can be very difficult
5511
because the interfacing program must interpret all the prompts that may come.
5512
This can be next to impossible. There are are a number of ways that Bacula is
5513
designed to facilitate this:
5518
<LI>The Bacula network protocol is packet based, and thus pieces of
5519
information sent can be ASCII or binary.
5521
<LI>The packet interface permits knowing where the end of a list is.
5523
<LI>The packet interface permits special ``signals'' to be passed rather
5526
<LI>The Director has a number of commands that are non-interactive. They
5527
all begin with a period, and provide things such as the list of all Jobs,
5528
list of all Clients, list of all Pools, list of all Storage, ... Thus the GUI
5529
interface can get to virtually all information that the Director has in a
5530
deterministic way. See <bacula-source>/src/dird/ua_dotcmds.c for
5531
more details on this.
5533
<LI>Most console commands allow all the arguments to be specified on the
5534
command line: e.g. <B>run job=NightlyBackup level=Full</B>
5539
One of the first things to overcome is to be able to establish a conversation
5540
with the Director. Although you can write all your own code, it is probably
5541
easier to use the Bacula subroutines. The following code is used by the
5542
Console program to begin a conversation.
5546
static BSOCK *UA_sock = NULL;
5549
read-your-config-getting-address-and-pasword;
5550
UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address,
5551
NULL, dir->DIRport, 0);
5552
if (UA_sock == NULL) {
5553
terminate_console(0);
5556
jcr.dir_bsock = UA_sock;
5557
if (!authenticate_director(\&jcr, dir)) {
5558
fprintf(stderr, "ERR=%s", UA_sock->msg);
5559
terminate_console(0);
5562
read_and_process_input(stdin, UA_sock);
5564
bnet_sig(UA_sock, BNET_TERMINATE); /* send EOF */
5565
bnet_close(UA_sock);
5570
Then the read_and_process_input routine looks like the following:
5574
get-input-to-send-to-the-Director;
5575
bnet_fsend(UA_sock, "%s", input);
5576
stat = bnet_recv(UA_sock);
5577
process-output-from-the-Director;
5580
For a GUI program things will be a bit more complicated. Basically in the very
5581
inner loop, you will need to check and see if any output is available on the
5582
UA_sock. For an example, please take a look at the GNOME GUI interface code
5583
in: <bacula-source&gt/src/gnome-console/console.c
5587
<H1><A NAME="SECTION000140000000000000000"></A>
5588
<A NAME="_Chapter_TLS"></A><A NAME="3477"></A>
5595
Written by Landon Fuller
5599
<H2><A NAME="SECTION000141000000000000000"></A>
5608
This patch includes all the back-end code necessary to add complete TLS
5609
data encryption support to Bacula. In addition, support for TLS in
5610
Console/Director communications has been added as a proof of concept.
5611
Adding support for the remaining daemons will be straight-forward.
5612
Supported features of this patchset include:
5617
<LI>Client/Server TLS Requirement Negotiation
5619
<LI>TLSv1 Connections with Server and Client Certificate
5622
<LI>Forward Secrecy Support via Diffie-Hellman Ephemeral Keying
5627
This document will refer to both ``server'' and ``client'' contexts. These
5628
terms refer to the accepting and initiating peer, respectively.
5631
Diffie-Hellman anonymous ciphers are not supported by this patchset. The
5632
use of DH anonymous ciphers increases the code complexity and places
5633
explicit trust upon the two-way Cram-MD5 implementation. Cram-MD5 is
5634
subject to known plaintext attacks, and is should be considered
5635
considerably less secure than PKI certificate-based authentication.
5638
Appropriate autoconf macros have been added to detect and use OpenSSL. Two
5639
additional preprocessor defines have been added: <I>HAVE_TLS</I> and
5640
<I>HAVE_OPENSSL</I>. All changes not specific to OpenSSL rely on
5641
<I>HAVE_TLS</I>. OpenSSL-specific code is constrained to
5642
<I>src/lib/tls.c</I> to facilitate the support of alternative TLS
5647
<H2><A NAME="SECTION000142000000000000000"></A>
5651
New Configuration Directives
5656
Additional configuration directives have been added to both the Console and
5657
Director resources. These new directives are defined as follows:
5662
<LI><U>TLS Enable</U> <I>(yes/no)</I>
5667
<LI><U>TLS Require</U> <I>(yes/no)</I>
5668
Require TLS connections.
5672
<LI><U>TLS Certificate</U> <I>(path)</I>
5673
Path to PEM encoded TLS certificate. Used as either a client or server
5678
<LI><U>TLS Key</U> <I>(path)</I>
5679
Path to PEM encoded TLS private key. Must correspond with the TLS
5684
<LI><U>TLS Verify Peer</U> <I>(yes/no)</I>
5685
Verify peer certificate. Instructs server to request and verify the
5686
client's x509 certificate. Any client certificate signed by a known-CA
5687
will be accepted unless the TLS Allowed CN configuration directive is used.
5688
Not valid in a client context.
5692
<LI><U>TLS Allowed CN</U> <I>(string list)</I>
5693
Common name attribute of allowed peer certificates. If directive is
5694
specified, all client certificates will be verified against this list.
5695
This directive may be specified more than once. Not valid in a client
5700
<LI><U>TLS CA Certificate File</U> <I>(path)</I>
5701
Path to PEM encoded TLS CA certificate(s). Multiple certificates are
5702
permitted in the file. One of <I>TLS CA Certificate File</I> or <I>TLS
5703
CA Certificate Dir</I> are required in a server context if <U>TLS
5704
Verify Peer</U> is also specified, and are always required in a client
5709
<LI><U>TLS CA Certificate Dir</U> <I>(path)</I>
5710
Path to TLS CA certificate directory. In the current implementation,
5711
certificates must be stored PEM encoded with OpenSSL-compatible hashes.
5712
One of <I>TLS CA Certificate File</I> or <I>TLS CA Certificate Dir</I> are
5713
required in a server context if <I>TLS Verify Peer</I> is also specified,
5714
and are always required in a client context.
5718
<LI><U>TLS DH File</U> <I>(path)</I>
5719
Path to PEM encoded Diffie-Hellman parameter file. If this directive is
5720
specified, DH ephemeral keying will be enabled, allowing for forward
5721
secrecy of communications. This directive is only valid within a server
5722
context. To generate the parameter file, you may use openssl:
5724
openssl dhparam -out dh1024.pem -5 1024
5731
<H2><A NAME="SECTION000143000000000000000"></A>
5735
TLS API Implementation
5740
To facilitate the use of additional TLS libraries, all OpenSSL-specific
5741
code has been implemented within <I>src/lib/tls.c</I>. In turn, a generic
5742
TLS API is exported.
5746
<H3><A NAME="SECTION000143100000000000000"></A>
5750
Library Initialization and Cleanup
5756
int init_tls (void);
5759
Performs TLS library initialization, including seeding of the PRNG. PRNG
5760
seeding has not yet been implemented for win32.
5764
int cleanup_tls (void);
5767
Performs TLS library cleanup.
5771
<H3><A NAME="SECTION000143200000000000000"></A>
5775
Manipulating TLS Contexts
5781
TLS_CONTEXT *new_tls_context (const char *ca_certfile,
5782
const char *ca_certdir, const char *certfile,
5783
const char *keyfile, const char *dhfile, bool verify_peer);
5786
Allocates and initalizes a new opaque <I>TLS_CONTEXT</I> structure. The
5787
<I>TLS_CONTEXT</I> structure maintains default TLS settings from which
5788
<I>TLS_CONNECTION</I> structures are instantiated. In the future the
5789
<I>TLS_CONTEXT</I> structure may be used to maintain the TLS session
5790
cache. <I>ca_certfile</I> and <I>ca_certdir</I> arguments are used to
5791
initialize the CA verification stores. The <I>certfile</I> and
5792
<I>keyfile</I> arguments are used to initialize the local certificate and
5793
private key. If <I>dhfile</I> is non-NULL, it is used to initialize
5794
Diffie-Hellman ephemeral keying. If <I>verify_peer</I> is <I>true</I> ,
5795
client certificate validation is enabled.
5799
void free_tls_context (TLS_CONTEXT *ctx);
5802
Deallocated a previously allocated <I>TLS_CONTEXT</I> structure.
5806
<H3><A NAME="SECTION000143300000000000000"></A>
5810
Performing Post-Connection Verification
5816
bool tls_postconnect_verify_host (TLS_CONNECTION *tls, const char *host);
5819
Performs post-connection verification of the peer-supplied x509
5820
certificate. Checks whether the <I>subjectAltName</I> and
5821
<I>commonName</I> attributes match the supplied <I>host</I> string.
5822
Returns <I>true</I> if there is a match, <I>false</I> otherwise.
5826
bool tls_postconnect_verify_cn (TLS_CONNECTION *tls, alist *verify_list);
5829
Performs post-connection verification of the peer-supplied x509
5830
certificate. Checks whether the <I>commonName</I> attribute matches any
5831
strings supplied via the <I>verify_list</I> parameter. Returns
5832
<I>true</I> if there is a match, <I>false</I> otherwise.
5836
<H3><A NAME="SECTION000143400000000000000"></A>
5840
Manipulating TLS Connections
5846
TLS_CONNECTION *new_tls_connection (TLS_CONTEXT *ctx, int fd);
5849
Allocates and initializes a new <I>TLS_CONNECTION</I> structure with
5850
context <I>ctx</I> and file descriptor <I>fd</I>.
5854
void free_tls_connection (TLS_CONNECTION *tls);
5857
Deallocates memory associated with the <I>tls</I> structure.
5861
bool tls_bsock_connect (BSOCK *bsock);
5864
Negotiates a a TLS client connection via <I>bsock</I>. Returns <I>true</I>
5865
if successful, <I>false</I> otherwise. Will fail if there is a TLS
5866
protocol error or an invalid certificate is presented
5870
bool tls_bsock_accept (BSOCK *bsock);
5873
Accepts a TLS client connection via <I>bsock</I>. Returns <I>true</I> if
5874
successful, <I>false</I> otherwise. Will fail if there is a TLS protocol
5875
error or an invalid certificate is presented.
5879
bool tls_bsock_shutdown (BSOCK *bsock);
5882
Issues a blocking TLS shutdown request to the peer via <I>bsock</I>. This function may not wait for the peer's reply.
5886
int tls_bsock_writen (BSOCK *bsock, char *ptr, int32_t nbytes);
5889
Writes <I>nbytes</I> from <I>ptr</I> via the <I>TLS_CONNECTION</I>
5890
associated with <I>bsock</I>. Due to OpenSSL's handling of <I>EINTR</I>,
5891
<I>bsock</I> is set non-blocking at the start of the function, and restored
5892
to its original blocking state before the function returns. Less than
5893
<I>nbytes</I> may be written if an error occurs. The actual number of
5894
bytes written will be returned.
5898
int tls_bsock_readn (BSOCK *bsock, char *ptr, int32_t nbytes);
5901
Reads <I>nbytes</I> from the <I>TLS_CONNECTION</I> associated with
5902
<I>bsock</I> and stores the result in <I>ptr</I>. Due to OpenSSL's
5903
handling of <I>EINTR</I>, <I>bsock</I> is set non-blocking at the start of
5904
the function, and restored to its original blocking state before the
5905
function returns. Less than <I>nbytes</I> may be read if an error occurs.
5906
The actual number of bytes read will be returned.
5910
<H2><A NAME="SECTION000144000000000000000"></A>
5919
A minimal number of changes were required in the Bnet socket API. The BSOCK
5920
structure was expanded to include an associated TLS_CONNECTION structure,
5921
as well as a flag to designate the current blocking state of the socket.
5922
The blocking state flag is required for win32, where it does not appear
5923
possible to discern the current blocking state of a socket.
5927
<H3><A NAME="SECTION000144100000000000000"></A>
5931
Negotiating a TLS Connection
5936
<I>bnet_tls_server()</I> and <I>bnet_tls_client()</I> were both
5937
implemented using the new TLS API as follows:
5941
int bnet_tls_client(TLS_CONTEXT *ctx, BSOCK * bsock);
5944
Negotiates a TLS session via <I>bsock</I> using the settings from
5945
<I>ctx</I>. Returns 1 if successful, 0 otherwise.
5949
int bnet_tls_server(TLS_CONTEXT *ctx, BSOCK * bsock, alist *verify_list);
5952
Accepts a TLS client session via <I>bsock</I> using the settings from
5953
<I>ctx</I>. If <I>verify_list</I> is non-NULL, it is passed to
5954
<I>tls_postconnect_verify_cn()</I> for client certificate verification.
5958
<H3><A NAME="SECTION000144200000000000000"></A>
5963
Manipulating Socket Blocking State
5968
Three functions were added for manipulating the blocking state of a socket
5969
on both Win32 and Unix-like systems. The Win32 code was written according
5970
to the MSDN documentation, but has not been tested.
5973
These functions are prototyped as follows:
5977
int bnet_set_nonblocking (BSOCK *bsock);
5980
Enables non-blocking I/O on the socket associated with <I>bsock</I>.
5981
Returns a copy of the socket flags prior to modification.
5985
int bnet_set_blocking (BSOCK *bsock);
5988
Enables blocking I/O on the socket associated with <I>bsock</I>. Returns a
5989
copy of the socket flags prior to modification.
5993
void bnet_restore_blocking (BSOCK *bsock, int flags);
5996
Restores blocking or non-blocking IO setting on the socket associated with
5997
<I>bsock</I>. The <I>flags</I> argument must be the return value of either
5998
<I>bnet_set_blocking()</I> or <I>bnet_restore_blocking()</I>.
6004
<H2><A NAME="SECTION000145000000000000000"></A>
6008
Authentication Negotiation
6013
Backwards compatibility with the existing SSL negotiation hooks implemented
6014
in src/lib/cram-md5.c have been maintained. The
6015
<I>cram_md5_get_auth()</I> function has been modified to accept an
6016
integer pointer argument, tls_remote_need. The TLS requirement
6017
advertised by the remote host is returned via this pointer.
6020
After exchanging cram-md5 authentication and TLS requirements, both the
6021
client and server independently decide whether to continue:
6025
if (!cram_md5_get_auth(dir, password, &tls_remote_need) ||
6026
!cram_md5_auth(dir, password, tls_local_need)) {
6028
/* Verify that the remote host is willing to meet our TLS requirements */
6029
if (tls_remote_need < tls_local_need && tls_local_need != BNET_TLS_OK &&
6030
tls_remote_need != BNET_TLS_OK) {
6031
sendit(_("Authorization problem:"
6032
" Remote server did not advertise required TLS support.\n"));
6033
auth_success = false;
6037
/* Verify that we are willing to meet the remote host's requirements */
6038
if (tls_remote_need > tls_local_need && tls_local_need != BNET_TLS_OK &&
6039
tls_remote_need != BNET_TLS_OK) {
6040
sendit(_("Authorization problem:"
6041
" Remote server requires TLS.\n"));
6042
auth_success = false;
6048
<H1><A NAME="SECTION000150000000000000000"></A>
6049
<A NAME="_ChapterStart8"></A><A NAME="3912"></A>
6052
Bacula Regression Testing
6058
<H2><A NAME="SECTION000151000000000000000"></A>
6066
This document is intended mostly for developers who wish to ensure that their
6067
changes to Bacula don't introduce bugs in the base code.
6070
You can find the existing regression script in the Bacula CVS on the
6071
SourceForge CVS in the project tree named <B>regress</B>.
6074
There are two different aspects of regression testing that this document will
6075
discuss: 1. Running the Regression Script, 2. Writing a Regression test.
6079
<H2><A NAME="SECTION000152000000000000000"></A>
6083
Running the Regression Script
6088
There are a number of different tests that may be run, such as: the standard
6089
set that uses disk Volumes and runs under any userid; a small set of tests
6090
that write to tape; another set of tests where you must be root to run them.
6091
To date, each subset of tests runs no more than about 15 minutes.
6095
<H3><A NAME="SECTION000152100000000000000"></A>
6099
Setting the Configuration Parameters
6104
Once you have the regression directory loaded, you will first need to create a
6105
custom xxx.conf file for your system. You can either edit <B>prototype.conf</B>
6106
directly or copy it to a new file and edit it. To see a real example of a
6107
configuration file, look at <B>kern.conf</B>. The variables you need to modify
6113
# Where to get the source to be tested
6114
# BACULA_SOURCE="${HOME}/bacula/branch-1.36.2"
6115
BACULA_SOURCE="${HOME}/bacula/k"
6117
# Where to send email !!!!! Change me !!!!!!!
6118
EMAIL=kern@sibbald.com
6119
SMTP_HOST="localhost"
6121
# Full "default" path where to find sqlite (no quotes!)
6122
#SQLITE_DIR=${HOME}/bacula/depkgs/sqlite3
6123
SQLITE_DIR=${HOME}/bacula/depkgs/sqlite
6125
TAPE_DRIVE="/dev/nst0"
6126
# if you don't have an autochanger set AUTOCHANGER to /dev/null
6127
AUTOCHANGER="/dev/sg0"
6128
# For two drive tests -- set to /dev/null if you do not have it
6129
TAPE_DRIVE1="/dev/nst1"
6131
# This must be the path to the autochanger including its name
6132
AUTOCHANGER_PATH="/usr/sbin/mtx"
6134
# Set your database here
6135
#SQLITE_DIR=${HOME}/bacula/depkgs/sqlite3
6136
WHICHDB?="--with-sqlite=${SQLITE_DIR}"
6137
#WHICHDB="--with-mysql=${HOME}/mysql"
6139
# Set this to "--with-tcp-wrappers" or "--without-tcp-wrappers"
6140
TCPWRAPPERS="--with-tcp-wrappers"
6145
<LI><B>BACULA_SOURCE</B> should be the full path to the Bacula source code
6146
that you wish to test.
6148
<LI><B>EMAIL</B> should be your email addres. Please remember to change this
6149
or I will get a flood of unwanted messages. You may or may not want to see
6150
these emails. In my case, I don't need them so I direct it to the bit bucket.
6152
<LI><B>SMTP_HOST</B> defines where your SMTP server is.
6156
<LI><B>SQLITE_DIR</B> should be the full path to the sqlite package, must
6157
be build before running a Bacula regression, if you are using SQLite. This
6158
variable is ignored if you are using MySQL or PostgreSQL. To use PostgreSQL,
6159
edit the Makefile and change (or add) WHICHDB?=``<code>--</code>with-postgresql''. For
6160
MySQL use ``WHICHDB?=''<code>--</code>with-mysql``.
6164
<LI><B>TAPE_DRIVE</B> is the full path to your tape drive. The base set of
6165
regression tests do not use a tape, so this is only important if you want to
6170
<LI><B>TAPE_DRIVE1</B> is the full path to your second tape drive, if
6171
have one. The base set of
6172
regression tests do not use a tape, so this is only important if you want to
6173
run the full two drive tests.
6177
<LI><B>AUTOCHANGER</B> is the name of your autochanger device. Set this to
6178
/dev/null if you do not have one.
6182
<LI><B>AUTOCHANGER_PATH</B> is the full path including the program name for
6183
your autochanger program (normally <B>mtx</B>. Leave the default value if you
6188
<LI><B>TCPWRAPPERS</B> defines whether or not you want the ./configure
6189
to be performed with tcpwrappers enabled.
6197
<H3><A NAME="SECTION000152200000000000000"></A>
6201
Building the Test Bacula
6206
Once the above variables are set, you can build Bacula by entering:
6214
Where xxx.conf is the name of the conf file containing your system parameters.
6215
This will build a Makefile from Makefile.in, then copy the source code within
6216
the regression tree (in directory regress/build), configure it, and build it.
6217
There should be no errors. If there are, please correct them before
6222
<H3><A NAME="SECTION000152300000000000000"></A>
6226
Running the Disk Only Regression
6231
Once Bacula is built, you can run the basic disk only non-root regression test
6239
This will run the base set of tests using disk Volumes, currently (19 Dec
6240
2003), there are current 18 separate tests that run. If you are testing on a
6241
non-Linux machine two of the tests will not be run. In any case, as we add new
6242
tests, the number will vary. It will take about 5 or 10 minutes if you have a
6243
fast (2 GHz) machine, and you don't need to be root to run these tests (I run
6244
under my regular userid). The result should be something similar to:
6250
===== Backup Bacula Test OK =====
6251
===== Verify Volume Test OK =====
6252
===== sparse-test OK =====
6253
===== compressed-test OK =====
6254
===== sparse-compressed-test OK =====
6255
===== Weird files test OK =====
6256
===== two-jobs-test OK =====
6257
===== two-vol-test OK =====
6258
===== six-vol-test OK =====
6259
===== bscan-test OK =====
6260
===== Weird files2 test OK =====
6261
===== concurrent-jobs-test OK =====
6262
===== four-concurrent-jobs-test OK =====
6263
===== bsr-opt-test OK =====
6264
===== bextract-test OK =====
6265
===== recycle-test OK =====
6266
===== span-vol-test OK =====
6267
===== restore-by-file-test OK =====
6268
===== restore2-by-file-test OK =====
6269
===== four-jobs-test OK =====
6270
===== incremental-test OK =====
6273
and the working tape tests are:
6279
===== Bacula tape test OK =====
6280
===== Small File Size test OK =====
6281
===== restore-by-file-tape test OK =====
6282
===== incremental-tape test OK =====
6283
===== four-concurrent-jobs-tape OK =====
6284
===== four-jobs-tape OK =====
6287
Each separate test is self contained in that it initializes to run Bacula from
6288
scratch (i.e. newly created database). It will also kill any Bacula session
6289
that is currently running. In addition, it uses ports 8101, 8102, and 8103 so
6290
that it does not intefere with a production system.
6294
<H3><A NAME="SECTION000152400000000000000"></A>
6303
There are a number of other tests that can be run as well. All the tests are a
6304
simply shell script keep in the regress directory. For example the ''make
6305
test`` simply executes <B>./all-non-root-tests</B>. The other tests are:
6309
<DT><STRONG>all_non-root-tests</STRONG></DT>
6310
<DD><A NAME="3979"></A>
6311
All non-tape tests not requiring root. This is the standard set of tests,
6312
that in general, backup some data, then restore it, and finally compares the
6313
restored data with the original data.
6317
<DT><STRONG>all-root-tests</STRONG></DT>
6318
<DD><A NAME="3980"></A>
6319
All non-tape tests requiring root permission. These are a relatively small
6320
number of tests that require running as root. The amount of data backed up
6321
can be quite large. For example, one test backs up /usr, another backs up
6322
/etc. One or more of these tests reports an error -- I'll fix it one day.
6326
<DT><STRONG>all-non-root-tape-tests</STRONG></DT>
6327
<DD><A NAME="3981"></A>
6328
All tape test not requiring root. There are currently three tests, all run
6329
without being root, and backup to a tape. The first two tests use one volume,
6330
and the third test requires an autochanger, and uses two volumes. If you
6331
don't have an autochanger, then this script will probably produce an error.
6335
<DT><STRONG>all-tape-and-file-tests</STRONG></DT>
6336
<DD><A NAME="3982"></A>
6337
All tape and file tests not requiring root. This includes just about
6338
everything, and I don't run it very often.
6344
<H3><A NAME="SECTION000152500000000000000"></A>
6353
If you one or more tests fail, the line output will be similar to:
6357
!!!!! concurrent-jobs-test failed!!! !!!!!
6360
If you want to determine why the test failed, you will need to modify the
6361
script so that it prints. Do so by finding the file in <B>regress/tests</B>
6362
that corresponds to the name printed. For example, the script for the above
6363
error message is in: <B>regress/tests/concurrent-jobs-test</B>.
6366
In order to see the output produced by Bacula, you need only change the lines
6367
that start with <B>@output</B> to <B>@tee</B>, then rerun the test by hand. it
6368
is very important to start the test from the <B>regress</B> directory.
6371
To modify the test mentioned above so that you can see the output, change
6372
every occurrence of <B>@output</B> to <B>@tee</B> in the file. In rare cases you
6373
might need to remove the <B>2>&1 >/dev/null</B> from the end of the
6374
<B>bacula</B>, <B>bconsole</B>, or <B>diff</B> lines, but this is rare.
6378
<H2><A NAME="SECTION000153000000000000000"></A>
6382
Writing a Regression Test
6387
Any developer, who implements a major new feature, should write a regression
6388
test that exercises and validates the new feature. Each regression test is a
6389
complete test by itself. It terminates any running Bacula, initializes the
6390
database, starts Bacula, then runs the test by using the console program.
6394
<H3><A NAME="SECTION000153100000000000000"></A>
6398
Running the Tests by Hand
6403
You can run any individual test by hand by cd'ing to the <B>regress</B>
6404
directory and entering:
6408
tests/<test-name>
6412
<H3><A NAME="SECTION000153200000000000000"></A>
6421
The directory structure of the regression tests is:
6425
regress - Makefile, scripts to start tests
6426
|------ scripts - Scripts and conf files
6427
|-------tests - All test scripts are here
6429
|------------------ -- All directories below this point are used
6430
| for testing, but are created from the
6431
| above directories and are removed with
6434
|------ bin - This is the install directory for
6435
| Bacula to be used testing
6436
|------ build - Where the Bacula source build tree is
6437
|------ tmp - Most temp files go here
6438
|------ working - Bacula working directory
6439
|------ weird-files - Weird files used in two of the tests.
6443
<H3><A NAME="SECTION000153300000000000000"></A>
6452
If you want to write a new regression test, it is best to start with one of
6453
the existing test scripts, and modify it to do the new test.
6456
When adding a new test, be extremely careful about adding anything to any of
6457
the daemons' configuration files. The reason is that it may change the prompts
6458
that are sent to the console. For example, adding a Pool means that the
6459
current scripts, which assume that Bacula automatically selects a Pool, will
6460
now be presented with a new prompt, so the test will fail. If you need to
6461
enhance the configuration files, consider making your own versions.
6465
<H1><A NAME="SECTION000160000000000000000"></A>
6466
<A NAME="_ChapterStart"></A>
6468
Bacula MD5 Algorithm
6474
<H2><A NAME="SECTION000161000000000000000"></A>
6478
Command Line Message Digest Utility
6483
This page describes <B>md5</B>, a command line utility usable on either Unix or
6484
MS-DOS/Windows, which generates and verifies message digests (digital
6485
signatures) using the MD5 algorithm. This program can be useful when
6486
developing shell scripts or Perl programs for software installation, file
6487
comparison, and detection of file corruption and tampering.
6491
<H3><A NAME="SECTION000161100000000000000"></A>
6499
<B>md5</B> - generate / check MD5 message digest
6503
<H3><A NAME="SECTION000161200000000000000"></A>
6511
<B>md5</B> [ <B>-c</B><I>signature</I> ] [ <B>-u</B> ] [ <B>-d</B><I>input_text</I>
6512
| <I>infile</I> ] [ <I>outfile</I> ]
6516
<H3><A NAME="SECTION000161300000000000000"></A>
6524
A <I>message digest</I> is a compact digital signature for an arbitrarily long
6525
stream of binary data. An ideal message digest algorithm would never generate
6526
the same signature for two different sets of input, but achieving such
6527
theoretical perfection would require a message digest as long as the input
6528
file. Practical message digest algorithms compromise in favour of a digital
6529
signature of modest size created with an algorithm designed to make
6530
preparation of input text with a given signature computationally infeasible.
6531
Message digest algorithms have much in common with techniques used in
6532
encryption, but to a different end; verification that data have not been
6533
altered since the signature was published.
6536
Many older programs requiring digital signatures employed 16 or 32 bit <I>cyclical redundancy codes</I> (CRC) originally developed to verify correct
6537
transmission in data communication protocols, but these short codes, while
6538
adequate to detect the kind of transmission errors for which they were
6539
intended, are insufficiently secure for applications such as electronic
6540
commerce and verification of security related software distributions.
6543
The most commonly used present-day message digest algorithm is the 128 bit MD5
6544
algorithm, developed by Ron Rivest of the
6546
HREF="http://web.mit.edu/">MIT</A>
6548
HREF="http://www.lcs.mit.edu/">Laboratory for Computer Science</A>
6551
HREF="http://www.rsa.com/">RSA Data Security, Inc.</A>
6552
The algorithm, with a
6553
reference implementation, was published as Internet
6555
HREF="http://www.fourmilab.ch/md5/rfc1321.html">RFC 1321</A>
6557
was placed into the public domain at that time. Message digest algorithms such
6558
as MD5 are not deemed ``encryption technology'' and are not subject to the
6559
export controls some governments impose on other data security products.
6560
(Obviously, the responsibility for obeying the laws in the jurisdiction in
6561
which you reside is entirely your own, but many common Web and Mail utilities
6562
use MD5, and I am unaware of any restrictions on their distribution and use.)
6565
The MD5 algorithm has been implemented in numerous computer languages
6568
HREF="http://www.perl.org/">Perl</A>, and
6570
HREF="http://www.javasoft.com/">Java</A>; if you're writing a program in such a
6571
language, track down a suitable subroutine and incorporate it into your
6572
program. The program described on this page is a <I>command line</I>
6573
implementation of MD5, intended for use in shell scripts and Perl programs (it
6574
is much faster than computing an MD5 signature directly in Perl). This <B>md5</B> program was originally developed as part of a suite of tools intended to
6575
monitor large collections of files (for example, the contents of a Web site)
6576
to detect corruption of files and inadvertent (or perhaps malicious) changes.
6577
That task is now best accomplished with more comprehensive packages such as
6579
HREF="ftp://coast.cs.purdue.edu/pub/COAST/Tripwire/">Tripwire</A>, but the
6580
command line <B>md5</B> component continues to prove useful for verifying
6581
correct delivery and installation of software packages, comparing the contents
6582
of two different systems, and checking for changes in specific files.
6586
<H3><A NAME="SECTION000161400000000000000"></A>
6595
<DT><STRONG><B>-c</B><I>signature</I> </STRONG></DT>
6596
<DD><A NAME="4289"></A>
6597
Computes the signature of the specified <I>infile</I> or the string supplied
6598
by the <B>-d</B> option and compares it against the specified <I>signature</I>.
6599
If the two signatures match, the exit status will be zero, otherwise the exit
6600
status will be 1. No signature is written to <I>outfile</I> or standard
6601
output; only the exit status is set. The signature to be checked must be
6602
specified as 32 hexadecimal digits.
6606
<DT><STRONG><B>-d</B><I>input_text</I> </STRONG></DT>
6607
<DD><A NAME="4296"></A>
6608
A signature is computed for the given <I>input_text</I> (which must be quoted
6609
if it contains white space characters) instead of input from <I>infile</I> or
6610
standard input. If input is specified with the <B>-d</B> option, no <I>infile</I> should be specified.
6614
<DT><STRONG><B>-u</B> </STRONG></DT>
6615
<DD>Print how-to-call information.
6622
<H3><A NAME="SECTION000161500000000000000"></A>
6630
If no <I>infile</I> or <B>-d</B> option is specified or <I>infile</I> is a single
6631
``-'', <B>md5</B> reads from standard input; if no <I>outfile</I> is given, or
6632
<I>outfile</I> is a single ``-'', output is sent to standard output. Input and
6633
output are processed strictly serially; consequently <B>md5</B> may be used in
6638
<H3><A NAME="SECTION000161600000000000000"></A>
6646
The mechanism used to set standard input to binary mode may be specific to
6647
Microsoft C; if you rebuild the DOS/Windows version of the program from source
6648
using another compiler, be sure to verify binary files work properly when read
6649
via redirection or a pipe.
6652
This program has not been tested on a machine on which <TT>int</TT> and/or <TT>long</TT> are longer than 32 bits.
6656
<H2><A NAME="SECTION000162000000000000000"></A>
6661
<A NAME="tex2html10"
6662
HREF="http://www.fourmilab.ch/md5/md5.zip">Download md5.zip</A>
6669
The program is provided as
6670
<A NAME="tex2html11"
6671
HREF="http://www.fourmilab.ch/md5/md5.zip">md5.zip</A>, a
6672
<A NAME="tex2html12"
6673
HREF="http://www.pkware.com/">Zipped</A>
6674
archive containing an ready-to-run
6675
Win32 command-line executable program, <TT>md5.exe</TT> (compiled using Microsoft
6676
Visual C++ 5.0), and in source code form along with a <TT>Makefile</TT> to build
6677
the program under Unix.
6681
<H3><A NAME="SECTION000162100000000000000"></A>
6694
<H3><A NAME="SECTION000162200000000000000"></A>
6703
<B>md5</B> returns status 0 if processing was completed without errors, 1 if
6704
the <B>-c</B> option was specified and the given signature does not match that
6705
of the input, and 2 if processing could not be performed at all due, for
6706
example, to a nonexistent input file.
6710
<H3><A NAME="SECTION000162300000000000000"></A>
6719
This software is in the public domain. Permission to use, copy, modify, and
6720
distribute this software and its documentation for any purpose and without
6721
fee is hereby granted, without any conditions or restrictions. This software
6722
is provided ``as is'' without express or implied warranty.
6728
<H3><A NAME="SECTION000162400000000000000"></A>
6736
The MD5 algorithm was developed by Ron Rivest. The public domain C language
6737
implementation used in this program was written by Colin Plumb in 1993.
6738
<I><A NAME="tex2html13"
6739
HREF="http://www.fourmilab.ch/">by John Walker</A>
6740
January 6th, MIM </I>
6744
<H1><A NAME="SECTION000170000000000000000"></A>
6745
<A NAME="_ChapterStart7"></A><A NAME="4518"></A>
6748
Bacula Memory Management
6754
<H2><A NAME="SECTION000171000000000000000"></A>
6762
This document describes the memory management routines that are used in Bacula
6763
and is meant to be a technical discussion for developers rather than part of
6767
Since Bacula may be called upon to handle filenames of varying and more or
6768
less arbitrary length, special attention needs to be used in the code to
6769
ensure that memory buffers are sufficiently large. There are four
6770
possibilities for memory usage within <B>Bacula</B>. Each will be described in
6776
<LI>Statically allocated memory.
6778
<LI>Dynamically allocated memory using malloc() and free().
6780
<LI>Non-pooled memory.
6789
<H3><A NAME="SECTION000171100000000000000"></A>
6793
Statically Allocated Memory
6798
Statically allocated memory is of the form:
6802
char buffer[MAXSTRING];
6805
The use of this kind of memory is discouraged except when you are 100% sure
6806
that the strings to be used will be of a fixed length. One example of where
6807
this is appropriate is for <B>Bacula</B> resource names, which are currently
6808
limited to 127 characters (MAX_NAME_LENGTH). Although this maximum size may
6809
change, particularly to accommodate Unicode, it will remain a relatively small
6814
<H3><A NAME="SECTION000171200000000000000"></A>
6818
Dynamically Allocated Memory
6823
Dynamically allocated memory is obtained using the standard malloc() routines.
6832
This kind of memory can be released with:
6839
It is recommended to use this kind of memory only when you are sure that you
6840
know the memory size needed and the memory will be used for short periods of
6841
time -- that is it would not be appropriate to use statically allocated
6842
memory. An example might be to obtain a large memory buffer for reading and
6843
writing files. When <B>SmartAlloc</B> is enabled, the memory obtained by
6844
malloc() will automatically be checked for buffer overwrite (overflow) during
6845
the free() call, and all malloc'ed memory that is not released prior to
6846
termination of the program will be reported as Orphaned memory.
6850
<H3><A NAME="SECTION000171300000000000000"></A>
6854
Pooled and Non-pooled Memory
6859
In order to facility the handling of arbitrary length filenames and to
6860
efficiently handle a high volume of dynamic memory usage, we have implemented
6861
routines between the C code and the malloc routines. The first is called
6862
``Pooled'' memory, and is memory, which once allocated and then released, is
6863
not returned to the system memory pool, but rather retained in a Bacula memory
6864
pool. The next request to acquire pooled memory will return any free memory
6865
block. In addition, each memory block has its current size associated with the
6866
block allowing for easy checking if the buffer is of sufficient size. This
6867
kind of memory would normally be used in high volume situations (lots of
6868
malloc()s and free()s) where the buffer length may have to frequently change
6869
to adapt to varying filename lengths.
6872
The non-pooled memory is handled by routines similar to those used for pooled
6873
memory, allowing for easy size checking. However, non-pooled memory is
6874
returned to the system rather than being saved in the Bacula pool. This kind
6875
of memory would normally be used in low volume situations (few malloc()s and
6876
free()s), but where the size of the buffer might have to be adjusted
6881
<H4><A NAME="SECTION000171310000000000000">
6882
Types of Memory Pool:</A>
6886
Currently there are three memory pool types:
6891
<LI>PM_NOPOOL -- non-pooled memory.
6893
<LI>PM_FNAME -- a filename pool.
6895
<LI>PM_MESSAGE -- a message buffer pool.
6897
<LI>PM_EMSG -- error message buffer pool.
6904
<H4><A NAME="SECTION000171320000000000000">
6909
To get memory, one uses:
6913
void *get_pool_memory(pool);
6916
where <B>pool</B> is one of the above mentioned pool names. The size of the
6917
memory returned will be determined by the system to be most appropriate for
6921
If you wish non-pooled memory, you may alternatively call:
6925
void *get_memory(size_t size);
6928
The buffer length will be set to the size specified, and it will be assigned
6929
to the PM_NOPOOL pool (no pooling).
6933
<H4><A NAME="SECTION000171330000000000000">
6934
Releasing Memory:</A>
6938
To free memory acquired by either of the above two calls, use:
6942
void free_pool_memory(void *buffer);
6945
where buffer is the memory buffer returned when the memory was acquired. If
6946
the memory was originally allocated as type PM_NOPOOL, it will be released to
6947
the system, otherwise, it will be placed on the appropriate Bacula memory pool
6948
free chain to be used in a subsequent call for memory from that pool.
6952
<H4><A NAME="SECTION000171340000000000000">
6953
Determining the Memory Size:</A>
6957
To determine the memory buffer size, use:
6961
size_t sizeof_pool_memory(void *buffer);
6965
<H4><A NAME="SECTION000171350000000000000">
6966
Resizing Pool Memory:</A>
6970
To resize pool memory, use:
6974
void *realloc_pool_memory(void *buffer);
6977
The buffer will be reallocated, and the contents of the original buffer will
6978
be preserved, but the address of the buffer may change.
6982
<H4><A NAME="SECTION000171360000000000000">
6983
Automatic Size Adjustment:</A>
6987
To have the system check and if necessary adjust the size of your pooled
6992
void *check_pool_memory_size(void *buffer, size_t new-size);
6995
where <B>new-size</B> is the buffer length needed. Note, if the buffer is
6996
already equal to or larger than <B>new-size</B> no buffer size change will
6997
occur. However, if a buffer size change is needed, the original contents of
6998
the buffer will be preserved, but the buffer address may change. Many of the
6999
low level Bacula subroutines expect to be passed a pool memory buffer and use
7000
this call to ensure the buffer they use is sufficiently large.
7004
<H4><A NAME="SECTION000171370000000000000">
7005
Releasing All Pooled Memory:</A>
7009
In order to avoid orphaned buffer error messages when terminating the program,
7014
void close_memory_pool();
7017
to free all unused memory retained in the Bacula memory pool. Note, any memory
7018
not returned to the pool via free_pool_memory() will not be released by this
7023
<H4><A NAME="SECTION000171380000000000000">
7024
Pooled Memory Statistics:</A>
7028
For debugging purposes and performance tuning, the following call will print
7029
the current memory pool statistics:
7033
void print_memory_pool_stats();
7036
an example output is:
7040
Pool Maxsize Maxused Inuse
7047
<H1><A NAME="SECTION000180000000000000000"></A>
7048
<A NAME="_ChapterStart5"></A><A NAME="4754"></A>
7051
TCP/IP Network Protocol
7057
<H2><A NAME="SECTION000181000000000000000"></A>
7065
This document describes the TCP/IP protocol used by Bacula to communicate
7066
between the various daemons and services. The definitive definition of the
7067
protocol can be found in src/lib/bsock.h, src/lib/bnet.c and
7068
src/lib/bnet_server.c.
7071
Bacula's network protocol is basically a ``packet oriented'' protocol built on
7072
a standard TCP/IP streams. At the lowest level all packet transfers are done
7073
with read() and write() requests on system sockets. Pipes are not used as they
7074
are considered unreliable for large serial data transfers between various
7078
Using the routines described below (bnet_open, bnet_write, bnet_recv, and
7079
bnet_close) guarantees that the number of bytes you write into the socket
7080
will be received as a single record on the other end regardless of how many
7081
low level write() and read() calls are needed. All data transferred are
7082
considered to be binary data.
7086
<H2><A NAME="SECTION000182000000000000000"></A>
7095
These bnet routines work fine in a threaded environment. However, they assume
7096
that there is only one reader or writer on the socket at any time. It is
7097
highly recommended that only a single thread access any BSOCK packet. The
7098
exception to this rule is when the socket is first opened and it is waiting
7099
for a job to start. The wait in the Storage daemon is done in one thread and
7100
then passed to another thread for subsequent handling.
7103
If you envision having two threads using the same BSOCK, think twice, then you
7104
must implement some locking mechanism. However, it probably would not be
7105
appropriate to put locks inside the bnet subroutines for efficiency reasons.
7109
<H2><A NAME="SECTION000183000000000000000"></A>
7117
To establish a connection to a server, use the subroutine:
7120
BSOCK *bnet_open(void *jcr, char *host, char *service, int port, int *fatal)
7121
bnet_open(), if successful, returns the Bacula sock descriptor pointer to be
7122
used in subsequent bnet_send() and bnet_read() requests. If not successful,
7123
bnet_open() returns a NULL. If fatal is set on return, it means that a fatal
7124
error occurred and that you should not repeatedly call bnet_open(). Any error
7125
message will generally be sent to the JCR.
7129
<H2><A NAME="SECTION000184000000000000000"></A>
7137
To send a packet, one uses the subroutine:
7140
int bnet_send(BSOCK *sock) This routine is equivalent to a write() except
7141
that it handles the low level details. The data to be sent is expected to be
7142
in sock->msg and be sock->msglen bytes. To send a packet, bnet_send()
7143
first writes four bytes in network byte order than indicate the size of the
7144
following data packet. It returns:
7148
Returns 0 on failure
7149
Returns 1 on success
7152
In the case of a failure, an error message will be sent to the JCR contained
7153
within the bsock packet.
7157
<H2><A NAME="SECTION000185000000000000000"></A>
7168
int bnet_fsend(BSOCK *sock, char *format, ...) and it allows you to send a
7169
formatted messages somewhat like fprintf(). The return status is the same as
7174
<H2><A NAME="SECTION000186000000000000000"></A>
7178
Additional Error information
7183
Fro additional error information, you can call <B>is_bnet_error(BSOCK
7184
*bsock)</B> which will return 0 if there is no error or non-zero if there is an
7185
error on the last transmission. The <B>is_bnet_stop(BSOCK *bsock)</B>
7186
function will return 0 if there no errors and you can continue sending. It
7187
will return non-zero if there are errors or the line is closed (no more
7188
transmissions should be sent).
7192
<H2><A NAME="SECTION000187000000000000000"></A>
7200
To read a packet, one uses the subroutine:
7203
int bnet_recv(BSOCK *sock) This routine is similar to a read() except that it
7204
handles the low level details. bnet_read() first reads packet length that
7205
follows as four bytes in network byte order. The data is read into
7206
sock->msg and is sock->msglen bytes. If the sock->msg is not large
7207
enough, bnet_recv() realloc() the buffer. It will return an error (-2) if
7208
maxbytes is less than the record size sent. It returns:
7212
* Returns number of bytes read
7213
* Returns 0 on end of file
7214
* Returns -1 on hard end of file (i.e. network connection close)
7215
* Returns -2 on error
7218
It should be noted that bnet_recv() is a blocking read.
7222
<H2><A NAME="SECTION000188000000000000000"></A>
7230
To send a ``signal'' from one daemon to another, one uses the subroutine:
7233
int bnet_sig(BSOCK *sock, SIGNAL) where SIGNAL is one of the following:
7238
<LI>BNET_EOF - deprecated use BNET_EOD
7240
<LI>BNET_EOD - End of data stream, new data may follow
7242
<LI>BNET_EOD_POLL - End of data and poll all in one
7244
<LI>BNET_STATUS - Request full status
7246
<LI>BNET_TERMINATE - Conversation terminated, doing close()
7248
<LI>BNET_POLL - Poll request, I'm hanging on a read
7250
<LI>BNET_HEARTBEAT - Heartbeat Response requested
7252
<LI>BNET_HB_RESPONSE - Only response permitted to HB
7254
<LI>BNET_PROMPT - Prompt for UA
7261
<H2><A NAME="SECTION000189000000000000000"></A>
7269
Returns a formated string corresponding to the last error that occurred.
7273
<H2><A NAME="SECTION0001810000000000000000"></A>
7281
The connection with the server remains open until closed by the subroutine:
7284
void bnet_close(BSOCK *sock)
7288
<H2><A NAME="SECTION0001811000000000000000"></A>
7297
The bnet_open() and bnet_close() routines described above are used on the
7298
client side to establish a connection and terminate a connection with the
7299
server. To become a server (i.e. wait for a connection from a client), use the
7300
routine <B>bnet_thread_server</B>. The calling sequence is a bit complicated,
7301
please refer to the code in bnet_server.c and the code at the beginning of
7302
each daemon as examples of how to call it.
7306
<H2><A NAME="SECTION0001812000000000000000"></A>
7310
Higher Level Conventions
7315
Within Bacula, we have established the convention that any time a single
7316
record is passed, it is sent with bnet_send() and read with bnet_recv().
7317
Thus the normal exchange between the server (S) and the client (C) are:
7321
S: wait for connection C: attempt connection
7322
S: accept connection C: bnet_send() send request
7323
S: bnet_recv() wait for request
7325
S: bnet_send() send ack C: bnet_recv() wait for ack
7328
Thus a single command is sent, acted upon by the server, and then
7332
In certain cases, such as the transfer of the data for a file, all the
7333
information or data cannot be sent in a single packet. In this case, the
7334
convention is that the client will send a command to the server, who knows
7335
that more than one packet will be returned. In this case, the server will
7340
while ((n=bnet_recv(bsock)) > 0) {
7347
The client will perform the following:
7354
bnet_sig(bsock, BNET_EOD);
7357
Thus the client will send multiple packets and signal to the server when all
7358
the packets have been sent by sending a zero length record.
7363
WIDTH="442" HEIGHT="67" ALIGN="BOTTOM" BORDER="0"
7365
ALT="\includegraphics{./smartall.eps}">
7369
<H1><A NAME="SECTION000190000000000000000"></A>
7370
<A NAME="_ChapterStart4"></A><A NAME="4967"></A>
7373
Smart Memory Allocation With Orphaned Buffer Detection
7378
Few things are as embarrassing as a program that leaks, yet few errors are so
7379
easy to commit or as difficult to track down in a large, complicated program
7380
as failure to release allocated memory. SMARTALLOC replaces the standard C
7381
library memory allocation functions with versions which keep track of buffer
7382
allocations and releases and report all orphaned buffers at the end of program
7383
execution. By including this package in your program during development and
7384
testing, you can identify code that loses buffers right when it's added and
7385
most easily fixed, rather than as part of a crisis debugging push when the
7386
problem is identified much later in the testing cycle (or even worse, when the
7387
code is in the hands of a customer). When program testing is complete, simply
7388
recompiling with different flags removes SMARTALLOC from your program,
7389
permitting it to run without speed or storage penalties.
7392
In addition to detecting orphaned buffers, SMARTALLOC also helps to find other
7393
common problems in management of dynamic storage including storing before the
7394
start or beyond the end of an allocated buffer, referencing data through a
7395
pointer to a previously released buffer, attempting to release a buffer twice
7396
or releasing storage not obtained from the allocator, and assuming the initial
7397
contents of storage allocated by functions that do not guarantee a known
7398
value. SMARTALLOC's checking does not usually add a large amount of overhead
7399
to a program (except for programs which use <TT>realloc()</TT> extensively; see
7400
below). SMARTALLOC focuses on proper storage management rather than internal
7401
consistency of the heap as checked by the malloc_debug facility available on
7402
some systems. SMARTALLOC does not conflict with malloc_debug and both may be
7403
used together, if you wish. SMARTALLOC makes no assumptions regarding the
7404
internal structure of the heap and thus should be compatible with any C
7405
language implementation of the standard memory allocation functions.
7409
<H3><A NAME="SECTION000190100000000000000"></A>
7413
Installing SMARTALLOC
7418
SMARTALLOC is provided as a Zipped archive,
7419
<A NAME="tex2html14"
7420
HREF="http://www.fourmilab.ch/smartall/smartall.zip">smartall.zip</A>; see the
7421
download instructions below.
7424
To install SMARTALLOC in your program, simply add the statement:
7427
to every C program file which calls any of the memory allocation functions
7428
(<TT>malloc</TT>, <TT>calloc</TT>, <TT>free</TT>, etc.). SMARTALLOC must be used for
7429
all memory allocation with a program, so include file for your entire program,
7430
if you have such a thing. Next, define the symbol SMARTALLOC in the
7431
compilation before the inclusion of smartall.h. I usually do this by having my
7432
Makefile add the ``<TT>-DSMARTALLOC</TT>'' option to the C compiler for
7433
non-production builds. You can define the symbol manually, if you prefer, by
7434
adding the statement:
7437
<TT>#define SMARTALLOC</TT>
7440
At the point where your program is all done and ready to relinquish control to
7441
the operating system, add the call:
7444
<TT> sm_dump(</TT><I>datadump</I><TT>);</TT>
7447
where <I>datadump</I> specifies whether the contents of orphaned buffers are to
7448
be dumped in addition printing to their size and place of allocation. The data
7449
are dumped only if <I>datadump</I> is nonzero, so most programs will normally
7450
use ``<TT>sm_dump(0);</TT>''. If a mysterious orphaned buffer appears that can't
7451
be identified from the information this prints about it, replace the statement
7452
with ``<TT>sm_dump(1)</TT>;''. Usually the dump of the buffer's data will
7453
furnish the additional clues you need to excavate and extirpate the elusive
7454
error that left the buffer allocated.
7457
Finally, add the files ``smartall.h'' and ``smartall.c'' from this release to
7458
your source directory, make dependencies, and linker input. You needn't make
7459
inclusion of smartall.c in your link optional; if compiled with SMARTALLOC not
7460
defined it generates no code, so you may always include it knowing it will
7461
waste no storage in production builds. Now when you run your program, if it
7462
leaves any buffers around when it's done, each will be reported by <TT>sm_dump()</TT> on stderr as follows:
7466
Orphaned buffer: 120 bytes allocated at line 50 of gutshot.c
7470
<H3><A NAME="SECTION000190200000000000000"></A>
7474
Squelching a SMARTALLOC
7479
Usually, when you first install SMARTALLOC in an existing program you'll find
7480
it nattering about lots of orphaned buffers. Some of these turn out to be
7481
legitimate errors, but some are storage allocated during program
7482
initialisation that, while dynamically allocated, is logically static storage
7483
not intended to be released. Of course, you can get rid of the complaints
7484
about these buffers by adding code to release them, but by doing so you're
7485
adding unnecessary complexity and code size to your program just to silence
7486
the nattering of a SMARTALLOC, so an escape hatch is provided to eliminate the
7487
need to release these buffers.
7490
Normally all storage allocated with the functions <TT>malloc()</TT>, <TT>calloc()</TT>, and <TT>realloc()</TT> is monitored by SMARTALLOC. If you make the
7498
you declare that subsequent storage allocated by <TT>malloc()</TT>, <TT>calloc()</TT>, and <TT>realloc()</TT> should not be considered orphaned if found to
7499
be allocated when <TT>sm_dump()</TT> is called. I use a call on ``<TT>sm_static(1);</TT>'' before I allocate things like program configuration tables
7500
so I don't have to add code to release them at end of program time. After
7501
allocating unmonitored data this way, be sure to add a call to:
7508
to resume normal monitoring of buffer allocations. Buffers allocated while
7509
<TT>sm_static(1</TT>) is in effect are not checked for having been orphaned but
7510
all the other safeguards provided by SMARTALLOC remain in effect. You may
7511
release such buffers, if you like; but you don't have to.
7515
<H3><A NAME="SECTION000190300000000000000"></A>
7519
Living with Libraries
7524
Some library functions for which source code is unavailable may gratuitously
7525
allocate and return buffers that contain their results, or require you to pass
7526
them buffers which they subsequently release. If you have source code for the
7527
library, by far the best approach is to simply install SMARTALLOC in it,
7528
particularly since this kind of ill-structured dynamic storage management is
7529
the source of so many storage leaks. Without source code, however, there's no
7530
option but to provide a way to bypass SMARTALLOC for the buffers the library
7531
allocates and/or releases with the standard system functions.
7534
For each function <I>xxx</I> redefined by SMARTALLOC, a corresponding routine
7535
named ``<TT>actually</TT><I>xxx</I>'' is furnished which provides direct access to
7536
the underlying system function, as follows:
7540
<BLOCKQUOTE><TABLE CELLPADDING=3>
7541
<TR><TD ALIGN="LEFT" COLSPAN=1><B>Standard function </B></TD>
7542
<TD ALIGN="LEFT" COLSPAN=1><B>Direct
7543
access function </B></TD>
7545
<TR><TD ALIGN="LEFT"><TT>malloc(</TT><I>size</I><TT>)</TT></TD>
7546
<TD ALIGN="LEFT"><TT>actuallymalloc(</TT><I>size</I><TT>)</TT></TD>
7548
<TR><TD ALIGN="LEFT"><TT>calloc(</TT><I>nelem</I><TT>,</TT> <I>elsize</I><TT>)</TT></TD>
7549
<TD ALIGN="LEFT"><TT>actuallycalloc(</TT><I>nelem</I>, <I>elsize</I><TT>)</TT></TD>
7551
<TR><TD ALIGN="LEFT"><TT>realloc(</TT><I>ptr</I><TT>,</TT> <I>size</I><TT>)</TT></TD>
7552
<TD ALIGN="LEFT"><TT>actuallyrealloc(</TT><I>ptr</I>, <I>size</I><TT>)</TT></TD>
7554
<TR><TD ALIGN="LEFT"><TT>free(</TT><I>ptr</I><TT>)</TT></TD>
7555
<TD ALIGN="LEFT"><TT>actuallyfree(</TT><I>ptr</I><TT>)</TT>
7564
For example, suppose there exists a system library function named ``<TT>getimage()</TT>'' which reads a raster image file and returns the address of a
7565
buffer containing it. Since the library routine allocates the image directly
7566
with <TT>malloc()</TT>, you can't use SMARTALLOC's <TT>free()</TT>, as that call
7567
expects information placed in the buffer by SMARTALLOC's special version of
7568
<TT>malloc()</TT>, and hence would report an error. To release the buffer you
7569
should call <TT>actuallyfree()</TT>, as in this code fragment:
7573
struct image *ibuf = getimage("ratpack.img");
7574
display_on_screen(ibuf);
7578
Conversely, suppose we are to call a library function, ``<TT>putimage()</TT>'',
7579
which writes an image buffer into a file and then releases the buffer with
7580
<TT>free()</TT>. Since the system <TT>free()</TT> is being called, we can't pass a
7581
buffer allocated by SMARTALLOC's allocation routines, as it contains special
7582
information that the system <TT>free()</TT> doesn't expect to be there. The
7583
following code uses <TT>actuallymalloc()</TT> to obtain the buffer passed to such
7588
struct image *obuf =
7589
(struct image *) actuallymalloc(sizeof(struct image));
7590
dump_screen_to_image(obuf);
7591
putimage("scrdump.img", obuf); /* putimage() releases obuf */
7594
It's unlikely you'll need any of the ``actually'' calls except under very odd
7595
circumstances (in four products and three years, I've only needed them once),
7596
but they're there for the rare occasions that demand them. Don't use them to
7597
subvert the error checking of SMARTALLOC; if you want to disable orphaned
7598
buffer detection, use the <TT>sm_static(1)</TT> mechanism described above. That
7599
way you don't forfeit all the other advantages of SMARTALLOC as you do when
7600
using <TT>actuallymalloc()</TT> and <TT>actuallyfree()</TT>.
7604
<H3><A NAME="SECTION000190400000000000000"></A>
7613
When you include ``smartall.h'' and define SMARTALLOC, the following standard
7614
system library functions are redefined with the #define mechanism to call
7615
corresponding functions within smartall.c instead. (For details of the
7616
redefinitions, please refer to smartall.h.)
7620
void *malloc(size_t size)
7621
void *calloc(size_t nelem, size_t elsize)
7622
void *realloc(void *ptr, size_t size)
7623
void free(void *ptr)
7624
void cfree(void *ptr)
7627
<TT>cfree()</TT> is a historical artifact identical to <TT>free()</TT>.
7630
In addition to allocating storage in the same way as the standard library
7631
functions, the SMARTALLOC versions expand the buffers they allocate to include
7632
information that identifies where each buffer was allocated and to chain all
7633
allocated buffers together. When a buffer is released, it is removed from the
7634
allocated buffer chain. A call on <TT>sm_dump()</TT> is able, by scanning the
7635
chain of allocated buffers, to find all orphaned buffers. Buffers allocated
7636
while <TT>sm_static(1)</TT> is in effect are specially flagged so that, despite
7637
appearing on the allocated buffer chain, <TT>sm_dump()</TT> will not deem them
7641
When a buffer is allocated by <TT>malloc()</TT> or expanded with <TT>realloc()</TT>,
7642
all bytes of newly allocated storage are set to the hexadecimal value 0x55
7643
(alternating one and zero bits). Note that for <TT>realloc()</TT> this applies
7644
only to the bytes added at the end of buffer; the original contents of the
7645
buffer are not modified. Initializing allocated storage to a distinctive
7646
nonzero pattern is intended to catch code that erroneously assumes newly
7647
allocated buffers are cleared to zero; in fact their contents are random. The
7648
<TT>calloc()</TT> function, defined as returning a buffer cleared to zero,
7649
continues to zero its buffers under SMARTALLOC.
7652
Buffers obtained with the SMARTALLOC functions contain a special sentinel byte
7653
at the end of the user data area. This byte is set to a special key value
7654
based upon the buffer's memory address. When the buffer is released, the key
7655
is tested and if it has been overwritten an assertion in the <TT>free</TT>
7656
function will fail. This catches incorrect program code that stores beyond the
7657
storage allocated for the buffer. At <TT>free()</TT> time the queue links are
7658
also validated and an assertion failure will occur if the program has
7659
destroyed them by storing before the start of the allocated storage.
7662
In addition, when a buffer is released with <TT>free()</TT>, its contents are
7663
immediately destroyed by overwriting them with the hexadecimal pattern 0xAA
7664
(alternating bits, the one's complement of the initial value pattern). This
7665
will usually trip up code that keeps a pointer to a buffer that's been freed
7666
and later attempts to reference data within the released buffer. Incredibly,
7667
this is <I>legal</I> in the standard Unix memory allocation package, which
7668
permits programs to free() buffers, then raise them from the grave with <TT>realloc()</TT>. Such program ``logic'' should be fixed, not accommodated, and
7669
SMARTALLOC brooks no such Lazarus buffer`` nonsense.
7672
Some C libraries allow a zero size argument in calls to <TT>malloc()</TT>. Since
7673
this is far more likely to indicate a program error than a defensible
7674
programming stratagem, SMARTALLOC disallows it with an assertion.
7677
When the standard library <TT>realloc()</TT> function is called to expand a
7678
buffer, it attempts to expand the buffer in place if possible, moving it only
7679
if necessary. Because SMARTALLOC must place its own private storage in the
7680
buffer and also to aid in error detection, its version of <TT>realloc()</TT>
7681
always moves and copies the buffer except in the trivial case where the size
7682
of the buffer is not being changed. By forcing the buffer to move on every
7683
call and destroying the contents of the old buffer when it is released,
7684
SMARTALLOC traps programs which keep pointers into a buffer across a call on
7685
<TT>realloc()</TT> which may move it. This strategy may prove very costly to
7686
programs which make extensive use of <TT>realloc()</TT>. If this proves to be a
7687
problem, such programs may wish to use <TT>actuallymalloc()</TT>, <TT>actuallyrealloc()</TT>, and <TT>actuallyfree()</TT> for such frequently-adjusted
7688
buffers, trading error detection for performance. Although not specified in
7689
the System V Interface Definition, many C library implementations of <TT>realloc()</TT> permit an old buffer argument of NULL, causing <TT>realloc()</TT> to
7690
allocate a new buffer. The SMARTALLOC version permits this.
7694
<H3><A NAME="SECTION000190500000000000000"></A>
7698
When SMARTALLOC is Disabled
7703
When SMARTALLOC is disabled by compiling a program with the symbol SMARTALLOC
7704
not defined, calls on the functions otherwise redefined by SMARTALLOC go
7705
directly to the system functions. In addition, compile-time definitions
7706
translate calls on the ''<TT>actually</TT>...<TT>()</TT>`` functions into the
7707
corresponding library calls; ''<TT>actuallymalloc(100)</TT>``, for example,
7708
compiles into ''<TT>malloc(100)</TT>``. The two special SMARTALLOC functions,
7709
<TT>sm_dump()</TT> and <TT>sm_static()</TT>, are defined to generate no code
7710
(hence the null statement). Finally, if SMARTALLOC is not defined, compilation
7711
of the file smartall.c generates no code or data at all, effectively removing
7712
it from the program even if named in the link instructions.
7715
Thus, except for unusual circumstances, a program that works with SMARTALLOC
7716
defined for testing should require no changes when built without it for
7721
<H3><A NAME="SECTION000190600000000000000"></A>
7725
The <TT>alloc()</TT> Function
7730
Many programs I've worked on use very few direct calls to <TT>malloc()</TT>,
7731
using the identically declared <TT>alloc()</TT> function instead. Alloc detects
7732
out-of-memory conditions and aborts, removing the need for error checking on
7733
every call of <TT>malloc()</TT> (and the temptation to skip checking for
7737
As a convenience, SMARTALLOC supplies a compatible version of <TT>alloc()</TT> in
7738
the file alloc.c, with its definition in the file alloc.h. This version of
7739
<TT>alloc()</TT> is sensitive to the definition of SMARTALLOC and cooperates with
7740
SMARTALLOC's orphaned buffer detection. In addition, when SMARTALLOC is
7741
defined and <TT>alloc()</TT> detects an out of memory condition, it takes
7742
advantage of the SMARTALLOC diagnostic information to identify the file and
7743
line number of the call on <TT>alloc()</TT> that failed.
7747
<H3><A NAME="SECTION000190700000000000000"></A>
7751
Overlays and Underhandedness
7756
String constants in the C language are considered to be static arrays of
7757
characters accessed through a pointer constant. The arrays are potentially
7758
writable even though their pointer is a constant. SMARTALLOC uses the
7759
compile-time definition <TT>./smartall.wml</TT> to obtain the name of the file in
7760
which a call on buffer allocation was performed. Rather than reserve space in
7761
a buffer to save this information, SMARTALLOC simply stores the pointer to the
7762
compiled-in text of the file name. This works fine as long as the program does
7763
not overlay its data among modules. If data are overlayed, the area of memory
7764
which contained the file name at the time it was saved in the buffer may
7765
contain something else entirely when <TT>sm_dump()</TT> gets around to using the
7766
pointer to edit the file name which allocated the buffer.
7769
If you want to use SMARTALLOC in a program with overlayed data, you'll have to
7770
modify smartall.c to either copy the file name to a fixed-length field added
7771
to the <TT>abufhead</TT> structure, or else allocate storage with <TT>malloc()</TT>,
7772
copy the file name there, and set the <TT>abfname</TT> pointer to that buffer,
7773
then remember to release the buffer in <TT>sm_free</TT>. Either of these
7774
approaches are wasteful of storage and time, and should be considered only if
7775
there is no alternative. Since most initial debugging is done in non-overlayed
7776
environments, the restrictions on SMARTALLOC with data overlaying may never
7777
prove a problem. Note that conventional overlaying of code, by far the most
7778
common form of overlaying, poses no problems for SMARTALLOC; you need only be
7779
concerned if you're using exotic tools for data overlaying on MS-DOS or other
7780
address-space-challenged systems.
7783
Since a C language ''constant`` string can actually be written into, most C
7784
compilers generate a unique copy of each string used in a module, even if the
7785
same constant string appears many times. In modules that contain many calls on
7786
allocation functions, this results in substantial wasted storage for the
7787
strings that identify the file name. If your compiler permits optimization of
7788
multiple occurrences of constant strings, enabling this mode will eliminate
7789
the overhead for these strings. Of course, it's up to you to make sure
7790
choosing this compiler mode won't wreak havoc on some other part of your
7795
<H3><A NAME="SECTION000190800000000000000"></A>
7799
Test and Demonstration Program
7804
A test and demonstration program, smtest.c, is supplied with SMARTALLOC. You
7805
can build this program with the Makefile included. Please refer to the
7806
comments in smtest.c and the Makefile for information on this program. If
7807
you're attempting to use SMARTALLOC on a new machine or with a new compiler or
7808
operating system, it's a wise first step to check it out with smtest first.
7812
<H3><A NAME="SECTION000190900000000000000"></A>
7816
Invitation to the Hack
7821
SMARTALLOC is not intended to be a panacea for storage management problems,
7822
nor is it universally applicable or effective; it's another weapon in the
7823
arsenal of the defensive professional programmer attempting to create reliable
7824
products. It represents the current state of evolution of expedient debug code
7825
which has been used in several commercial software products which have,
7826
collectively, sold more than third of a million copies in the retail market,
7827
and can be expected to continue to develop through time as it is applied to
7828
ever more demanding projects.
7831
The version of SMARTALLOC here has been tested on a Sun SPARCStation, Silicon
7832
Graphics Indigo2, and on MS-DOS using both Borland and Microsoft C. Moving
7833
from compiler to compiler requires the usual small changes to resolve disputes
7834
about prototyping of functions, whether the type returned by buffer allocation
7835
is <TT>char *</TT> or <TT>void *</TT>, and so forth, but following those changes
7836
it works in a variety of environments. I hope you'll find SMARTALLOC as useful
7837
for your projects as I've found it in mine.
7841
<H2><A NAME="SECTION000191000000000000000"></A>
7847
<A NAME="tex2html16"
7848
HREF="http://www.fourmilab.ch/smartall/smartall.zip">Download smartall.zip</A>
7854
SMARTALLOC is provided as
7855
<A NAME="tex2html17"
7856
HREF="http://www.fourmilab.ch/smartall/smartall.zip">smartall.zip</A>, a
7857
<A NAME="tex2html18"
7858
HREF="http://www.pkware.com/">Zipped</A>
7859
archive containing source code,
7860
documentation, and a <TT>Makefile</TT> to build the software under Unix.
7864
<H3><A NAME="SECTION000191100000000000000"></A>
7873
SMARTALLOC is in the public domain. Permission to use, copy, modify, and
7874
distribute this software and its documentation for any purpose and without fee
7875
is hereby granted, without any conditions or restrictions. This software is
7876
provided ''as is`` without express or implied warranty.
7881
<I><A NAME="tex2html19"
7882
HREF="http://www.fourmilab.ch">by John Walker</A>
7883
October 30th, 1998 </I>
7899
<H1><A NAME="SECTION000200000000000000000">
7900
GNU Free Documentation License</A>
7907
<DIV ALIGN="CENTER">
7910
<DIV ALIGN="CENTER">Version 1.2, November 2002
7913
<DIV ALIGN="CENTER">Copyright ©2000,2001,2002 Free Software Foundation, Inc.
7916
<DIV ALIGN="CENTER"></DIV>
7919
<DIV ALIGN="CENTER"></DIV>
7921
<DIV ALIGN="CENTER">51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7924
<DIV ALIGN="CENTER"></DIV>
7927
<DIV ALIGN="CENTER"></DIV>
7929
<DIV ALIGN="CENTER">Everyone is permitted to copy and distribute verbatim copies
7930
of this license document, but changing it is not allowed.
7935
<DIV ALIGN="CENTER">
7936
<B><FONT SIZE="+1">Preamble</FONT></B>
7941
The purpose of this License is to make a manual, textbook, or other
7942
functional and useful document "free" in the sense of freedom: to
7943
assure everyone the effective freedom to copy and redistribute it,
7944
with or without modifying it, either commercially or noncommercially.
7945
Secondarily, this License preserves for the author and publisher a way
7946
to get credit for their work, while not being considered responsible
7947
for modifications made by others.
7950
This License is a kind of "copyleft", which means that derivative
7951
works of the document must themselves be free in the same sense. It
7952
complements the GNU General Public License, which is a copyleft
7953
license designed for free software.
7956
We have designed this License in order to use it for manuals for free
7957
software, because free software needs free documentation: a free
7958
program should come with manuals providing the same freedoms that the
7959
software does. But this License is not limited to software manuals;
7960
it can be used for any textual work, regardless of subject matter or
7961
whether it is published as a printed book. We recommend this License
7962
principally for works whose purpose is instruction or reference.
7965
<DIV ALIGN="CENTER">
7966
<FONT SIZE="+2"><B>1. APPLICABILITY AND DEFINITIONS</B></FONT>
7972
This License applies to any manual or other work, in any medium, that
7973
contains a notice placed by the copyright holder saying it can be
7974
distributed under the terms of this License. Such a notice grants a
7975
world-wide, royalty-free license, unlimited in duration, to use that
7976
work under the conditions stated herein. The <B>"Document"</B>, below,
7977
refers to any such manual or work. Any member of the public is a
7978
licensee, and is addressed as <B>"you"</B>. You accept the license if you
7979
copy, modify or distribute the work in a way requiring permission
7980
under copyright law.
7983
A <B>"Modified Version"</B> of the Document means any work containing the
7984
Document or a portion of it, either copied verbatim, or with
7985
modifications and/or translated into another language.
7988
A <B>"Secondary Section"</B> is a named appendix or a front-matter section of
7989
the Document that deals exclusively with the relationship of the
7990
publishers or authors of the Document to the Document's overall subject
7991
(or to related matters) and contains nothing that could fall directly
7992
within that overall subject. (Thus, if the Document is in part a
7993
textbook of mathematics, a Secondary Section may not explain any
7994
mathematics.) The relationship could be a matter of historical
7995
connection with the subject or with related matters, or of legal,
7996
commercial, philosophical, ethical or political position regarding
8000
The <B>"Invariant Sections"</B> are certain Secondary Sections whose titles
8001
are designated, as being those of Invariant Sections, in the notice
8002
that says that the Document is released under this License. If a
8003
section does not fit the above definition of Secondary then it is not
8004
allowed to be designated as Invariant. The Document may contain zero
8005
Invariant Sections. If the Document does not identify any Invariant
8006
Sections then there are none.
8009
The <B>"Cover Texts"</B> are certain short passages of text that are listed,
8010
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
8011
the Document is released under this License. A Front-Cover Text may
8012
be at most 5 words, and a Back-Cover Text may be at most 25 words.
8015
A <B>"Transparent"</B> copy of the Document means a machine-readable copy,
8016
represented in a format whose specification is available to the
8017
general public, that is suitable for revising the document
8018
straightforwardly with generic text editors or (for images composed of
8019
pixels) generic paint programs or (for drawings) some widely available
8020
drawing editor, and that is suitable for input to text formatters or
8021
for automatic translation to a variety of formats suitable for input
8022
to text formatters. A copy made in an otherwise Transparent file
8023
format whose markup, or absence of markup, has been arranged to thwart
8024
or discourage subsequent modification by readers is not Transparent.
8025
An image format is not Transparent if used for any substantial amount
8026
of text. A copy that is not "Transparent" is called <B>"Opaque"</B>.
8029
Examples of suitable formats for Transparent copies include plain
8030
ASCII without markup, Texinfo input format, LaTeX input format, SGML
8031
or XML using a publicly available DTD, and standard-conforming simple
8032
HTML, PostScript or PDF designed for human modification. Examples of
8033
transparent image formats include PNG, XCF and JPG. Opaque formats
8034
include proprietary formats that can be read and edited only by
8035
proprietary word processors, SGML or XML for which the DTD and/or
8036
processing tools are not generally available, and the
8037
machine-generated HTML, PostScript or PDF produced by some word
8038
processors for output purposes only.
8041
The <B>"Title Page"</B> means, for a printed book, the title page itself,
8042
plus such following pages as are needed to hold, legibly, the material
8043
this License requires to appear in the title page. For works in
8044
formats which do not have any title page as such, "Title Page" means
8045
the text near the most prominent appearance of the work's title,
8046
preceding the beginning of the body of the text.
8049
A section <B>"Entitled XYZ"</B> means a named subunit of the Document whose
8050
title either is precisely XYZ or contains XYZ in parentheses following
8051
text that translates XYZ in another language. (Here XYZ stands for a
8052
specific section name mentioned below, such as <B>"Acknowledgements"</B>,
8053
<B>"Dedications"</B>, <B>"Endorsements"</B>, or <B>"History"</B>.)
8054
To <B>"Preserve the Title"</B>
8055
of such a section when you modify the Document means that it remains a
8056
section "Entitled XYZ" according to this definition.
8059
The Document may include Warranty Disclaimers next to the notice which
8060
states that this License applies to the Document. These Warranty
8061
Disclaimers are considered to be included by reference in this
8062
License, but only as regards disclaiming warranties: any other
8063
implication that these Warranty Disclaimers may have is void and has
8064
no effect on the meaning of this License.
8067
<DIV ALIGN="CENTER">
8068
<FONT SIZE="+2"><B>2. VERBATIM COPYING</B></FONT>
8074
You may copy and distribute the Document in any medium, either
8075
commercially or noncommercially, provided that this License, the
8076
copyright notices, and the license notice saying this License applies
8077
to the Document are reproduced in all copies, and that you add no other
8078
conditions whatsoever to those of this License. You may not use
8079
technical measures to obstruct or control the reading or further
8080
copying of the copies you make or distribute. However, you may accept
8081
compensation in exchange for copies. If you distribute a large enough
8082
number of copies you must also follow the conditions in section 3.
8085
You may also lend copies, under the same conditions stated above, and
8086
you may publicly display copies.
8089
<DIV ALIGN="CENTER">
8090
<FONT SIZE="+2"><B>3. COPYING IN QUANTITY</B></FONT>
8096
If you publish printed copies (or copies in media that commonly have
8097
printed covers) of the Document, numbering more than 100, and the
8098
Document's license notice requires Cover Texts, you must enclose the
8099
copies in covers that carry, clearly and legibly, all these Cover
8100
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
8101
the back cover. Both covers must also clearly and legibly identify
8102
you as the publisher of these copies. The front cover must present
8103
the full title with all words of the title equally prominent and
8104
visible. You may add other material on the covers in addition.
8105
Copying with changes limited to the covers, as long as they preserve
8106
the title of the Document and satisfy these conditions, can be treated
8107
as verbatim copying in other respects.
8110
If the required texts for either cover are too voluminous to fit
8111
legibly, you should put the first ones listed (as many as fit
8112
reasonably) on the actual cover, and continue the rest onto adjacent
8116
If you publish or distribute Opaque copies of the Document numbering
8117
more than 100, you must either include a machine-readable Transparent
8118
copy along with each Opaque copy, or state in or with each Opaque copy
8119
a computer-network location from which the general network-using
8120
public has access to download using public-standard network protocols
8121
a complete Transparent copy of the Document, free of added material.
8122
If you use the latter option, you must take reasonably prudent steps,
8123
when you begin distribution of Opaque copies in quantity, to ensure
8124
that this Transparent copy will remain thus accessible at the stated
8125
location until at least one year after the last time you distribute an
8126
Opaque copy (directly or through your agents or retailers) of that
8127
edition to the public.
8130
It is requested, but not required, that you contact the authors of the
8131
Document well before redistributing any large number of copies, to give
8132
them a chance to provide you with an updated version of the Document.
8135
<DIV ALIGN="CENTER">
8136
<FONT SIZE="+2"><B>4. MODIFICATIONS</B></FONT>
8142
You may copy and distribute a Modified Version of the Document under
8143
the conditions of sections 2 and 3 above, provided that you release
8144
the Modified Version under precisely this License, with the Modified
8145
Version filling the role of the Document, thus licensing distribution
8146
and modification of the Modified Version to whoever possesses a copy
8147
of it. In addition, you must do these things in the Modified Version:
8152
<DD>Use in the Title Page (and on the covers, if any) a title distinct
8153
from that of the Document, and from those of previous versions
8154
(which should, if there were any, be listed in the History section
8155
of the Document). You may use the same title as a previous version
8156
if the original publisher of that version gives permission.
8161
<DD>List on the Title Page, as authors, one or more persons or entities
8162
responsible for authorship of the modifications in the Modified
8163
Version, together with at least five of the principal authors of the
8164
Document (all of its principal authors, if it has fewer than five),
8165
unless they release you from this requirement.
8170
<DD>State on the Title page the name of the publisher of the
8171
Modified Version, as the publisher.
8176
<DD>Preserve all the copyright notices of the Document.
8181
<DD>Add an appropriate copyright notice for your modifications
8182
adjacent to the other copyright notices.
8187
<DD>Include, immediately after the copyright notices, a license notice
8188
giving the public permission to use the Modified Version under the
8189
terms of this License, in the form shown in the Addendum below.
8194
<DD>Preserve in that license notice the full lists of Invariant Sections
8195
and required Cover Texts given in the Document's license notice.
8200
<DD>Include an unaltered copy of this License.
8205
<DD>Preserve the section Entitled "History", Preserve its Title, and add
8206
to it an item stating at least the title, year, new authors, and
8207
publisher of the Modified Version as given on the Title Page. If
8208
there is no section Entitled "History" in the Document, create one
8209
stating the title, year, authors, and publisher of the Document as
8210
given on its Title Page, then add an item describing the Modified
8211
Version as stated in the previous sentence.
8216
<DD>Preserve the network location, if any, given in the Document for
8217
public access to a Transparent copy of the Document, and likewise
8218
the network locations given in the Document for previous versions
8219
it was based on. These may be placed in the "History" section.
8220
You may omit a network location for a work that was published at
8221
least four years before the Document itself, or if the original
8222
publisher of the version it refers to gives permission.
8227
<DD>For any section Entitled "Acknowledgements" or "Dedications",
8228
Preserve the Title of the section, and preserve in the section all
8229
the substance and tone of each of the contributor acknowledgements
8230
and/or dedications given therein.
8235
<DD>Preserve all the Invariant Sections of the Document,
8236
unaltered in their text and in their titles. Section numbers
8237
or the equivalent are not considered part of the section titles.
8242
<DD>Delete any section Entitled "Endorsements". Such a section
8243
may not be included in the Modified Version.
8248
<DD>Do not retitle any existing section to be Entitled "Endorsements"
8249
or to conflict in title with any Invariant Section.
8254
<DD>Preserve any Warranty Disclaimers.
8259
If the Modified Version includes new front-matter sections or
8260
appendices that qualify as Secondary Sections and contain no material
8261
copied from the Document, you may at your option designate some or all
8262
of these sections as invariant. To do this, add their titles to the
8263
list of Invariant Sections in the Modified Version's license notice.
8264
These titles must be distinct from any other section titles.
8267
You may add a section Entitled "Endorsements", provided it contains
8268
nothing but endorsements of your Modified Version by various
8269
parties--for example, statements of peer review or that the text has
8270
been approved by an organization as the authoritative definition of a
8274
You may add a passage of up to five words as a Front-Cover Text, and a
8275
passage of up to 25 words as a Back-Cover Text, to the end of the list
8276
of Cover Texts in the Modified Version. Only one passage of
8277
Front-Cover Text and one of Back-Cover Text may be added by (or
8278
through arrangements made by) any one entity. If the Document already
8279
includes a cover text for the same cover, previously added by you or
8280
by arrangement made by the same entity you are acting on behalf of,
8281
you may not add another; but you may replace the old one, on explicit
8282
permission from the previous publisher that added the old one.
8285
The author(s) and publisher(s) of the Document do not by this License
8286
give permission to use their names for publicity for or to assert or
8287
imply endorsement of any Modified Version.
8290
<DIV ALIGN="CENTER">
8291
<FONT SIZE="+2"><B>5. COMBINING DOCUMENTS</B></FONT>
8297
You may combine the Document with other documents released under this
8298
License, under the terms defined in section 4 above for modified
8299
versions, provided that you include in the combination all of the
8300
Invariant Sections of all of the original documents, unmodified, and
8301
list them all as Invariant Sections of your combined work in its
8302
license notice, and that you preserve all their Warranty Disclaimers.
8305
The combined work need only contain one copy of this License, and
8306
multiple identical Invariant Sections may be replaced with a single
8307
copy. If there are multiple Invariant Sections with the same name but
8308
different contents, make the title of each such section unique by
8309
adding at the end of it, in parentheses, the name of the original
8310
author or publisher of that section if known, or else a unique number.
8311
Make the same adjustment to the section titles in the list of
8312
Invariant Sections in the license notice of the combined work.
8315
In the combination, you must combine any sections Entitled "History"
8316
in the various original documents, forming one section Entitled
8317
"History"; likewise combine any sections Entitled "Acknowledgements",
8318
and any sections Entitled "Dedications". You must delete all sections
8319
Entitled "Endorsements".
8322
<DIV ALIGN="CENTER">
8323
<FONT SIZE="+2"><B>6. COLLECTIONS OF DOCUMENTS</B></FONT>
8329
You may make a collection consisting of the Document and other documents
8330
released under this License, and replace the individual copies of this
8331
License in the various documents with a single copy that is included in
8332
the collection, provided that you follow the rules of this License for
8333
verbatim copying of each of the documents in all other respects.
8336
You may extract a single document from such a collection, and distribute
8337
it individually under this License, provided you insert a copy of this
8338
License into the extracted document, and follow this License in all
8339
other respects regarding verbatim copying of that document.
8342
<DIV ALIGN="CENTER">
8343
<FONT SIZE="+2"><B>7. AGGREGATION WITH INDEPENDENT WORKS</B></FONT>
8349
A compilation of the Document or its derivatives with other separate
8350
and independent documents or works, in or on a volume of a storage or
8351
distribution medium, is called an "aggregate" if the copyright
8352
resulting from the compilation is not used to limit the legal rights
8353
of the compilation's users beyond what the individual works permit.
8354
When the Document is included in an aggregate, this License does not
8355
apply to the other works in the aggregate which are not themselves
8356
derivative works of the Document.
8359
If the Cover Text requirement of section 3 is applicable to these
8360
copies of the Document, then if the Document is less than one half of
8361
the entire aggregate, the Document's Cover Texts may be placed on
8362
covers that bracket the Document within the aggregate, or the
8363
electronic equivalent of covers if the Document is in electronic form.
8364
Otherwise they must appear on printed covers that bracket the whole
8368
<DIV ALIGN="CENTER">
8369
<FONT SIZE="+2"><B>8. TRANSLATION</B></FONT>
8375
Translation is considered a kind of modification, so you may
8376
distribute translations of the Document under the terms of section 4.
8377
Replacing Invariant Sections with translations requires special
8378
permission from their copyright holders, but you may include
8379
translations of some or all Invariant Sections in addition to the
8380
original versions of these Invariant Sections. You may include a
8381
translation of this License, and all the license notices in the
8382
Document, and any Warranty Disclaimers, provided that you also include
8383
the original English version of this License and the original versions
8384
of those notices and disclaimers. In case of a disagreement between
8385
the translation and the original version of this License or a notice
8386
or disclaimer, the original version will prevail.
8389
If a section in the Document is Entitled "Acknowledgements",
8390
"Dedications", or "History", the requirement (section 4) to Preserve
8391
its Title (section 1) will typically require changing the actual
8395
<DIV ALIGN="CENTER">
8396
<FONT SIZE="+2"><B>9. TERMINATION</B></FONT>
8402
You may not copy, modify, sublicense, or distribute the Document except
8403
as expressly provided for under this License. Any other attempt to
8404
copy, modify, sublicense or distribute the Document is void, and will
8405
automatically terminate your rights under this License. However,
8406
parties who have received copies, or rights, from you under this
8407
License will not have their licenses terminated so long as such
8408
parties remain in full compliance.
8411
<DIV ALIGN="CENTER">
8412
<FONT SIZE="+2"><B>10. FUTURE REVISIONS OF THIS LICENSE</B></FONT>
8418
The Free Software Foundation may publish new, revised versions
8419
of the GNU Free Documentation License from time to time. Such new
8420
versions will be similar in spirit to the present version, but may
8421
differ in detail to address new problems or concerns. See
8422
http://www.gnu.org/copyleft/.
8425
Each version of the License is given a distinguishing version number.
8426
If the Document specifies that a particular numbered version of this
8427
License "or any later version" applies to it, you have the option of
8428
following the terms and conditions either of that specified version or
8429
of any later version that has been published (not as a draft) by the
8430
Free Software Foundation. If the Document does not specify a version
8431
number of this License, you may choose any version ever published (not
8432
as a draft) by the Free Software Foundation.
8435
<DIV ALIGN="CENTER">
8436
<FONT SIZE="+2"><B>ADDENDUM: How to use this License for your documents</B></FONT>
8442
To use this License in a document you have written, include a copy of
8443
the License in the document and put the following copyright and
8444
license notices just after the title page:
8451
Copyright ©YEAR YOUR NAME.
8452
Permission is granted to copy, distribute and/or modify this document
8453
under the terms of the GNU Free Documentation License, Version 1.2
8454
or any later version published by the Free Software Foundation;
8455
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
8456
A copy of the license is included in the section entitled "GNU
8457
Free Documentation License".
8465
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
8466
replace the "with...Texts." line with this:
8473
with the Invariant Sections being LIST THEIR TITLES, with the
8474
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
8482
If you have Invariant Sections without Cover Texts, or some other
8483
combination of the three, merge those two alternatives to suit the
8487
If your document contains nontrivial examples of program code, we
8488
recommend releasing these examples in parallel under your choice of
8489
free software license, such as the GNU General Public License,
8490
to permit their use in free software.
8498
<H2><A NAME="SECTION000210000000000000000">
8501
<DT><STRONG>Catalog Services </STRONG>
8502
<DD><A HREF="developers.html#1599">Catalog Services</A>
8503
<DT><STRONG>Catalog, Internal Bacula </STRONG>
8504
<DD><A HREF="developers.html#1647">Internal Bacula Catalog</A>
8505
<DT><STRONG>Database Table Design </STRONG>
8506
<DD><A HREF="developers.html#1656">Database Table Design</A>
8507
<DT><STRONG>Database Tables </STRONG>
8508
<DD><A HREF="developers.html#1669">Database Tables</A>
8509
<DT><STRONG>Definition, MySQL Table </STRONG>
8510
<DD><A HREF="developers.html#2322">MySQL Table Definition</A>
8511
<DT><STRONG>Design, Database Table </STRONG>
8512
<DD><A HREF="developers.html#1655">Database Table Design</A>
8513
<DT><STRONG>Difficult, GUI Interface is </STRONG>
8514
<DD><A HREF="developers.html#3423">GUI Interface is Difficult</A>
8515
<DT><STRONG>Filenames and Maximum Filename Length </STRONG>
8516
<DD><A HREF="developers.html#1617">Filenames and Maximum Filename Length</A>
8517
<DT><STRONG>General </STRONG>
8518
<DD><A HREF="developers.html#1604">General</A>
8519
| <A HREF="developers.html#3410">General</A>
8520
<DT><STRONG>GNU ree Documentation License</STRONG>
8521
<DD><A HREF="developers.html#5593">GNU Free Documentation License</A>
8522
<DT><STRONG>GUI Interface is Difficult </STRONG>
8523
<DD><A HREF="developers.html#3422">GUI Interface is Difficult</A>
8524
<DT><STRONG>Implementing a Bacula GUI Interface </STRONG>
8525
<DD><A HREF="developers.html#3405">Implementing a Bacula GUI Interface</A>
8526
<DT><STRONG>Installing and Configuring MySQL </STRONG>
8527
<DD><A HREF="developers.html#1624">Installing and Configuring MySQL</A>
8528
<DT><STRONG>Installing and Configuring PostgreSQL </STRONG>
8529
<DD><A HREF="developers.html#1632">Installing and Configuring PostgreSQL</A>
8530
<DT><STRONG>Installing and Configuring SQLite </STRONG>
8531
<DD><A HREF="developers.html#1639">Installing and Configuring SQLite</A>
8532
<DT><STRONG>Interface, Implementing a Bacula GUI </STRONG>
8533
<DD><A HREF="developers.html#3404">Implementing a Bacula GUI Interface</A>
8534
<DT><STRONG>Internal Bacula Catalog </STRONG>
8535
<DD><A HREF="developers.html#1648">Internal Bacula Catalog</A>
8536
<DT><STRONG>Job, Sequence of Creation of Records for a Save </STRONG>
8537
<DD><A HREF="developers.html#1662">Sequence of Creation of Records for a Save Job</A>
8538
<DT><STRONG>Length, Filenames and Maximum Filename </STRONG>
8539
<DD><A HREF="developers.html#1618">Filenames and Maximum Filename Length</A>
8540
<DT><STRONG>License, GNU ree Documentation</STRONG>
8541
<DD><A HREF="developers.html#5594">GNU Free Documentation License</A>
8542
<DT><STRONG>Minimal Code in Console Program </STRONG>
8543
<DD><A HREF="developers.html#3417">Minimal Code in Console Program</A>
8544
<DT><STRONG>MySQL Table Definition </STRONG>
8545
<DD><A HREF="developers.html#2321">MySQL Table Definition</A>
8546
<DT><STRONG>MySQL, Installing and Configuring </STRONG>
8547
<DD><A HREF="developers.html#1623">Installing and Configuring MySQL</A>
8548
<DT><STRONG>PostgreSQL, Installing and Configuring </STRONG>
8549
<DD><A HREF="developers.html#1631">Installing and Configuring PostgreSQL</A>
8550
<DT><STRONG>Program, Minimal Code in Console </STRONG>
8551
<DD><A HREF="developers.html#3416">Minimal Code in Console Program</A>
8552
<DT><STRONG>Sequence of Creation of Records for a Save Job </STRONG>
8553
<DD><A HREF="developers.html#1661">Sequence of Creation of Records for a Save Job</A>
8554
<DT><STRONG>Services, Catalog </STRONG>
8555
<DD><A HREF="developers.html#1598">Catalog Services</A>
8556
<DT><STRONG>SQLite, Installing and Configuring </STRONG>
8557
<DD><A HREF="developers.html#1640">Installing and Configuring SQLite</A>
8558
<DT><STRONG>Tables, Database </STRONG>
8559
<DD><A HREF="developers.html#1670">Database Tables</A>
8564
<H1><A NAME="SECTION000220000000000000000">
8565
About this document ...</A>
8568
WIDTH="458" HEIGHT="99" ALIGN="BOTTOM" BORDER="0"
8569
SRC="bacula-logo.png"
8570
ALT="\includegraphics{./bacula-logo.eps}">
8573
<DIV ALIGN="CENTER">
8574
<FONT SIZE="+1">It comes in the night and sucks
8575
the essence from your computers.
8577
</FONT></DIV></STRONG><P>
8578
This document was generated using the
8579
<A HREF="http://www.latex2html.org/"><STRONG>LaTeX</STRONG>2<tt>HTML</tt></A> translator Version 2002-2-1 (1.70)
8581
Copyright © 1993, 1994, 1995, 1996,
8582
<A HREF="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos Drakos</A>,
8583
Computer Based Learning Unit, University of Leeds.
8585
Copyright © 1997, 1998, 1999,
8586
<A HREF="http://www.maths.mq.edu.au/~ross/">Ross Moore</A>,
8587
Mathematics Department, Macquarie University, Sydney.
8589
The command line arguments were: <BR>
8590
<STRONG>latex2html</STRONG> <TT>-white -no_subdir -split 0 -toc_stars -white -notransparent developers</TT>
8592
The translation was initiated by on 2006-07-01<HR>
8593
<!--Navigation Panel-->
8594
<IMG WIDTH="81" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next_inactive"
8595
SRC="file:/usr/share/latex2html/icons/nx_grp_g.png">
8596
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
8597
SRC="file:/usr/share/latex2html/icons/up_g.png">
8598
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
8599
SRC="file:/usr/share/latex2html/icons/prev_g.png">
8601
<!--End of Navigation Panel-->