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}
11 \index[general]{General }
12 \addcontentsline{toc}{subsection}{General}
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.
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, Bacula will
31 automatically set them for you.
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 By default, Bacula will restore data to the same Client that was backed
41 up, and those data will be restored not to the original places but to
42 {\bf /tmp/bacula-restores}. You may modify any of these defaults when the
43 restore command prompts you to run the job by selecting the {\bf mod}
47 \subsection*{The Restore Command}
48 \index[general]{Command!Restore }
49 \index[general]{Restore Command }
50 \addcontentsline{toc}{subsection}{Restore Command}
52 Since Bacula maintains a catalog of your files and on which Volumes (disk or
53 tape), they are stored, it can do most of the bookkeeping work, allowing you
54 simply to specify what kind of restore you want (current, before a particular
55 date), and what files to restore. Bacula will then do the rest.
57 This is accomplished using the {\bf restore} command in the Console. First you
58 select the kind of restore you want, then the JobIds are selected,
59 the File records for those Jobs are placed in an internal Bacula directory
60 tree, and the restore enters a file selection mode that allows you to
61 interactively walk up and down the file tree selecting individual files to be
62 restored. This mode is somewhat similar to the standard Unix {\bf restore}
63 program's interactive file selection mode.
65 If your Files have been pruned, the {\bf restore} command will be unable
66 to find any files to restore. See below for more details on this.
68 Within the Console program, after entering the {\bf restore} command, you are
69 presented with the following selection prompt:
73 First you select one or more JobIds that contain files
74 to be restored. You will be presented several methods
75 of specifying the JobIds. Then you will be allowed to
76 select which files from those JobIds are to be restored.
77 To select the JobIds, you have the following choices:
78 1: List last 20 Jobs run
79 2: List Jobs where a given File is saved
80 3: Enter list of comma separated JobIds to select
81 4: Enter SQL list command
82 5: Select the most recent backup for a client
83 6: Select backup for a client before a specified time
84 7: Enter a list of files to restore
85 8: Enter a list of files to restore before a specified time
86 9: Find the JobIds of the most recent backup for a client
87 10: Find the JobIds for a backup for a client before a specified time
88 11: Enter a list of directories to restore for found JobIds
95 \item Item 1 will list the last 20 jobs run. If you find the Job you want,
96 you can then select item 3 and enter its JobId(s).
98 \item Item 2 will list all the Jobs where a specified file is saved. If you
99 find the Job you want, you can then select item 3 and enter the JobId.
101 \item Item 3 allows you the enter a list of comma separated JobIds whose
102 files will be put into the directory tree. You may then select which
103 files from those JobIds to restore.
105 \item Item 4 allows you to enter any arbitrary SQL command. This is probably
106 the most primitive way of finding the desired JobIds, but at the same time,
107 the most flexible. Once you have found the JobId(s), you can select item 3
110 \item Item 5 will automatically select the most recent Full backup and all
111 subsequent incremental and differential backups for a specified Client.
112 These are the Jobs and Files which, if reloaded, will restore your
113 system to the most current saved state. It automatically enters the
114 JobIds found into the directory tree. This is probably the most
115 convenient of all the above options to use if you wish to restore a
116 selected Client to its most recent state.
118 There are two important things to note. First, this automatic selection
119 will never select a job that failed (terminated with an error status).
120 If you have such a job and want to recover one or more files from it,
121 you will need to explicitly enter the JobId in item 3, then choose the
124 If some of the Jobs that are needed to do the restore have had their
125 File records pruned, the restore will be incomplete. Bacula currently
126 does not correctly detect this condition. You can however, check for
127 this by looking carefully at the list of Jobs that Bacula selects and
128 prints. If you find Jobs with the JobFiles column set to zero, when
129 files should have been backed up, then you should expect problems.
131 If all the File records have been pruned, Bacula will realize that there
132 are no file records in any of the JobIds chosen and will inform you. It
133 will then propose doing a full restore (non-selective) of those JobIds.
134 This is possible because Bacula still knows where the beginning of the
135 Job data is on the Volumes, even if it does not know where particular
138 \item Item 6 allows you to specify a date and time, after which Bacula will
139 automatically select the most recent Full backup and all subsequent
140 incremental and differential backups that started before the specified date
143 \item Item 7 allows you to specify one or more filenames (complete path
144 required) to be restored. Each filename is entered one at a time or if you
145 prefix a filename with the less-than symbol (\lt{}) Bacula will read that
146 file and assume it is a list of filenames to be restored. The filename entry
147 mode is terminated by entering a blank line.
149 \item Item 8 allows you to specify a date and time before entering the
150 filenames. See Item 7 above for more details.
152 \item Item 9 allows you find the JobIds of the most recent backup for
153 a client. This is much like option 5 (it uses the same code), but
154 those JobIds are retained internally as if you had entered them
155 manually. You may then select item 11 (see below) to restore one
158 \item Item 10 is the same as item 9, except that it allows you to enter
159 a before date (as with item 6). These JobIds will then be retained
162 \index[general]{Restore Directories}
163 \item Item 11 allows you to enter a list of JobIds from which you can
164 select directories to be restored. The list of JobIds can have been
165 previously created by using either item 9 or 10 on the menu. You
166 may then enter a full path to a directory name or a filename preceded
167 by a less than sign (\lt{}). The filename should contain a list
168 of directories to be restored. All files in those directories will
169 be restored, but if the directory contains subdirectories, nothing
170 will be restored in the subdirectory unless you explicitly enter its
173 \item Item 12 allows you to cancel the restore command.
176 As an example, suppose that we select item 5 (restore to most recent state).
177 It will then ask for the desired Client, which on my system, will print all
178 the Clients found in the database as follows:
192 Select Client (File daemon) resource (1-9):
197 You will probably have far fewer Clients than this example, and if you have
198 only one Client, it will be automatically selected. In this case, I enter
199 {\bf Rufus} to select the Client. Then Bacula needs to know what FileSet is
200 to be restored, so it prompts with:
204 The defined FileSet resources are:
207 Select FileSet resource (1-2):
212 I choose item 1, which is my full backup. Normally, you will only have a
213 single FileSet for each Job, and if your machines are similar (all Linux) you
214 may only have one FileSet for all your Clients.
216 At this point, {\bf Bacula} has all the information it needs to find the most
217 recent set of backups. It will then query the database, which may take a bit
218 of time, and it will come up with something like the following. Note, some of
219 the columns are truncated here for presentation:
223 +-------+------+----------+-------------+-------------+------+-------+----------
225 | JobId | Levl | JobFiles | StartTime | VolumeName | File | SesId |
227 +-------+------+----------+-------------+-------------+------+-------+----------
229 | 1,792 | F | 128,374 | 08-03 01:58 | DLT-19Jul02 | 67 | 18 |
231 | 1,792 | F | 128,374 | 08-03 01:58 | DLT-04Aug02 | 0 | 18 |
233 | 1,797 | I | 254 | 08-04 13:53 | DLT-04Aug02 | 5 | 23 |
235 | 1,798 | I | 15 | 08-05 01:05 | DLT-04Aug02 | 6 | 24 |
237 +-------+------+----------+-------------+-------------+------+-------+----------
239 You have selected the following JobId: 1792,1792,1797
240 Building directory tree for JobId 1792 ...
241 Building directory tree for JobId 1797 ...
242 Building directory tree for JobId 1798 ...
248 Depending on the number of {\bf JobFiles} for each JobId, the {\bf Building
249 directory tree ..."} can take a bit of time. If you notice ath all the
250 JobFiles are zero, your Files have probably been pruned and you will not be
251 able to select any individual files -- it will be restore everything or
254 In our example, Bacula found four Jobs that comprise the most recent backup of
255 the specified Client and FileSet. Two of the Jobs have the same JobId because
256 that Job wrote on two different Volumes. The third Job was an incremental
257 backup to the previous Full backup, and it only saved 254 Files compared to
258 128,374 for the Full backup. The fourth Job was also an incremental backup
261 Next Bacula entered those Jobs into the directory tree, with no files marked
262 to be restored as a default, tells you how many files are in the tree, and
263 tells you that the current working directory ({\bf cwd}) is /. Finally, Bacula
264 prompts with the dollar sign (\$) to indicate that you may enter commands to
265 move around the directory tree and to select files.
267 If you want all the files to automatically be marked when the directory
268 tree is built, enter the command {\bf restore all}.
270 Instead of choosing item 5 on the first menu (Select the most recent backup
271 for a client), if we had chosen item 3 (Enter list of JobIds to select) and we
272 had entered the JobIds {\bf 1792,1797,1798} we would have arrived at the same
275 One point to note, if you are manually entering JobIds, is that you must enter
276 them in the order they were run (generally in increasing JobId order). If you
277 enter them out of order and the same file was saved in two or more of the
278 Jobs, you may end up with an old version of that file (i.e. not the most
281 Directly entering the JobIds can also permit you to recover data from
282 a Job that wrote files to tape but that terminated with an error status.
284 While in file selection mode, you can enter {\bf help} or a question mark (?)
285 to produce a summary of the available commands:
291 cd change current directory
292 count count marked files in and below the cd
293 dir long list current directory, wildcards allowed
294 done leave file selection mode
295 estimate estimate restore size
296 exit same as done command
297 find find files, wildcards allowed
299 ls list current directory, wildcards allowed
300 lsmark list the marked files in and below the cd
301 mark mark dir/file to be restored recursively in dirs
302 markdir mark directory name to be restored (no files)
303 pwd print current working directory
304 unmark unmark dir/file to be restored recursively in dir
305 unmarkdir unmark directory name only no recursion
306 quit quit and do not do restore
311 As a default no files have been selected for restore (unless you
312 added {\bf all} to the command line. If you want to restore
313 everything, at this point, you should enter {\bf mark *}, and then {\bf done}
314 and {\bf Bacula} will write the bootstrap records to a file and request your
315 approval to start a restore job.
317 If you do not enter the above mentioned {\bf mark *} command, you will start
318 with an empty slate. Now you can simply start looking at the tree and {\bf
319 mark} particular files or directories you want restored. It is easy to make
320 a mistake in specifying a file to mark or unmark, and Bacula's error handling
321 is not perfect, so please check your work by using the {\bf ls} or {\bf dir}
322 commands to see what files are actually selected. Any selected file has its
323 name preceded by an asterisk.
325 To check what is marked or not marked, enter the {\bf count} command, which
330 128401 total files. 128401 marked to be restored.
335 Each of the above commands will be described in more detail in the next
336 section. We continue with the above example, having accepted to restore all
337 files as Bacula set by default. On entering the {\bf done} command, Bacula
342 Bootstrap records written to /home/kern/bacula/working/restore.bsr
343 The restore job will require the following Volumes:
347 128401 files selected to restore.
349 JobName: kernsrestore
350 Bootstrap: /home/kern/bacula/working/restore.bsr
351 Where: /tmp/bacula-restores
357 OK to run? (yes/mod/no):
362 Please examine each of the items very carefully to make sure that they are
363 correct. In particular, look at {\bf Where}, which tells you where in the
364 directory structure the files will be restored, and {\bf Client}, which
365 tells you which client will receive the files. Note that by default the
366 Client which will receive the files is the Client that was backed up.
367 These items will not always be completed with the correct values depending
368 on which of the restore options you chose. You can change any of these
369 default items by entering {\bf mod} and responding to the prompts.
371 The above assumes that you have defined a {\bf Restore} Job resource in your
372 Director's configuration file. Normally, you will only need one Restore Job
373 resource definition because by its nature, restoring is a manual operation,
374 and using the Console interface, you will be able to modify the Restore Job to
377 An example Restore Job resource definition is given below.
379 Returning to the above example, you should verify that the Client name is
380 correct before running the Job. However, you may want to modify some of the
381 parameters of the restore job. For example, in addition to checking the Client
382 it is wise to check that the Storage device chosen by Bacula is indeed
383 correct. Although the {\bf FileSet} is shown, it will be ignored in restore.
384 The restore will choose the files to be restored either by reading the {\bf
385 Bootstrap} file, or if not specified, it will restore all files associated
386 with the specified backup {\bf JobId} (i.e. the JobId of the Job that
387 originally backed up the files).
389 Finally before running the job, please note that the default location for
390 restoring files is {\bf not} their original locations, but rather the directory
391 {\bf /tmp/bacula-restores}. You can change this default by modifying your {\bf
392 bacula-dir.conf} file, or you can modify it using the {\bf mod} option. If you
393 want to restore the files to their original location, you must have {\bf
394 Where} set to nothing or to the root, i.e. {\bf /}.
396 If you now enter {\bf yes}, Bacula will run the restore Job. The Storage
397 daemon will first request Volume {\bf DLT-19Jul02} and after the appropriate
398 files have been restored from that volume, it will request Volume {\bf
401 \subsection*{Selecting Files by Filename}
402 \index[general]{Selecting Files by Filename }
403 \index[general]{Filename!Selecting Files by }
404 \addcontentsline{toc}{subsection}{Selecting Files by Filename}
406 If you have a small number of files to restore, and you know the filenames,
407 you can either put the list of filenames in a file to be read by Bacula, or
408 you can enter the names one at a time. The filenames must include the full
409 path and filename. No wild cards are used.
411 To enter the files, after the {\bf restore}, you select item number 7 from the
416 To select the JobIds, you have the following choices:
417 1: List last 20 Jobs run
418 2: List Jobs where a given File is saved
419 3: Enter list of comma separated JobIds to select
420 4: Enter SQL list command
421 5: Select the most recent backup for a client
422 6: Select backup for a client before a specified time
423 7: Enter a list of files to restore
424 8: Enter a list of files to restore before a specified time
425 9: Find the JobIds of the most recent backup for a client
426 10: Find the JobIds for a backup for a client before a specified time
427 11: Enter a list of directories to restore for found JobIds
433 which then prompts you for the client name:
441 Select the Client (1-3): 3
445 Of course, your client list will be different, and if you have only one
446 client, it will be automatically selected. And finally, Bacula requests you to
455 At this point, you can enter the full path and filename
459 Enter filename: /home/kern/bacula/k/Makefile.in
464 as you can see, it took the filename. If Bacula cannot find a copy of the
465 file, it prints the following:
469 Enter filename: junk filename
470 No database record found for: junk filename
475 If you want Bacula to read the filenames from a file, you simply precede the
476 filename with a less-than symbol (\lt{}). When you have entered all the
477 filenames, you enter a blank line, and Bacula will write the bootstrap file,
478 tells you what tapes will be used, and proposes a Restore job to be run:
483 Automatically selected Storage: DDS-4
484 Bootstrap records written to /home/kern/bacula/working/restore.bsr
485 The restore job will require the following Volumes:
488 1 file selected to restore.
490 JobName: kernsrestore
491 Bootstrap: /home/kern/bacula/working/restore.bsr
492 Where: /tmp/bacula-restores
497 When: 2003-09-11 10:20:53
499 OK to run? (yes/mod/no):
503 It is possible to automate the selection by file by putting your list of files
504 in say {\bf /tmp/file-list}, then using the following command:
508 restore client=Rufus file=</tmp/file-list
512 If in modifying the parameters for the Run Restore job, you find that Bacula
513 asks you to enter a Job number, this is because you have not yet specified
514 either a Job number or a Bootstrap file. Simply entering zero will allow you
515 to continue and to select another option to be modified.
516 \label{CommandArguments}
518 \subsection*{Command Line Arguments}
519 \index[general]{Arguments!Command Line }
520 \index[general]{Command Line Arguments }
521 \addcontentsline{toc}{subsection}{Command Line Arguments}
523 If all the above sounds complicated, you will probably agree that it really
524 isn't after trying it a few times. It is possible to do everything that was
525 shown above, with the exception of selecting the FileSet, by using command
526 line arguments with a single command by entering:
530 restore client=Rufus select current all done yes
534 The {\bf client=Rufus} specification will automatically select Rufus as the
535 client, the {\bf current} tells Bacula that you want to restore the system to
536 the most current state possible, and the {\bf yes} suppresses the final {\bf
537 yes/mod/no} prompt and simply runs the restore.
539 The full list of possible command line arguments are:
542 \item {\bf all} -- select all Files to be restored.
543 \item {\bf select} -- use the tree selection method.
544 \item {\bf done} -- do not prompt the user in tree mode.
545 \item {\bf current} -- automatically select the most current set of backups
546 for the specified client.
547 \item {\bf client=xxxx} -- select the specified client.
548 \item {\bf jobid=nnn} -- specify a JobId or comma separated list of JobIds to
550 \item {\bf before=YYYY-MM-DD HH:MM:SS} -- specify a date and time to which
551 the system should be restored. Only Jobs started before the specified
552 date/time will be selected, and as is the case for {\bf current} Bacula will
553 automatically find the most recent prior Full save and all Differential and
554 Incremental saves run before the date you specify. Note, this command is not
555 too user friendly in that you must specify the date/time exactly as shown.
556 \item {\bf file=filename} -- specify a filename to be restored. You must
557 specify the full path and filename. Prefixing the entry with a less-than
559 (\lt{}) will cause Bacula to assume that the filename is on your system and
560 contains a list of files to be restored. Bacula will thus read the list from
561 that file. Multiple file=xxx specifications may be specified on the command
563 \item {\bf jobid=nnn} -- specify a JobId to be restored.
564 \item {\bf pool=pool-name} -- specify a Pool name to be used for selection of
565 Volumes when specifying options 5 and 6 (restore current system, and restore
566 current system before given date). This permits you to have several Pools,
567 possibly one offsite, and to select the Pool to be used for restoring.
568 \item {\bf yes} -- automatically run the restore without prompting for
569 modifications (most useful in batch scripts).
572 \subsection*{Restoring Directory Attributes}
573 \index[general]{Attributes!Restoring Directory }
574 \index[general]{Restoring Directory Attributes }
575 \addcontentsline{toc}{subsection}{Restoring Directory Attributes}
577 Depending how you do the restore, you may or may not get the directory entries
578 back to their original state. Here are a few of the problems you can
579 encounter, and for same machine restores, how to avoid them.
582 \item You backed up on one machine and are restoring to another that is
583 either a different OS or doesn't have the same users/groups defined. Bacula
584 does the best it can in these situations.
585 \item You are restoring into a directory that is already created and has file
586 creation restrictions. Bacula tries to reset everything but without walking
587 up the full chain of directories and modifying them all during the restore,
588 which Bacula does and will not do, getting permissions back correctly in
590 situation depends to a large extent on your OS.
591 \item You selected one or more files in a directory, but did not select the
592 directory entry to be restored. In that case, if the directory is not on
594 Bacula simply creates the directory with some default attributes which may
595 not be the same as the original. If you do not select a directory and all
597 contents to be restored, you can still select items within the directory to
598 be restored by individually marking those files, but in that case, you
600 individually use the "markdir" command to select all higher level
601 directory entries (one at a time) to be restored if you want the directory
602 entries properly restored.
607 \subsection*{Restoring on Windows}
608 \index[general]{Restoring on Windows }
609 \index[general]{Windows!Restoring on }
610 \addcontentsline{toc}{subsection}{Restoring on Windows}
612 If you are restoring on WinNT/2K/XP systems, Bacula will restore the files
613 with the original ownerships and permissions as would be expected. This is
614 also true if you are restoring those files to an alternate directory (using
615 the Where option in restore). However, if the alternate directory does not
616 already exist, the Bacula File daemon (Client) will try to create it. In
617 some cases, it may not create the directories, and if it does since the
618 File daemon runs under the SYSTEM account, the directory will be created
619 with SYSTEM ownership and permissions. In this case, you may have problems
620 accessing the newly restored files.
622 To avoid this problem, you should create any alternate directory before doing
624 restore. Bacula will not change the ownership and permissions of the directory
625 if it is already created as long as it is not one of the directories being
626 restored (i.e. written to tape).
628 The default restore location is {\bf /tmp/bacula-restores/} and if you are
629 restoring from drive {\bf E:}, the default will be
630 {\bf /tmp/bacula-restores/e/}, so you should ensure that this directory
631 exists before doing the restore, or use the {\bf mod} option to
632 select a different {\bf where} directory that does exist.
634 Some users have experienced problems restoring files that participate in
635 the Active Directory. They also report that changing the userid under which
636 Bacula (bacula-fd.exe) runs, from SYSTEM to a Domain Admin userid, resolves
640 \subsection*{Restoring Files Can Be Slow}
641 \index[general]{Slow!Restoring Files Can Be }
642 \index[general]{Restoring Files Can Be Slow }
643 \addcontentsline{toc}{subsection}{Restoring Files Can Be Slow}
645 Restoring files is generally {\bf much} slower than backing them up for several
646 reasons. The first is that during a backup the tape is normally already
647 positioned and Bacula only needs to write. On the other hand, because restoring
648 files is done so rarely, Bacula keeps only the start file and block on the
649 tape for the whole job rather than on a file by file basis which would use
650 quite a lot of space in the catalog.
652 Bacula will forward space to the correct file mark on the tape for the Job,
653 then forward space to the correct block, and finally sequentially read each
654 record until it gets to the correct one(s) for the file or files you want to
655 restore. Once the desired files are restored, Bacula will stop reading the
658 Finally, instead of just reading a file for backup, during the restore, Bacula
659 must create the file, and the operating system must allocate disk space for
660 the file as Bacula is restoring it.
662 For all the above reasons the restore process is generally much slower than
663 backing up (sometimes it takes three times as long).
665 \subsection*{Problems Restoring Files}
666 \index[general]{Files!Problems Restoring }
667 \index[general]{Problems Restoring Files }
668 \addcontentsline{toc}{subsection}{Problems Restoring Files}
670 The most frequent problems users have restoring files are error messages such
675 04-Jan 00:33 z217-sd: RestoreFiles.2005-01-04_00.31.04 Error:
676 block.c:868 Volume data error at 20:0! Short block of 512 bytes on
677 device /dev/tape discarded.
685 04-Jan 00:33 z217-sd: RestoreFiles.2005-01-04_00.31.04 Error:
686 block.c:264 Volume data error at 20:0! Wanted ID: "BB02", got ".".
691 Both these kinds of messages indicate that you were probably running your tape
692 drive in fixed block mode rather than variable block mode. Fixed block mode
693 will work with any program that reads tapes sequentially such as tar, but
694 Bacula repositions the tape on a block basis when restoring files because this
695 will speed up the restore by orders of magnitude when only a few files are being
696 restored. There are several ways that you can attempt to recover from this
697 unfortunate situation.
699 Try the following things, each separately, and reset your Device resource to
700 what it is now after each individual test:
703 \item Set "Block Positioning = no" in your Device resource and try the
704 restore. This is a new directive and untested.
705 \item Set "Minimum Block Size = 512" and "Maximum Block Size = 512" and
706 try the restore. Again send me the full job report output. If you are able
708 determine the block size your drive was previously using, you should try
709 that size if 512 does not work.
710 \item Try editing the restore.bsr file at the Run xxx yes/mod/no prompt
711 before starting the restore job and remove all the VolBlock statements.
713 are what causes Bacula to reposition the tape, and where problems occur if
714 you have a fixed block size set for your drive. The VolFile commands also
715 cause repositioning, but this will work regardless of the block size.
716 \item Use bextract to extract the files you want -- it reads the Volume
717 sequentially if you use the include list feature, or if you use a .bsr file,
718 but remove all the VolBlock statements after the .bsr file is created (at
720 Run yes/mod/no) prompt but before you start the restore.
723 \subsection*{Example Restore Job Resource}
724 \index[general]{Example Restore Job Resource }
725 \index[general]{Resource!Example Restore Job }
726 \addcontentsline{toc}{subsection}{Example Restore Job Resource}
731 Name = "RestoreFiles"
734 FileSet = "Any-FileSet"
735 Storage = Any-storage
736 Where = /tmp/bacula-restores
743 If {\bf Where} is not specified, the default location for restoring files will
744 be their original locations.
747 \subsection*{File Selection Commands}
748 \index[general]{Commands!File Selection }
749 \index[general]{File Selection Commands }
750 \addcontentsline{toc}{subsection}{File Selection Commands}
752 After you have selected the Jobs to be restored and Bacula has created the
753 in-memory directory tree, you will enter file selection mode as indicated by
754 the dollar sign ({\bf \$}) prompt. While in this mode, you may use the
755 commands listed above. The basic idea is to move up and down the in memory
756 directory structure with the {\bf cd} command much as you normally do on the
757 system. Once you are in a directory, you may select the files that you want
758 restored. As a default no files are marked to be restored. If you wish to
759 start with all files, simply enter: {\bf cd /} and {\bf mark *}. Otherwise
760 proceed to select the files you wish to restore by marking them with the {\bf
761 mark} command. The available commands are:
766 The {\bf cd} command changes the current directory to the argument
768 It operates much like the Unix {\bf cd} command. Wildcard specifications are
771 Note, on Windows systems, the various drives (c:, d:, ...) are treated like
773 directory within the file tree while in the file selection mode. As a
774 consequence, you must do a {\bf cd c:} or possibly in some cases a {\bf cd
775 C:} (note upper case) to get down to the first directory.
779 The {\bf dir} command is similar to the {\bf ls} command, except that it
780 prints it in long format (all details). This command can be a bit slower
782 the {\bf ls} command because it must access the catalog database for the
783 detailed information for each file.
786 \index[dir]{estimate }
787 The {\bf estimate} command prints a summary of the total files in the tree,
788 how many are marked to be restored, and an estimate of the number of bytes
790 be restored. This can be useful if you are short on disk space on the
792 where the files will be restored.
796 The {\bf find} command accepts one or more arguments and displays all files
797 in the tree that match that argument. The argument may have wildcards. It is
798 somewhat similar to the Unix command {\bf find / -name arg}.
801 The {\bf ls} command produces a listing of all the files contained in the
802 current directory much like the Unix {\bf ls} command. You may specify an
803 argument containing wildcards, in which case only those files will be
805 Any file that is marked to be restored will have its name preceded by an
806 asterisk ({\bf *}). Directory names will be terminated with a forward slash
807 ({\bf /}) to distinguish them from filenames.
811 The {\bf lsmark} command is the same as the {\bf ls} except that it will
812 print only those files marked for extraction. The other distinction is that
813 it will recursively descend into any directory selected.
817 The {\bf mark} command allows you to mark files to be restored. It takes a
818 single argument which is the filename or directory name in the current
819 directory to be marked for extraction. The argument may be a wildcard
820 specification, in which case all files that match in the current directory
821 are marked to be restored. If the argument matches a directory rather than a
822 file, then the directory and all the files contained in that directory
823 (recursively) are marked to be restored. Any marked file will have its name
824 preceded with an asterisk ({\bf *}) in the output produced by the {\bf ls}
826 {\bf dir} commands. Note, supplying a full path on the mark command does not
827 work as expected to select a file or directory in the current directory.
828 Also, the {\bf mark} command works on the current and lower directories but
829 does not touch higher level directories.
831 After executing the {\bf mark} command, it will print a brief summary:
840 If no files were marked, or:
849 if some files are marked.
853 The {\bf unmark} is identical to the {\bf mark} command, except that it
854 unmarks the specified file or files so that they will not be restored. Note:
855 the {\bf unmark} command works from the current directory, so it does not
856 unmark any files at a higher level. First do a {\bf cd /} before the {\bf
857 unmark *} command if you want to unmark everything.
861 The {\bf pwd} command prints the current working directory. It accepts no
866 The {\bf count} command prints the total files in the directory tree and the
867 number of files marked to be restored.
871 This command terminates file selection mode.
875 This command terminates file selection mode (the same as done).
879 This command terminates the file selection and does not run the restore
885 This command prints a summary of the commands available.
888 This command is the same as the {\bf help} command.
891 \subsection*{Restoring When Things Go Wrong}
892 \index[general]{Restoring When Things Go Wrong }
893 \addcontentsline{toc}{subsection}{Restoring When Things Go Wrong}
895 This and the following sections will try to present a few of the kinds of
896 problems that can come up making restoring more difficult. I'll try to
897 provide a few ideas how to get out of these problem situations.
901 Your catalog has been damaged and Bacula either doesn't work or prints
904 For SQLite, use the vacuum command to try to fix the database. For either
905 MySQL or PostgreSQL, see the vendor's documentation. They have specific tools
906 that check and repair databases.
908 Assuming the above does not resolve the problem, you will need to restore
909 or rebuild your catalog.
911 How do I restore my catalog?
913 If you have backed up your database nightly (as you should) and you
914 have made a bootstrap file, you can immediately load back your
915 database (or the ASCII SQL output). Make a copy of your current
916 database, then re-initialize it, by running the following scripts:
921 After re-initializing the database, you should be able to run
922 Bacula. If you now try to use the restore command, it will not
923 work because the database will be empty. However, you can manually
924 run a restore job and specify your bootstrap file. You do so
925 by entering the {bf run} command in the console and selecting the
926 restore job. If you are using the default bacula-dir.conf, this
927 Job will be named {\bf RestoreFiles}. Most likely it will prompt
928 you with something such as:
932 JobName: RestoreFiles
933 Bootstrap: /home/kern/bacula/working/restore.bsr
934 Where: /tmp/bacula-restores
939 When: 2005-07-10 17:33:40
942 OK to run? (yes/mod/no):
945 A number of the items will be different in your case. What you want
946 to do is: to use the mod option to change the Bootstrap to point to
947 your saved bootstrap file; and to make sure all the other items
948 such as Client, Storage, Catalog, and Where are correct. The
949 FileSet is not used when you specify a bootstrap file.
950 Once you have set all the correct values, run the Job and
951 it will restore the backup of your database. You will then
952 need to follow the instructions for your database type to
953 recreate the database from the ASCII backup file.
957 If you did save your database but did not make a bootstrap file, then
958 recovering the database
959 is more difficult. You will probably need to use bextract to extract the
961 First you should locate the listing of the job report from the last catalog
962 backup. It has important information that will allow you to quickly find
963 your database file. For example, in the job report for the CatalogBackup
964 shown below, the critical items are the Volume name(s), the Volume Session Id
965 and the Volume Session Time. If you know those, you can easily restore your
970 22-Apr 10:22 HeadMan: Start Backup JobId 7510,
971 Job=CatalogBackup.2005-04-22_01.10.0
972 22-Apr 10:23 HeadMan: Bacula 1.37.14 (21Apr05): 22-Apr-2005 10:23:06
974 Job: CatalogBackup.2005-04-22_01.10.00
977 FileSet: "CatalogFile" 2003-04-10 01:24:01
980 Start time: 22-Apr-2005 10:21:00
981 End time: 22-Apr-2005 10:23:06
984 FD Bytes Written: 210,739,395
985 SD Bytes Written: 210,739,521
987 Software Compression: None
988 Volume name(s): DLT-22Apr05
989 Volume Session Id: 11
990 Volume Session Time: 1114075126
991 Last Volume Bytes: 1,428,240,465
992 Non-fatal FD errors: 0
994 FD termination status: OK
995 SD termination status: OK
996 Termination: Backup OK
1000 From the above information, you can manually create a bootstrap file,
1001 and then follow the instructions given above for restoring your database.
1002 A reconstructed bootstrap file for the above backup Job would look
1006 Volume="DLT-22Apr05"
1008 VolSessionTime=1114075126
1012 Where we have inserted the Volume name, Volume Session Id, and Volume Session
1014 correspond to the values in the job report. We've also used a FileIndex of
1016 which will always be the case providing that there was only one file
1017 backed up in the job.
1019 The disadvantage of this bootstrap file compared to what is created when you
1020 ask for one to be written, is that there is no File and Block specified, so
1021 the restore code must search all data in the Volume to find the requested
1022 file. A fully specified bootstrap file would have the File and Blocks
1027 Volume="DLT-22Apr05"
1029 VolSessionTime=1114075126
1036 You don't have a bootstrap file, and you don't have the Job report for
1037 the backup of your database, but you did backup the database, and you
1038 know the Volume to which it was backed up.
1041 Use {\bf bls} to indicate where it is on the tape. For example:
1045 ./bls -j -V DLT-22Apr05 /dev/nst0
1048 Might produce the following output:
1051 bls: butil.c:258 Using device: "/dev/nst0" for reading.
1052 21-Jul 18:34 bls: Ready to read from volume "DLT-22Apr05" on device "DLTDrive"
1054 Volume Record: File:blk=0:0 SessId=11 SessTime=1114075126 JobId=0 DataLen=164
1056 Begin Job Session Record: File:blk=118:0 SessId=11 SessTime=1114075126
1058 Job=CatalogBackup.2005-04-22_01.10.0 Date=22-Apr-2005 10:21:00 Level=F Type=B
1059 End Job Session Record: File:blk=118:4053 SessId=11 SessTime=1114075126
1061 Date=22-Apr-2005 10:23:06 Level=F Type=B Files=1 Bytes=210,739,395 Errors=0
1064 21-Jul 18:34 bls: End of Volume at file 201 on device "DLTDrive" (/dev/nst0),
1065 Volume "DLT-22Apr05"
1066 21-Jul 18:34 bls: End of all volumes.
1069 Of course, there will be many more records printed, but we have indicated
1070 the essential lines of output. From the information on the Begin Job and End
1071 Job Session Records, you can reconstruct a bootstrap file such as the one
1075 How can I find where a file is stored.
1077 Normally, it is not necessary, you just use the {\bf restore} command to
1079 most recently saved version (menu option 5), or a version saved before a given
1081 option 8). If you know the JobId of the job in which it was saved, you can
1083 option 3 to enter that JobId.
1085 If you would like to know the JobId where a file was saved, select restore
1089 You can also use the {\bf query} command to find information such as:
1095 2: List up to 20 places where a File is saved regardless of the directory:
1096 3: List where the most recent copies of a file are saved:
1097 4: List last 20 Full Backups for a Client:
1098 5: List all backups for a Client after a specified time
1099 6: List all backups for a Client
1100 7: List Volume Attributes for a selected Volume:
1101 8: List Volumes used by selected JobId:
1102 9: List Volumes to Restore All Files:
1103 10: List Pool Attributes for a selected Pool:
1104 11: List total files/bytes by Job:
1105 12: List total files/bytes by Volume:
1106 13: List Files for a selected JobId:
1107 14: List Jobs stored in a selected MediaId:
1108 15: List Jobs stored for a given Volume name:
1109 Choose a query (1-15):