]> git.sur5r.net Git - bacula/docs/blob - docs/manual/restore.tex
2c2ef406b8838a78c6bbdaab6ee21d504357c095
[bacula/docs] / docs / manual / restore.tex
1 %%
2 %%
3
4 \section*{The Bacula Console Restore Command}
5 \label{_ChapterStart13}
6 \index[general]{Command!Bacula Console Restore }
7 \index[general]{Bacula Console Restore Command }
8 \addcontentsline{toc}{section}{Bacula Console Restore Command}
9
10 \subsection*{General}
11 \index[general]{General }
12 \addcontentsline{toc}{subsection}{General}
13
14 Below, we will discuss restoring files with the Console {\bf Restore} command,
15 which is the recommended way of doing it. However, there is a standalone
16 program named {\bf bextract}, which also permits restoring files. For more
17 information on this program, please see the 
18 \ilink{Bacula Utility Programs}{bextract} chapter of this manual.
19 You will also want to look at the {\bf bls} program in the same chapter, which
20 allows you to list the contents of your Volumes. Finally, if you have an old
21 Volume that is no longer in the catalog, you can restore the catalog entries
22 using the program named {\bf bscan}, documented in the same 
23 \ilink{Bacula Utility Programs}{bextract} chapter. 
24
25 In general, to restore a file or a set of files, you must run a {\bf restore}
26 job. That is a job with {\bf Type = Restore}. As a consequence, you will need
27 a predefined {\bf restore} job in your {\bf bacula-dir.conf} (Director's
28 config) file. The exact parameters (Client, FileSet, ...) that you define are
29 not important as you can either modify them manually before running the job or
30 if you use the {\bf restore} command, explained below, they will be
31 automatically set for you. 
32
33 Since Bacula is a network backup program, you must be aware that when you
34 restore files, it is up to you to ensure that you or Bacula have selected the
35 correct Client and the correct hard disk location for restoring those files.
36 {\bf Bacula} will quite willingly backup client A, and restore it by sending
37 the files to a different directory on client B. Normally, you will want to
38 avoid this, but assuming the operating systems are not too different in their
39 file structures, this should work perfectly well, if so desired. 
40 \label{Example1}
41
42 \subsection*{The Restore Command}
43 \index[general]{Command!Restore }
44 \index[general]{Restore Command }
45 \addcontentsline{toc}{subsection}{Restore Command}
46
47 Since Bacula maintains a catalog of your files and on which Volumes (disk or
48 tape), they are stored, it can do most of the bookkeeping work, allowing you
49 simply to specify what kind of restore you want (current, before a particular
50 date), and what files to restore. Bacula will then do the rest. 
51
52 This is accomplished using the {\bf restore} command in the Console. First you
53 select the kind of restore you want, then the JobIds are selected,
54 the File records for those Jobs are placed in an internal Bacula directory
55 tree, and the restore enters a file selection mode that allows you to
56 interactively walk up and down the file tree selecting individual files to be
57 restored. This mode is somewhat similar to the standard Unix {\bf restore}
58 program's interactive file selection mode. 
59
60 Within the Console program, after entering the {\bf restore} command, you are
61 presented with the following selection prompt:  
62
63 \footnotesize
64 \begin{verbatim}
65 First you select one or more JobIds that contain files
66 to be restored. You will be presented several methods
67 of specifying the JobIds. Then you will be allowed to
68 select which files from those JobIds are to be restored.
69 To select the JobIds, you have the following choices:
70      1: List last 20 Jobs run
71      2: List Jobs where a given File is saved
72      3: Enter list of JobIds to select
73      4: Enter SQL list command
74      5: Select the most recent backup for a client
75      6: Select backup for a client before a specified time
76      7: Enter a list of files to restore
77      8: Enter a list of files to restore before a specified time
78      9: Cancel
79 Select item:  (1-9):
80      
81 \end{verbatim}
82 \normalsize
83
84 \begin{itemize}
85 \item Item 1 will list the last 20 jobs run. If you find the  Job you want,
86    you can then select item 3 and enter its JobId(s). 
87 \item Item 2 will list all the Jobs where a specified file is saved.  If you
88    find the Job you want, you can then select item 3 and  enter the JobId. 
89 \item Item 3 allows you the enter a list of comma separated JobIds whose 
90    files will be put into the directory tree. 
91 \item Item 4 allows you to enter any arbitrary SQL command. This is  probably
92    the most primitive way of finding the desired JobIds,  but at the same time,
93    the most flexible.  Once you have found the JobId(s), you can select item 3
94 and enter  them.  
95 \item Item 5 will automatically select the most recent Full backup and all 
96    subsequent incremental and differential backups for a specified  Client. These
97    are the Jobs and Files which, if reloaded, will  restore your system to the most
98 current saved state. It  automatically enters the JobIds found into the 
99 directory tree. This is probably the most convenient of all the  above options
100 to use if you wish to restore a selected Client to  its most recent state.  
101 \item Item 6 allows you to specify a date and time, after which Bacula  will
102    automatically select the most recent Full backup and all  subsequent
103    incremental and differential backups that started  before the specified date
104 and time.  
105 \item Item 7 allows you to specify one or more filenames  (complete path
106    required) to be restored. Each filename  is entered one at a time or if you
107    prefix a filename  with the less-than symbol (\lt{}) Bacula will read that 
108 file and assume it is a list of filenames to be restored.  The filename entry
109 mode is terminated by entering a  blank line.  
110 \item Item 8 allows you to specify a date and time before  entering the
111    filenames. See Item 7 above for more  details.  
112 \item Item 9 allows you to cancel the restore command.  
113    \end{itemize}
114
115 As an example, suppose that we select item 5 (restore to most recent state).
116 It will then ask for the desired Client, which on my system, will print all
117 the Clients found in the database as follows:  
118
119 \footnotesize
120 \begin{verbatim}
121 Defined clients:
122      1: Rufus
123      2: Matou
124      3: Polymatou
125      4: Minimatou
126      5: Minou
127      6: MatouVerify
128      7: PmatouVerify
129      8: RufusVerify
130      9: Watchdog
131 Select Client (File daemon) resource (1-9):
132      
133 \end{verbatim}
134 \normalsize
135
136 You will probably have far fewer Clients than this example, and  if you have
137 only one Client, it will be automatically selected. In this case, I enter
138 {\bf Rufus} to select the Client. Then  Bacula needs to know what FileSet is
139 to be restored, so it  prompts with:  
140
141 \footnotesize
142 \begin{verbatim}
143 The defined FileSet resources are:
144      1: Full Set
145      2: Kerns Files
146 Select FileSet resource (1-2):
147      
148 \end{verbatim}
149 \normalsize
150
151 I choose item 1, which is my full backup. Normally, you will only have a
152 single FileSet for each Job, and if your machines are similar (all Linux) you
153 may only have one FileSet for all your Clients. 
154
155 At this point, {\bf Bacula} has all the information it needs to find the most
156 recent set of backups. It will then query the database, which may take a bit
157 of time, and it will come up with something like the following. Note, some of
158 the columns are truncated here for presentation: 
159
160 \footnotesize
161 \begin{verbatim}
162 +-------+------+----------+-------------+-------------+------+-------+------------+
163 | JobId | Levl | JobFiles | StartTime   | VolumeName  | File | SesId | VolSesTime |
164 +-------+------+----------+-------------+-------------+------+-------+------------+
165 | 1,792 | F    |  128,374 | 08-03 01:58 | DLT-19Jul02 |   67 |    18 | 1028042998 |
166 | 1,792 | F    |  128,374 | 08-03 01:58 | DLT-04Aug02 |    0 |    18 | 1028042998 |
167 | 1,797 | I    |      254 | 08-04 13:53 | DLT-04Aug02 |    5 |    23 | 1028042998 |
168 | 1,798 | I    |       15 | 08-05 01:05 | DLT-04Aug02 |    6 |    24 | 1028042998 |
169 +-------+------+----------+-------------+-------------+------+-------+------------+
170 You have selected the following JobId: 1792,1792,1797
171 Building directory tree for JobId 1792 ...
172 Building directory tree for JobId 1797 ...
173 Building directory tree for JobId 1798 ...
174 cwd is: /
175 $
176 \end{verbatim}
177 \normalsize
178
179 Depending on the number of {\bf JobFiles} for each JobId, the {\bf Building
180 directory tree ...``} can take a bit of time. 
181
182 In our example, Bacula found four Jobs that comprise the most recent backup of
183 the specified Client and FileSet. Two of the Jobs have the same JobId because
184 that Job wrote on two different Volumes. The third Job was an incremental
185 backup to the previous Full backup, and it only saved 254 Files compared to
186 128,374 for the Full backup. The fourth Job was also an incremental backup
187 that saved 15 files. 
188
189 Next Bacula entered those Jobs into the directory tree, with no files marked
190 to be restored as a default, tells you how many files are in the tree, and
191 tells you that the current working directory ({\bf cwd}) is /. Finally, Bacula
192 prompts with the dollar sign (\$) to indicate that you may enter commands to
193 move around the directory tree and to select files. 
194
195 Instead of choosing item 5 on the first menu (Select the most recent backup
196 for a client), if we had chosen item 3 (Enter list of JobIds to select) and we
197 had entered the JobIds {\bf 1792,1797,1798} we would have arrived at the same
198 point. 
199
200 One point to note, if you are manually entering JobIds, is that you must enter
201 them in the order they were run (generally in increasing JobId order). If you
202 enter them out of order and the same file was saved in two or more of the
203 Jobs, you may end up with an old version of that file (i.e. not the most
204 recent). 
205
206 While in file selection mode, you can enter {\bf help} or a question mark (?)
207 to produce a summary of the available commands:  
208
209 \footnotesize
210 \begin{verbatim}
211   Command    Description
212   =======    ===========
213   cd         change current directory
214   count      count marked files in and below the cd
215   dir        list current directory
216   done       leave file selection mode
217   estimate   estimate restore size
218   exit       exit = done
219   find       find files -- wildcards allowed
220   help       print help
221   ls         list current directory -- wildcards allowed
222   lsmark     list the marked files in and below the cd
223   mark       mark file to be restored
224   markdir    mark directory entry to be restored -- nonrecursive
225   pwd        print current working directory
226   unmark     unmark file to be restored
227   unmarkdir  unmark directory -- no recursion
228   quit       quit
229   ?          print help
230      
231 \end{verbatim}
232 \normalsize
233
234 As a default no files have been selected for restore. If you want to restore
235 everything, at this point, you should enter {\bf mark *}, and then {\bf done}
236 and {\bf Bacula} will write the bootstrap records to a file and request your
237 approval to start a restore job. 
238
239 If you do not enter the above mentioned {\bf mark *} command, you will start
240 with an empty slate. Now you can simply start looking at the tree and {\bf
241 mark} particular files or directories you want restored. It is easy to make
242 a mistake in specifying a file to mark or unmark, and Bacula's error handling
243 is not perfect, so please check your work by using the {\bf ls} or {\bf dir}
244 commands to see what files are actually selected. Any selected file has its
245 name preceded by an asterisk. 
246
247 To check what is marked or not marked, enter the {\bf count} command, which
248 displays:  
249
250 \footnotesize
251 \begin{verbatim}
252 128401 total files. 128401 marked to be restored.
253      
254 \end{verbatim}
255 \normalsize
256
257 Each of the above commands will be described in more detail in the next
258 section. We continue with the above example, having accepted to restore all
259 files as Bacula set by default. On entering the {\bf done} command, Bacula
260 prints:  
261
262 \footnotesize
263 \begin{verbatim}
264 Bootstrap records written to /home/kern/bacula/working/restore.bsr
265 The restore job will require the following Volumes:
266    
267    DLT-19Jul02
268    DLT-04Aug02
269 128401 files selected to restore.
270 Run Restore job
271 JobName:    kernsrestore
272 Bootstrap:  /home/kern/bacula/working/restore.bsr
273 Where:      /tmp/bacula-restores
274 Replace:    always
275 FileSet:    Kerns Files
276 Client:     Rufus
277 Storage:    SDT-10000
278 JobId:      *None*
279 OK to run? (yes/mod/no):
280     
281 \end{verbatim}
282 \normalsize
283
284 Please examine each of the items very carefully to make sure that they are
285 correct. In particular, look at {\bf Where}, which tells you where in the
286 directory structure the files will be restored, and {\bf Client}, which tells
287 you which client will receive the files. These items will not always be
288 completed with the correct values depending on which of the restore options
289 you chose. 
290
291 The above assumes that you have defined a {\bf Restore} Job resource in your
292 Director's configuration file. Normally, you will only need one Restore Job
293 resource definition because by its nature, restoring is a manual operation,
294 and using the Console interface, you will be able to modify the Restore Job to
295 do what you want. 
296
297 An example Restore Job resource definition is given below. 
298
299 Returning to the above example, you should verify that the Client name is
300 correct before running the Job. However, you may want to modify some of the
301 parameters of the restore job. For example, in addition to checking the Client
302 it is wise to check that the Storage device chosen by Bacula is indeed
303 correct. Although the {\bf FileSet} is shown, it will be ignored in restore.
304 The restore will choose the files to be restored either by reading the {\bf
305 Bootstrap} file, or if not specified, it will restore all files associated
306 with the specified backup {\bf JobId} (i.e. the JobId of the Job that
307 originally backed up the files). 
308
309 Finally before running the job, please note that the default location for
310 restoring files is {\bf not} their original locations, but rather the directory
311 {\bf /tmp/bacula-restores}. You can change this default by modifying your {\bf
312 bacula-dir.conf} file, or you can modify it using the {\bf mod} option. If you
313 want to restore the files to their original location, you must have {\bf
314 Where} set to nothing or to the root, i.e. {\bf /}. 
315
316 If you now enter {\bf yes}, Bacula will run the restore Job. The Storage
317 daemon will first request Volume {\bf DLT-19Jul02} and after the appropriate
318 files have been restored from that volume, it will request Volume {\bf
319 DLT-04Aug02}. 
320
321 \subsection*{Selecting Files by Filename}
322 \index[general]{Selecting Files by Filename }
323 \index[general]{Filename!Selecting Files by }
324 \addcontentsline{toc}{subsection}{Selecting Files by Filename}
325
326 If you have a small number of files to restore, and you know the filenames,
327 you can either put the list of filenames in a file to be read by Bacula, or
328 you can enter the names one at a time. The filenames must include the full
329 path and filename. No wild cards are used. 
330
331 To enter the files, after the {\bf restore}, you select item number 7 from the
332 prompt list: 
333
334 \footnotesize
335 \begin{verbatim}
336 To select the JobIds, you have the following choices:
337      1: List last 20 Jobs run
338      2: List Jobs where a given File is saved
339      3: Enter list of JobIds to select
340      4: Enter SQL list command
341      5: Select the most recent backup for a client
342      6: Select backup for a client before a specified time
343      7: Enter a list of files to restore
344      8: Enter a list of files to restore before a specified time
345      9: Cancel
346 Select item:  (1-9): 7
347 \end{verbatim}
348 \normalsize
349
350 which then prompts you for the client name: 
351
352 \footnotesize
353 \begin{verbatim}
354 Defined Clients:
355      1: Timmy
356      2: Tibs
357      3: Rufus
358 Select the Client (1-3): 3
359 \end{verbatim}
360 \normalsize
361
362 Of course, your client list will be different, and if you have only one
363 client, it will be automatically selected. And finally, Bacula requests you to
364 enter a filename: 
365
366 \footnotesize
367 \begin{verbatim}
368 Enter filename:
369 \end{verbatim}
370 \normalsize
371
372 At this point, you can enter the full path and filename 
373
374 \footnotesize
375 \begin{verbatim}
376 Enter filename: /home/kern/bacula/k/Makefile.in
377 Enter filename:
378 \end{verbatim}
379 \normalsize
380
381 as you can see, it took the filename. If Bacula cannot find a copy of the
382 file, it prints the following: 
383
384 \footnotesize
385 \begin{verbatim}
386 Enter filename: junk filename
387 No database record found for: junk filename
388 Enter filename:
389 \end{verbatim}
390 \normalsize
391
392 If you want Bacula to read the filenames from a file, you simply precede the
393 filename with a less-than symbol (\lt{}). When you have entered all the
394 filenames, you enter a blank line, and Bacula will write the bootstrap file,
395 tells you what tapes will be used, and proposes a Restore job to be run: 
396
397 \footnotesize
398 \begin{verbatim}
399 Enter filename:
400 Automatically selected Storage: DDS-4
401 Bootstrap records written to /home/kern/bacula/working/restore.bsr
402 The restore job will require the following Volumes:
403    
404    test1
405 1 file selected to restore.
406 Run Restore job
407 JobName:    kernsrestore
408 Bootstrap:  /home/kern/bacula/working/restore.bsr
409 Where:      /tmp/bacula-restores
410 Replace:    always
411 FileSet:    Kerns Files
412 Client:     Rufus
413 Storage:    DDS-4
414 When:       2003-09-11 10:20:53
415 Priority:   10
416 OK to run? (yes/mod/no):
417 \end{verbatim}
418 \normalsize
419
420 It is possible to automate the selection by file by putting your list of files
421 in say {\bf /tmp/file-list}, then using the following command: 
422
423 \footnotesize
424 \begin{verbatim}
425 restore client=Rufus file=</tmp/file-list
426 \end{verbatim}
427 \normalsize
428
429 If in modifying the parameters for the Run Restore job, you find that Bacula
430 asks you to enter a Job number, this is because you have no yet specified
431 either a Job number or a Bootstrap file. Simply entering zero will allow you
432 to continue and to select another option to be modified. 
433 \label{CommandArguments}
434
435 \subsection*{Command Line Arguments}
436 \index[general]{Arguments!Command Line }
437 \index[general]{Command Line Arguments }
438 \addcontentsline{toc}{subsection}{Command Line Arguments}
439
440 If all the above sounds complicated, you will probably agree that it really
441 isn't after trying it a few times. It is possible to do everything that was
442 shown above, with the exception of selecting the FileSet, by using command
443 line arguments with a single command by entering: 
444
445 \footnotesize
446 \begin{verbatim}
447 restore client=Rufus select current all done yes
448 \end{verbatim}
449 \normalsize
450
451 The {\bf client=Rufus} specification will automatically select Rufus as the
452 client, the {\bf current} tells Bacula that you want to restore the system to
453 the most current state possible, and the {\bf yes} suppresses the final {\bf
454 yes/mod/no} prompt and simply runs the restore. 
455
456 The full list of possible command line arguments are: 
457
458 \begin{itemize}
459 \item {\bf all} -- select all Files to be restored.  
460 \item {\bf select} -- use the tree selection method.  
461 \item {\bf done} -- do not prompt the user in tree mode.  
462 \item {\bf current} -- automatically select the most current set of  backups
463    for the specified client.  
464 \item {\bf client=xxxx} -- select the specified client.  
465 \item {\bf jobid=nnn} -- specify a JobId or comma separated list of  JobIds to
466    be restored.  
467 \item {\bf before=YYYY-MM-DD HH:MM:SS} -- specify a date and time to  which
468    the system should be restored. Only Jobs started before  the specified
469    date/time will be selected, and as is the case  for {\bf current} Bacula will
470 automatically find the most  recent prior Full save and all Differential and
471 Incremental  saves run before the date you specify. Note, this command is  not
472 too user friendly in that you must specify the date/time  exactly as shown. 
473 \item {\bf file=filename} -- specify a filename to be restored. You  must
474    specify the full path and filename. Prefixing the entry  with a less-than sign
475    (\lt{}) will cause Bacula to assume that the  filename is on your system and
476 contains a list of files to be  restored. Bacula will thus read the list from
477 that file. Multiple  file=xxx specifications may be specified on the command
478 line. 
479 \item {\bf jobid=nnn} -- specify a JobId to be restored. 
480 \item {\bf pool=pool-name} -- specify a Pool name to be used for selection  of
481    Volumes when specifying options 5 and 6 (restore current system,  and restore
482    current system before given date). This permits you to  have several Pools,
483 possibly one offsite, and to select the Pool to  be used for restoring.  
484 \item {\bf yes} -- automatically run the restore without prompting  for
485    modifications (most useful in batch scripts). 
486    \end{itemize}
487
488 \subsection*{Restoring Directory Attributes}
489 \index[general]{Attributes!Restoring Directory }
490 \index[general]{Restoring Directory Attributes }
491 \addcontentsline{toc}{subsection}{Restoring Directory Attributes}
492
493 Depending how you do the restore, you may or may not get the directory entries
494 back to their original state. Here are a few of the problems you can
495 encounter, and for same machine restores, how to avoid them. 
496
497 \begin{itemize}
498 \item You backed up on one machine and are restoring to another that is 
499    either a different OS or doesn't have the same users/groups defined.  Bacula
500    does the best it can in these situations.  
501 \item You are restoring into a directory that is already created and has  file
502    creation restrictions. Bacula tries to reset everything  but without walking
503    up the full chain of directories and modifying  them all during the restore,
504 which Bacula does and will not do,  getting permissions back correctly in this
505 situation depends to a  large extent on your OS.  
506 \item You selected one or more files in a directory, but did not select  the
507    directory entry to be restored. In that case, if the directory  is not on disk
508    Bacula simply creates the directory with some default  attributes which may
509 not be the same as the original.  If you do not select a directory and all its
510 contents to be restored,  you can still select items within the directory to
511 be restored by  individually marking those files, but in that case, you should
512 individually use the ''markdir`` command to select all higher level 
513 directory entries (one at a time) to be restored if you want the  directory
514 entries properly restored. 
515 \end{itemize}
516
517 \label{Windows}
518
519 \subsection*{Restoring on Windows}
520 \index[general]{Restoring on Windows }
521 \index[general]{Windows!Restoring on }
522 \addcontentsline{toc}{subsection}{Restoring on Windows}
523
524 If you are restoring on WinNT/2K/XP systems, Bacula will restore the files
525 with the original ownerships and permissions as would be expected.  This is
526 also true if you are restoring those files to an alternate directory (using
527 the Where option in restore).  However, if the alternate directory does not
528 already exist, the Bacula File daemon (Client) will try to create it.  In
529 some cases, it may not create the directories, and if it does since the
530 File daemon runs under the SYSTEM account, the directory will be created
531 with SYSTEM ownership and permissions.  In this case, you may have problems
532 accessing the newly restored files.
533
534 To avoid this problem, you should create any alternate directory before doing the
535 restore. Bacula will not change the ownership and permissions of the directory
536 if it is already created as long as it is not one of the directories being
537 restored (i.e. written to tape). 
538
539 The default restore location is {\bf /tmp/bacula-restores/} and if you are
540 restoring from drive {\bf E:}, the default will be 
541 {\bf /tmp/bacula-restores/e/}, so you should ensure that this directory
542 exists before doing the restore, or use the {\bf mod} option to
543 select a different {\bf where} directory that does exist.
544
545 Some users have experienced problems restoring files that participate in
546 the Active Directory. They also report that changing the userid under which
547 Bacula (bacula-fd.exe) runs, from SYSTEM to a Domain Admin userid, resolves
548 the problem.
549
550
551 \subsection*{Restoring Files Can Be Slow}
552 \index[general]{Slow!Restoring Files Can Be }
553 \index[general]{Restoring Files Can Be Slow }
554 \addcontentsline{toc}{subsection}{Restoring Files Can Be Slow}
555
556 Restoring files is generally {\bf much} slower than backing it up for several
557 reasons. The first is that during a backup the tape is normally already
558 positioned and Bacula only needs to write. On the other hand, because restoring
559 files is done so rarely, Bacula keeps only the he start file and block on the
560 tape for the whole job rather than on a file by file basis which would use
561 quite a lot of space in the catalog. 
562
563 Bacula versions 1.31a and older would seek to the first file on the first
564 tape, then sequentially search the tape for the specified files. If you were
565 doing a full restore, this is OK, but if you want to restore one or two files,
566 the process could be quite long. 
567
568 This deficiency has been corrected in version 1.32. The consequence is that
569 Bacula will forward space to the correct file mark on the tape for the Job,
570 then forward space to the correct block, and finally sequentially read each
571 record until it gets to the correct one(s) for the file or files you want to
572 restore. Once the desired files are restored, Bacula will stop reading the
573 tape. For restoring a small number of files, version 1.32 and greater are
574 hundreds of times faster than previous versions. 
575
576 Finally, instead of just reading a file for backup, during the restore, Bacula
577 must create the file, and the operating system must allocate disk space for
578 the file as Bacula is restoring it. 
579
580 For all the above reasons the restore process is generally much slower than
581 backing up. 
582
583 \subsection*{Problems Restoring Files}
584 \index[general]{Files!Problems Restoring }
585 \index[general]{Problems Restoring Files }
586 \addcontentsline{toc}{subsection}{Problems Restoring Files}
587
588 The most frequent problems users have restoring files are error messages such
589 as: 
590
591 \footnotesize
592 \begin{verbatim}
593 04-Jan 00:33 z217-sd: RestoreFiles.2005-01-04_00.31.04 Error:
594 block.c:868 Volume data error at 20:0! Short block of 512 bytes on
595 device /dev/tape discarded.
596 \end{verbatim}
597 \normalsize
598
599 or 
600
601 \footnotesize
602 \begin{verbatim}
603 04-Jan 00:33 z217-sd: RestoreFiles.2005-01-04_00.31.04 Error:
604 block.c:264 Volume data error at 20:0! Wanted ID: "BB02", got ".".
605 Buffer discarded.
606 \end{verbatim}
607 \normalsize
608
609 Both these kinds of messages indicate that you were probably running your tape
610 drive in fixed block mode rather than variable block mode. Fixed block mode
611 will work with any program that reads tapes sequentially such as tar, but
612 Bacula repositions the tape on a block basis when restoring files because this
613 will speed up the restore by orders of magnitude when only a few files are being
614 restored. There are several ways that you can attempt to recover from this
615 unfortunate situation. 
616
617 Try the following things, each separately, and reset your Device resource to
618 what it is now after each individual test: 
619
620 \begin{enumerate}
621 \item Set ''Block Positioning = no`` in your Device resource  and try the
622    restore. This is a new directive and untested. 
623 \item Set ''Minimum Block Size = 512`` and ''Maximum  Block Size = 512`` and
624    try the restore. Again send me the  full job report output. If you are able to
625    determine the  block size your drive was previously using, you should try 
626 that size if 512 does not work. 
627 \item Try editing the restore.bsr file at the Run xxx yes/mod/no prompt 
628    before starting the restore job and remove all the VolBlock  statements. These
629    are what causes Bacula to reposition the tape,  and where problems occur if
630 you have a fixed block size set  for your drive. The VolFile commands also
631 cause repositioning,  but this will work regardless of the block size. 
632 \item Use bextract to extract the files you want -- it reads the  Volume
633    sequentially if you use the include list feature, or  if you use a .bsr file,
634    but remove all the VolBlock statements  after the .bsr file is created (at the
635 Run yes/mod/no) prompt but  before you start the restore. 
636 \end{enumerate}
637
638 \subsection*{Example Restore Job Resource}
639 \index[general]{Example Restore Job Resource }
640 \index[general]{Resource!Example Restore Job }
641 \addcontentsline{toc}{subsection}{Example Restore Job Resource}
642
643 \footnotesize
644 \begin{verbatim}
645 Job {
646   Name = "RestoreFiles"
647   Type = Restore
648   Client = Any-client
649   FileSet = "Any-FileSet"
650   Storage = Any-storage
651   Where = /tmp/bacula-restores
652   Messages = Standard
653   Pool = Default
654 }
655 \end{verbatim}
656 \normalsize
657
658 If {\bf Where} is not specified, the default location for restoring files will
659 be their original locations. 
660 \label{Selection}
661
662 \subsection*{File Selection Commands}
663 \index[general]{Commands!File Selection }
664 \index[general]{File Selection Commands }
665 \addcontentsline{toc}{subsection}{File Selection Commands}
666
667 After you have selected the Jobs to be restored and Bacula has created the
668 in-memory directory tree, you will enter file selection mode as indicated by
669 the dollar sign ({\bf \$}) prompt. While in this mode, you may use the
670 commands listed above. The basic idea is to move up and down the in memory
671 directory structure with the {\bf cd} command much as you normally do on the
672 system. Once you are in a directory, you may select the files that you want
673 restored. As a default no files are marked to be restored. If you wish to
674 start with all files, simply enter: {\bf cd /} and {\bf mark *}. Otherwise
675 proceed to select the files you wish to restore by marking them with the {\bf
676 mark} command. The available commands are: 
677
678 \begin{description}
679
680 \item [cd]
681    The {\bf cd} command changes the current directory to  the argument specified.
682    It operates much like the Unix {\bf cd} command.  Wildcard specifications are
683 not permitted.  
684
685 Note, on Windows systems, the various drives (c:, d:, ...) are treated  like a
686 directory within the file tree while in the file  selection mode. As a
687 consequence, you must do a {\bf cd c:} or  possibly in some cases a {\bf cd
688 C:} (note upper case)  to get down to the first directory.  
689
690 \item [dir]
691    \index[dir]{dir }
692    The {\bf dir} command is similar to the {\bf ls} command,  except that it
693 prints it in long format (all details). This command  can be a bit slower than
694 the {\bf ls} command because it must access  the catalog database for the
695 detailed information for each file.  
696
697 \item [estimate]
698    \index[dir]{estimate }
699    The {\bf estimate} command prints a summary of  the total files in the tree,
700 how many are marked to be restored, and  an estimate of the number of bytes to
701 be restored. This can be useful  if you are short on disk space on the machine
702 where the files will be  restored.  
703
704 \item [find]
705    \index[dir]{find }
706    The {\bf find} command accepts one or more arguments  and displays all files
707 in the tree that match that argument. The argument  may have wildcards. It is
708 somewhat similar to the Unix command  {\bf find / -name arg}.  
709
710 \item [ls]
711    The {\bf ls} command produces a listing of all the files  contained in the
712    current directory much like the Unix {\bf ls} command.  You may specify an
713 argument containing wildcards, in which case only  those files will be listed.
714 Any file that is marked to be restored will  have its name preceded by an
715 asterisk ({\bf *}). Directory names  will be terminated with a forward slash
716 ({\bf /}) to distinguish them  from filenames.  
717
718 \item [lsmark]
719    \index[fd]{lsmark }
720    The {\bf lsmark} command is the same as the  {\bf ls} except that it will
721 print only those files marked for  extraction. The other distinction is that
722 it will recursively  descend into any directory selected. 
723
724 \item [mark]
725    \index[dir]{mark }
726    The {\bf mark} command allows you to mark files  to be restored. It takes a
727 single argument which is the filename  or directory name in the current
728 directory to be marked for extraction.  The argument may be a wildcard
729 specification, in which  case all files that match in the current directory
730 are marked to be  restored. If the argument matches a directory rather than a
731 file,  then the directory and all the files contained in that directory
732 (recursively)  are marked to be restored. Any marked file will have its name 
733 preceded with an asterisk ({\bf *}) in the output produced by the  {\bf ls} or
734 {\bf dir} commands. Note, supplying a full path on  the mark command does not
735 work as expected to select a file or  directory in the current directory.
736 Also, the {\bf mark} command works  on the current and lower directories but
737 does not touch higher level  directories.  
738
739 After executing the {\bf mark} command, it will print a brief summary:  
740
741 \footnotesize
742 \begin{verbatim}
743     No files marked.
744     
745 \end{verbatim}
746 \normalsize
747
748 If no files were marked, or:  
749
750 \footnotesize
751 \begin{verbatim}
752     nn files marked.
753     
754 \end{verbatim}
755 \normalsize
756
757 if some files are marked.  
758
759 \item [unmark]
760    \index[dir]{unmark }
761    The {\bf unmark} is identical to the {\bf mark}  command, except that it
762 unmarks the specified file or files so that  they will not be restored. Note:
763 the {\bf unmark} command works from  the current directory, so it does not
764 unmark any files at a higher  level. First do a {\bf cd /} before the {\bf
765 unmark *} command if  you want to unmark everything.  
766
767 \item [pwd]
768    \index[dir]{pwd }
769    The {\bf pwd} command prints the current working  directory. It accepts no
770 arguments.  
771
772 \item [count]
773    \index[dir]{count }
774    The {\bf count} command prints the total files in the  directory tree and the
775 number of files marked to be restored.  
776
777 \item [done]
778    \index[dir]{done }
779    This command terminates file selection mode.  
780
781 \item [exit]
782    \index[fd]{exit }
783    This command terminates file selection mode (the same as  done).  
784
785 \item [quit]
786    \index[fd]{quit }
787    This command terminates the file selection and does  not run the restore job. 
788
789
790 \item [help]
791    \index[fd]{help }
792    This command prints a summary of the commands available.  
793
794 \item [?]
795    This command is the same as the {\bf help} command.  
796    \end{description}