]> git.sur5r.net Git - bacula/docs/blob - docs/manual/bootstrap.tex
Initial revision
[bacula/docs] / docs / manual / bootstrap.tex
1 %%
2 %%
3
4 \section*{The Bootstrap File}
5 \label{_ChapterStart43}
6 \index[general]{File!Bootstrap }
7 \index[general]{Bootstrap File }
8 \addcontentsline{toc}{section}{Bootstrap File}
9
10 The information in this chapter is provided so that you may either create your
11 own bootstrap files, or so that you can edit a bootstrap file produced by {\bf
12 Bacula}. However, normally the bootstrap file will be automatically created
13 for you during the 
14 \ilink{restore}{_ChapterStart13} command in the Console program, or
15 by using a 
16 \ilink{ Write Bootstrap}{writebootstrap} record in your Backup
17 Jobs, and thus you will never need to know the details of this file. 
18
19 The {\bf bootstrap} file contains ASCII information that permits precise
20 specification of what files should be restored. It is a relatively compact
21 form of specifying the information, is human readable, and can be edited with
22 any text editor. 
23
24 \subsection*{File Format}
25 \index[general]{Format!File }
26 \index[general]{File Format }
27 \addcontentsline{toc}{subsection}{File Format}
28
29 The general format of a {\bf bootstrap} file is: 
30
31 {\bf \lt{}keyword\gt{}= \lt{}value\gt{}} 
32
33 Where each {\bf keyword} and the {\bf value} specify which files to restore.
34 More precisely the {\bf keyword} and their {\bf values} serve to limit which
35 files will be restored and thus act as a filter. The absence of a keyword
36 means that all records will be accepted. 
37
38 Blank lines and lines beginning with a pound sign (\#) in the bootstrap file
39 are ignored. 
40
41 There are keywords which permit filtering by Volume, Client, Job, FileIndex,
42 Session Id, Session Time, ... 
43
44 The more keywords that are specified, the more selective the specification of
45 which files to restore will be. In fact, each keyword is {\bf AND}ed with
46 other keywords that may be present. 
47
48 For example, 
49
50 \footnotesize
51 \begin{verbatim}
52 Volume = Test-001
53 VolSessionId = 1
54 VolSessionTime = 108927638
55 \end{verbatim}
56 \normalsize
57
58 directs the Storage daemon (or the {\bf bextract} program) to restore only
59 those files on Volume Test-001 {\bf AND} having VolumeSessionId equal to one
60 {\bf AND} having VolumeSession time equal to 108927638. 
61
62 The full set of permitted keywords presented in the order in which they are
63 matched against the Volume records are: 
64
65 \begin{description}
66
67 \item [Volume]
68    \index[fd]{Volume }
69    The value field specifies what Volume the  following commands apply to.  Each
70 Volume specification becomes the current  Volume, to which all the following
71 commands apply until  a new current Volume (if any) is specified. If the
72 Volume name  contains spaces, it should be enclosed in quotes. 
73
74 \item [Count]
75    \index[fd]{Count }
76    The value is the total number of files that  will be restored for this Volume.
77 This allows the Storage  daemon to know when to stop reading the Volume.  
78
79 \item [VolFile]
80    \index[fd]{VolFile }
81    The value is a file number, a list of file numbers,  or a range of file
82 numbers numbers to match on the current Volume.  The file number represents
83 the physical file on the Volume where  the data is stored. For a tape volume,
84 this record is used  to position to the correct starting file, and once the
85 tape is  past the last specified file, reading will stop. 
86
87 \item [VolBlock]
88    \index[fd]{VolBlock }
89    The value is a block number, a list of block numbers,  or a range of block
90 numbers numbers to match on the current Volume.  The block number represents
91 the physical block on the Volume where  the data is stored. This record is
92 currently not used.  
93
94 \item [VolSessionTime]
95    \index[fd]{VolSessionTime }
96    The value specifies a Volume Session Time to  be matched from the current
97 volume.  
98
99 \item [VolSessionId]
100    \index[fd]{VolSessionId }
101    The value specifies a VolSessionId, a list of  volume session ids, or a range
102 of volume session ids to be matched  from the current Volume. Each
103 VolSessionId and VolSessionTime pair corresponds  to a unique Job that is
104 backed up on the Volume.  
105
106 \item [JobId]
107    \index[fd]{JobId }
108    The value specifies a JobId, list of JobIds, or range of JobIds  to be
109 selected from the current Volume. Note, the JobId may not be  unique if you
110 have multiple Directors, or if you have reinitialized your  database. The
111 JobId filter works only if you do not run  multiple simultaneous jobs.  
112
113 \item [Job]
114    \index[fd]{Job }
115    The value specifies a Job name or list of Job names to  be matched on the
116 current Volume. The Job corresponds to a unique  VolSessionId and
117 VolSessionTime pair. However, the Job is perhaps a  bit more readable by
118 humans. Standard regular expressions (wildcards)  may be used to match Job
119 names. The Job filter works only if you do  not run multiple simultaneous
120 jobs.  
121
122 \item [Client]
123    \index[fd]{Client }
124    The value specifies a Client name or list of Clients to  will be matched on
125 the current Volume. Standard regular expressions  (wildcards) may be used to
126 match Client names. The Client filter works  only if you do not run multiple
127 simultaneous jobs.  
128
129 \item [FileIndex]
130    \index[fd]{FileIndex }
131    The value specifies a FileIndex, list of FileIndexes,  or range of FileIndexes
132 to be selected from the current Volume.  Each file (data) stored on a Volume
133 within a Session has a unique  FileIndex. For each Session, the first file
134 written is assigned  FileIndex equal to one and incremented for each file
135 backed up.  
136
137 This for a given Volume, the triple VolSessionId, VolSessionTime,  and
138 FileIndex uniquely identifies a file stored on the Volume. Multiple  copies of
139 the same file may be stored on the same Volume, but for  each file, the triple
140 VolSessionId, VolSessionTime, and FileIndex  will be unique. This triple is
141 stored in the Catalog database for  each file.  
142
143 \item [Slot]
144    \index[fd]{Slot }
145    The value specifies the autochanger slot. There may  be only a single {\bf
146 Slot} specification for each Volume.  
147
148 \item [Stream]
149    \index[fd]{Stream }
150    The value specifies a Stream, a list of Streams,  or a range of Streams to be
151 selected from the current Volume.  Unless you really know what you are doing
152 (the internals of  {\bf Bacula}, you should avoid this specification.  
153
154 \item [*JobType]
155    \index[fd]{*JobType }
156    Not yet implemented.  
157
158 \item [*JobLevel]
159    \index[fd]{*JobLevel }
160    Not yet implemented.  
161 \end{description}
162
163 The {\bf Volume} record is a bit special in that it must be the first record.
164 The other keyword records may appear in any order and any number following a
165 Volume record. 
166
167 Multiple Volume records may be specified in the same bootstrap file, but each
168 one starts a new set of filter criteria for the Volume. 
169
170 In processing the bootstrap file within the current Volume, each filter
171 specified by a keyword is {\bf AND}ed with the next. Thus, 
172
173 \footnotesize
174 \begin{verbatim}
175 Volume = Test-01
176 Client = "My machine"
177 FileIndex = 1
178 \end{verbatim}
179 \normalsize
180
181 will match records on Volume {\bf Test-01} {\bf AND} Client records for {\bf
182 My machine} {\bf AND} FileIndex equal to {\bf one}. 
183
184 Multiple occurrences of the same record are {\bf OR}ed together. Thus, 
185
186 \footnotesize
187 \begin{verbatim}
188 Volume = Test-01
189 Client = "My machine"
190 Client = "Backup machine"
191 FileIndex = 1
192 \end{verbatim}
193 \normalsize
194
195 will match records on Volume {\bf Test-01} {\bf AND} (Client records for {\bf
196 My machine} {\bf OR} {\bf Backup machine}) {\bf AND} FileIndex equal to {\bf
197 one}. 
198
199 For integer values, you may supply a range or a list, and for all other values
200 except Volumes, you may specify a list. A list is equivalent to multiple
201 records of the same keyword. For example, 
202
203 \footnotesize
204 \begin{verbatim}
205 Volume = Test-01
206 Client = "My machine", "Backup machine"
207 FileIndex = 1-20, 35
208 \end{verbatim}
209 \normalsize
210
211 will match records on Volume {\bf Test-01} {\bf AND} {\bf (}Client records for
212 {\bf My machine} {\bf OR} {\bf Backup machine}{\bf )} {\bf AND} {\bf
213 (}FileIndex 1 {\bf OR} 2 {\bf OR} 3 ... {\bf OR} 20 {\bf OR} 35{\bf )}. 
214
215 As previously mentioned above, there may be multiple Volume records in the
216 same bootstrap file. Each new Volume definition begins a new set of filter
217 conditions that apply to that Volume and will be {\bf OR}ed with any other
218 Volume definitions. 
219
220 As an example, suppose we query for the current set of tapes to restore all
221 files on Client {\bf Rufus} using the {\bf query} command in the console
222 program: 
223
224 \footnotesize
225 \begin{verbatim}
226 Using default Catalog name=MySQL DB=bacula
227 *query
228 Available queries:
229      1: List Job totals:
230      2: List where a file is saved:
231      3: List where the most recent copies of a file are saved:
232      4: List total files/bytes by Job:
233      5: List total files/bytes by Volume:
234      6: List last 10 Full Backups for a Client:
235      7: List Volumes used by selected JobId:
236      8: List Volumes to Restore All Files:
237 Choose a query (1-8): 8
238 Enter Client Name: Rufus
239 +-------+------------------+------------+-----------+----------+------------+
240 | JobId | StartTime        | VolumeName | StartFile | VolSesId | VolSesTime |
241 +-------+------------------+------------+-----------+----------+------------+
242 | 154   | 2002-05-30 12:08 | test-02    | 0         | 1        | 1022753312 |
243 | 202   | 2002-06-15 10:16 | test-02    | 0         | 2        | 1024128917 |
244 | 203   | 2002-06-15 11:12 | test-02    | 3         | 1        | 1024132350 |
245 | 204   | 2002-06-18 08:11 | test-02    | 4         | 1        | 1024380678 |
246 +-------+------------------+------------+-----------+----------+------------+
247 \end{verbatim}
248 \normalsize
249
250 The output shows us that there are four Jobs that must be restored. The first
251 one is a Full backup, and the following three are all Incremental backups. 
252
253 The following bootstrap file will restore those files: 
254
255 \footnotesize
256 \begin{verbatim}
257 Volume=test-02
258 VolSessionId=1
259 VolSessionTime=1022753312
260 Volume=test-02
261 VolSessionId=2
262 VolSessionTime=1024128917
263 Volume=test-02
264 VolSessionId=1
265 VolSessionTime=1024132350
266 Volume=test-02
267 VolSessionId=1
268 VolSessionTime=1024380678
269 \end{verbatim}
270 \normalsize
271
272 As a final example, assume that the initial Full save spanned two Volumes. The
273 output from {\bf query} might look like: 
274
275 \footnotesize
276 \begin{verbatim}
277 +-------+------------------+------------+-----------+----------+------------+
278 | JobId | StartTime        | VolumeName | StartFile | VolSesId | VolSesTime |
279 +-------+------------------+------------+-----------+----------+------------+
280 | 242   | 2002-06-25 16:50 | File0003   | 0         | 1        | 1025016612 |
281 | 242   | 2002-06-25 16:50 | File0004   | 0         | 1        | 1025016612 |
282 | 243   | 2002-06-25 16:52 | File0005   | 0         | 2        | 1025016612 |
283 | 246   | 2002-06-25 19:19 | File0006   | 0         | 2        | 1025025494 |
284 +-------+------------------+------------+-----------+----------+------------+
285 \end{verbatim}
286 \normalsize
287
288 and the following bootstrap file would restore those files: 
289
290 \footnotesize
291 \begin{verbatim}
292 Volume=File0003
293 VolSessionId=1
294 VolSessionTime=1025016612
295 Volume=File0004
296 VolSessionId=1
297 VolSessionTime=1025016612
298 Volume=File0005
299 VolSessionId=2
300 VolSessionTime=1025016612
301 Volume=File0006
302 VolSessionId=2
303 VolSessionTime=1025025494
304 \end{verbatim}
305 \normalsize
306
307 \subsection*{Automatic Generation of Bootstrap Files}
308 \index[general]{Files!Automatic Generation of Bootstrap }
309 \index[general]{Automatic Generation of Bootstrap Files }
310 \addcontentsline{toc}{subsection}{Automatic Generation of Bootstrap Files}
311
312 One thing that is probably worth knowing: the bootstrap files that are
313 generated automatically at the end of the job are not as optimized as those
314 generated by the restore command. This is because the ones created at the end
315 of the file, contain all files written to the Volume for that job. As a
316 consequence, all the files saved to an Incremental or Differential job will be
317 restored first by the Full save, then by any Incremental or Differential
318 saves. 
319
320 When the bootstrap file is generated for the restore command, only one copy
321 (the most recent) of each file is restored. 
322
323 So if you have spare cycles on your machine, you could optimize the bootstrap
324 files by doing the following: 
325
326 \footnotesize
327 \begin{verbatim}
328    ./console
329    restore client=xxx select all
330    no
331    quit
332    Backup bootstrap file.
333 \end{verbatim}
334 \normalsize
335
336 The above will not work if you have multiple FileSets because that will be an
337 extra prompt. However, the {\bf restore client=xxx select all} builds the
338 in-memory tree, selecting everything and creates the bootstrap file. 
339
340 The {\bf no} answers the {\bf Do you want to run this (yes/mod/no)} question. 
341
342 \subsection*{A Final Example}
343 \index[general]{Example!Final }
344 \index[general]{Final Example }
345 \addcontentsline{toc}{subsection}{Final Example}
346
347 If you want to extract or copy a single Job, you can do it by selecting by
348 JobId (code not tested) or better yet, if you know the VolSessionTime and the
349 VolSessionId (printed on Job report and in Catalog), specifying this is by far
350 the best. Using the VolSessionTime and VolSessionId is the way Bacula does
351 restores. A bsr file might look like the following: 
352
353 \footnotesize
354 \begin{verbatim}
355 Volume="Vol001"
356 VolSessionId=10
357 VolSessionTime=1080847820
358 \end{verbatim}
359 \normalsize
360
361 If you know how many files are backed up (on the job report), you can
362 enormously speed up the selection by adding (let's assume there are 157
363 files): 
364
365 \footnotesize
366 \begin{verbatim}
367 FileIndex=1-157
368 Count=157
369 \end{verbatim}
370 \normalsize
371
372 Finally, if you know the File number where the Job starts, you can also cause
373 bcopy to forward space to the right file without reading every record: 
374
375 \footnotesize
376 \begin{verbatim}
377 VolFile=20
378 \end{verbatim}
379 \normalsize
380
381 There is nothing magic or complicated about a BSR file. Parsing it and
382 properly applying it within Bacula *is* magic, but you don't need to worry
383 about that. 
384
385 If you want to see a *real* bsr file, simply fire up the {\bf restore} command
386 in the console program, select something, then answer no when it prompts to
387 run the job. Then look at the file {\bf restore.bsr} in your working
388 directory.