4 \chapter{The Bootstrap File}
5 \label{BootstrapChapter}
6 \index[general]{File!Bootstrap }
7 \index[general]{Bootstrap File }
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
13 \ilink{restore\_command}{_ConsoleChapter} command in the Console program, or
15 \ilink{ Write Bootstrap}{writebootstrap} record in your Backup
16 Jobs, and thus you will never need to know the details of this file.
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
24 \index[general]{Format!File }
25 \index[general]{File Format }
27 The general format of a {\bf bootstrap} file is:
29 {\bf \lt{}keyword\gt{}= \lt{}value\gt{}}
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.
36 Blank lines and lines beginning with a pound sign (\#) in the bootstrap file
39 There are keywords which permit filtering by Volume, Client, Job, FileIndex,
40 Session Id, Session Time, ...
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.
52 VolSessionTime = 108927638
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.
60 The full set of permitted keywords presented in the order in which they are
61 matched against the Volume records are:
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.
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.
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.
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
92 \item [VolSessionTime]
93 \index[fd]{VolSessionTime }
94 The value specifies a Volume Session Time to be matched from the current
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.
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.
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
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
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
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.
143 The value specifies the autochanger slot. There may be only a single {\bf
144 Slot} specification for each Volume.
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.
153 \index[fd]{*JobType }
157 \index[fd]{*JobLevel }
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
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.
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,
174 Client = "My machine"
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}.
182 Multiple occurrences of the same record are {\bf OR}ed together. Thus,
187 Client = "My machine"
188 Client = "Backup machine"
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
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,
204 Client = "My machine", "Backup machine"
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 )}.
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
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
224 Using default Catalog name=MySQL DB=bacula
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 +-------+------------------+------------+-----------+----------+------------+
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.
251 The following bootstrap file will restore those files:
257 VolSessionTime=1022753312
260 VolSessionTime=1024128917
263 VolSessionTime=1024132350
266 VolSessionTime=1024380678
270 As a final example, assume that the initial Full save spanned two Volumes. The
271 output from {\bf query} might look like:
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 +-------+------------------+------------+-----------+----------+------------+
286 and the following bootstrap file would restore those files:
292 VolSessionTime=1025016612
295 VolSessionTime=1025016612
298 VolSessionTime=1025016612
301 VolSessionTime=1025025494
305 \section{Automatic Generation of Bootstrap Files}
306 \index[general]{Files!Automatic Generation of Bootstrap }
307 \index[general]{Automatic Generation of Bootstrap Files }
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
317 When the bootstrap file is generated for the restore command, only one copy
318 (the most recent) of each file is restored.
320 So if you have spare cycles on your machine, you could optimize the bootstrap
321 files by doing the following:
326 restore client=xxx select all
329 Backup bootstrap file.
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.
337 The {\bf no} answers the {\bf Do you want to run this (yes/mod/no)} question.
339 \section{A Final Example}
340 \index[general]{Example!Final }
341 \index[general]{Final Example }
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:
353 VolSessionTime=1080847820
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
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:
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
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