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