Below, we will discuss restoring files with the Console {\bf restore} command,
which is the recommended way of doing restoring files. It is not possible
to restore files by automatically starting a job as you do with Backup,
-Verify, ... jobs. However, in addition to the console restore command,
+Verify, \ldots{} jobs. However, in addition to the console restore command,
there is a standalone program named {\bf bextract}, which also permits
restoring files. For more information on this program, please see the
-\ilink{Bacula Utility Programs}{bextract} chapter of this manual. We
+\bsysxrlink{bextract}{bextract}{utility}{command} in the \utilityman{}. We
don't particularly recommend the {\bf bextract} program because it
-lacks many of the features of the normal Bacula restore, such as the
+lacks many of the features of the normal Bacula restore, such as the
ability to restore Win32 files to Unix systems, and the ability to
restore access control lists (ACL). As a consequence, we recommend,
wherever possible to use Bacula itself for restores as described below.
which allows you to list the contents of your Volumes. Finally, if you
have an old Volume that is no longer in the catalog, you can restore the
catalog entries using the program named {\bf bscan}, documented in the same
-\ilink{Bacula Utility Programs}{bscan} chapter.
+\bsysxrlink{bscan}{bscan}{utility}{command} in the \utilityman{}.
In general, to restore a file or a set of files, you must run a {\bf restore}
job. That is a job with {\bf Type = Restore}. As a consequence, you will need
a predefined {\bf restore} job in your {\bf bacula-dir.conf} (Director's
-config) file. The exact parameters (Client, FileSet, ...) that you define are
+config) file. The exact parameters (Client, FileSet, \ldots{}) that you define are
not important as you can either modify them manually before running the job or
-if you use the {\bf restore} command, explained below, Bacula will
+if you use the {\bf restore} command, explained below, Bacula will
automatically set them for you. In fact, you can no longer simply run a restore
-job. You must use the restore command.
+job. You must use the restore command.
Since Bacula is a network backup program, you must be aware that when you
restore files, it is up to you to ensure that you or Bacula have selected the
{\bf Bacula} will quite willingly backup client A, and restore it by sending
the files to a different directory on client B. Normally, you will want to
avoid this, but assuming the operating systems are not too different in their
-file structures, this should work perfectly well, if so desired.
+file structures, this should work perfectly well, if so desired.
By default, Bacula will restore data to the same Client that was backed
up, and those data will be restored not to the original places but to
{\bf /tmp/bacula-restores}. You may modify any of these defaults when the
Since Bacula maintains a catalog of your files and on which Volumes (disk or
tape), they are stored, it can do most of the bookkeeping work, allowing you
simply to specify what kind of restore you want (current, before a particular
-date), and what files to restore. Bacula will then do the rest.
+date), and what files to restore. Bacula will then do the rest.
This is accomplished using the {\bf restore} command in the Console. First you
select the kind of restore you want, then the JobIds are selected,
tree, and the restore enters a file selection mode that allows you to
interactively walk up and down the file tree selecting individual files to be
restored. This mode is somewhat similar to the standard Unix {\bf restore}
-program's interactive file selection mode.
+program's interactive file selection mode.
If a Job's file records have been pruned from the catalog, the {\bf restore}
command will be unable to find any files to restore. Bacula will ask if you
option}{FileRegex} and below for more details on this.
Within the Console program, after entering the {\bf restore} command, you are
-presented with the following selection prompt:
+presented with the following selection prompt:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
11: Enter a list of directories to restore for found JobIds
12: Cancel
Select item: (1-12):
-\end{verbatim}
+\end{lstlisting}
\normalsize
There are a lot of options, and as a point of reference, most people will
want to slect item 5 (the most recent backup for a client). The details
of the above options are:
-\begin{itemize}
+\begin{bsysitemize}
\item Item 1 will list the last 20 jobs run. If you find the Job you want,
you can then select item 3 and enter its JobId(s).
\item Item 2 will list all the Jobs where a specified file is saved. If you
find the Job you want, you can then select item 3 and enter the JobId.
-\item Item 3 allows you the enter a list of comma separated JobIds whose
+\item Item 3 allows you the enter a list of comma separated JobIds whose
files will be put into the directory tree. You may then select which
files from those JobIds to restore. Normally, you would use this option
if you have a particular version of a file that you want to restore and
you know its JobId. The most common options (5 and 6) will not select
- a job that did not terminate normally, so if you know a file is
+ a job that did not terminate normally, so if you know a file is
backed up by a Job that failed (possibly because of a system crash), you
- can access it through this option by specifying the JobId.
+ can access it through this option by specifying the JobId.
\item Item 4 allows you to enter any arbitrary SQL command. This is
probably the most primitive way of finding the desired JobIds, but at
you will need to explicitly enter the JobId in item 3, then choose the
files to restore.
- If some of the Jobs that are needed to do the restore have had their
+ If some of the Jobs that are needed to do the restore have had their
File records pruned, the restore will be incomplete. Bacula currently
does not correctly detect this condition. You can however, check for
this by looking carefully at the list of Jobs that Bacula selects and
\item Item 6 allows you to specify a date and time, after which Bacula will
automatically select the most recent Full backup and all subsequent
incremental and differential backups that started before the specified date
- and time.
+ and time.
\item Item 7 allows you to specify one or more filenames (complete path
required) to be restored. Each filename is entered one at a time or if you
- prefix a filename with the less-than symbol (\lt{}) Bacula will read that
+ prefix a filename with the less-than symbol (\lt{}) Bacula will read that
file and assume it is a list of filenames to be restored. If you
prefix the filename with a question mark (?), then the filename will
be interpreted as an SQL table name, and Bacula will include the rows
of that table in the list to be restored. The table must contain the
- JobId in the first column and the FileIndex in the second column.
+ JobId in the first column and the FileIndex in the second column.
This table feature is intended for external programs that want to build
their own list of files to be restored.
The filename entry mode is terminated by entering a blank line.
will be restored in the subdirectory unless you explicitly enter its
name.
-\item Item 12 allows you to cancel the restore command.
-\end{itemize}
+\item Item 12 allows you to cancel the restore command.
+\end{bsysitemize}
As an example, suppose that we select item 5 (restore to most recent state).
If you have not specified a client=xxx on the command line, it
it will then ask for the desired Client, which on my system, will print all
-the Clients found in the database as follows:
+the Clients found in the database as follows:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Defined clients:
1: Rufus
2: Matou
8: RufusVerify
9: Watchdog
Select Client (File daemon) resource (1-9):
-\end{verbatim}
+\end{lstlisting}
\normalsize
You will probably have far fewer Clients than this example, and if you have
only one Client, it will be automatically selected. In this case, I enter
{\bf Rufus} to select the Client. Then Bacula needs to know what FileSet is
-to be restored, so it prompts with:
+to be restored, so it prompts with:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
The defined FileSet resources are:
1: Full Set
2: Other Files
Select FileSet resource (1-2):
-\end{verbatim}
+\end{lstlisting}
\normalsize
If you have only one FileSet defined for the Client, it will be selected
At this point, {\bf Bacula} has all the information it needs to find the most
recent set of backups. It will then query the database, which may take a bit
of time, and it will come up with something like the following. Note, some of
-the columns are truncated here for presentation:
+the columns are truncated here for presentation:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
+-------+------+----------+-------------+-------------+------+-------+------------+
| JobId | Levl | JobFiles | StartTime | VolumeName | File | SesId |VolSesTime |
+-------+------+----------+-------------+-------------+------+-------+------------+
Building directory tree for JobId 1798 ...
cwd is: /
$
-\end{verbatim}
+\end{lstlisting}
\normalsize
Depending on the number of {\bf JobFiles} for each JobId, the {\bf Building
-directory tree ..."} can take a bit of time. If you notice ath all the
+directory tree \ldots{}"} can take a bit of time. If you notice ath all the
JobFiles are zero, your Files have probably been pruned and you will not be
able to select any individual files -- it will be restore everything or
nothing.
that Job wrote on two different Volumes. The third Job was an incremental
backup to the previous Full backup, and it only saved 254 Files compared to
128,374 for the Full backup. The fourth Job was also an incremental backup
-that saved 15 files.
+that saved 15 files.
Next Bacula entered those Jobs into the directory tree, with no files marked
to be restored as a default, tells you how many files are in the tree, and
tells you that the current working directory ({\bf cwd}) is /. Finally, Bacula
prompts with the dollar sign (\$) to indicate that you may enter commands to
-move around the directory tree and to select files.
-
+move around the directory tree and to select files.
+
If you want all the files to automatically be marked when the directory
tree is built, you could have entered the command {\bf restore all}, or
at the \$ prompt, you can simply enter {\bf mark *}.
Instead of choosing item 5 on the first menu (Select the most recent backup
for a client), if we had chosen item 3 (Enter list of JobIds to select) and we
had entered the JobIds {\bf 1792,1797,1798} we would have arrived at the same
-point.
+point.
One point to note, if you are manually entering JobIds, is that you must enter
them in the order they were run (generally in increasing JobId order). If you
enter them out of order and the same file was saved in two or more of the
Jobs, you may end up with an old version of that file (i.e. not the most
-recent).
+recent).
Directly entering the JobIds can also permit you to recover data from
a Job that wrote files to tape but that terminated with an error status.
While in file selection mode, you can enter {\bf help} or a question mark (?)
-to produce a summary of the available commands:
+to produce a summary of the available commands:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Command Description
======= ===========
cd change current directory
unmarkdir unmark directory name only no recursion
quit quit and do not do restore
? print help
-\end{verbatim}
+\end{lstlisting}
\normalsize
As a default no files have been selected for restore (unless you
added {\bf all} to the command line. If you want to restore
everything, at this point, you should enter {\bf mark *}, and then {\bf done}
and {\bf Bacula} will write the bootstrap records to a file and request your
-approval to start a restore job.
+approval to start a restore job.
If you do not enter the above mentioned {\bf mark *} command, you will start
with an empty slate. Now you can simply start looking at the tree and {\bf
a mistake in specifying a file to mark or unmark, and Bacula's error handling
is not perfect, so please check your work by using the {\bf ls} or {\bf dir}
commands to see what files are actually selected. Any selected file has its
-name preceded by an asterisk.
+name preceded by an asterisk.
To check what is marked or not marked, enter the {\bf count} command, which
-displays:
+displays:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
128401 total files. 128401 marked to be restored.
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
Each of the above commands will be described in more detail in the next
section. We continue with the above example, having accepted to restore all
files as Bacula set by default. On entering the {\bf done} command, Bacula
-prints:
+prints:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Bootstrap records written to /home/kern/bacula/working/restore.bsr
-The job will require the following
+The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
Catalog: MyCatalog
Priority: 10
OK to run? (yes/mod/no):
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
Please examine each of the items very carefully to make sure that they are
Director's configuration file. Normally, you will only need one Restore Job
resource definition because by its nature, restoring is a manual operation,
and using the Console interface, you will be able to modify the Restore Job to
-do what you want.
+do what you want.
-An example Restore Job resource definition is given below.
+An example Restore Job resource definition is given below.
Returning to the above example, you should verify that the Client name is
correct before running the Job. However, you may want to modify some of the
The restore will choose the files to be restored either by reading the {\bf
Bootstrap} file, or if not specified, it will restore all files associated
with the specified backup {\bf JobId} (i.e. the JobId of the Job that
-originally backed up the files).
+originally backed up the files).
Finally before running the job, please note that the default location for
restoring files is {\bf not} their original locations, but rather the directory
{\bf /tmp/bacula-restores}. You can change this default by modifying your {\bf
bacula-dir.conf} file, or you can modify it using the {\bf mod} option. If you
want to restore the files to their original location, you must have {\bf
-Where} set to nothing or to the root, i.e. {\bf /}.
+Where} set to nothing or to the root, i.e. {\bf /}.
If you now enter {\bf yes}, Bacula will run the restore Job. The Storage
daemon will first request Volume {\bf DLT-19Jul02} and after the appropriate
files have been restored from that volume, it will request Volume {\bf
-DLT-04Aug02}.
+DLT-04Aug02}.
\subsection{Restore a pruned job using a pattern}
During a restore, if all File records are pruned from the catalog
With this new feature, Bacula will ask if you want to specify a Regex
expression for extracting only a part of the full backup.
-\begin{verbatim}
+\begin{lstlisting}
Building directory tree for JobId(s) 1,3 ...
There were no files inserted into the tree, so file selection
is not possible.Most likely your retention policy pruned the files
-
+
Do you want to restore all the files? (yes|no): no
-
+
Regexp matching files to restore? (empty to abort): /tmp/regress/(bin|tests)/
Bootstrap records written to /tmp/regress/working/zog4-dir.restore.1.bsr
-\end{verbatim}
+\end{lstlisting}
See also \ilink{FileRegex bsr option}{FileRegex} for more information.
If you have a small number of files to restore, and you know the filenames,
you can either put the list of filenames in a file to be read by Bacula, or
you can enter the names one at a time. The filenames must include the full
-path and filename. No wild cards are used.
+path and filename. No wild cards are used.
To enter the files, after the {\bf restore}, you select item number 7 from the
-prompt list:
+prompt list:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
To select the JobIds, you have the following choices:
1: List last 20 Jobs run
2: List Jobs where a given File is saved
11: Enter a list of directories to restore for found JobIds
12: Cancel
Select item: (1-12):
-\end{verbatim}
+\end{lstlisting}
\normalsize
-which then prompts you for the client name:
+which then prompts you for the client name:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Defined Clients:
1: Timmy
2: Tibs
3: Rufus
Select the Client (1-3): 3
-\end{verbatim}
+\end{lstlisting}
\normalsize
Of course, your client list will be different, and if you have only one
client, it will be automatically selected. And finally, Bacula requests you to
-enter a filename:
+enter a filename:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Enter filename:
-\end{verbatim}
+\end{lstlisting}
\normalsize
-At this point, you can enter the full path and filename
+At this point, you can enter the full path and filename
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Enter filename: /home/kern/bacula/k/Makefile.in
Enter filename:
-\end{verbatim}
+\end{lstlisting}
\normalsize
as you can see, it took the filename. If Bacula cannot find a copy of the
-file, it prints the following:
+file, it prints the following:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Enter filename: junk filename
No database record found for: junk filename
Enter filename:
-\end{verbatim}
+\end{lstlisting}
\normalsize
If you want Bacula to read the filenames from a file, you simply precede the
filename with a less-than symbol (\lt{}). When you have entered all the
filenames, you enter a blank line, and Bacula will write the bootstrap file,
-tells you what tapes will be used, and proposes a Restore job to be run:
+tells you what tapes will be used, and proposes a Restore job to be run:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Enter filename:
Automatically selected Storage: DDS-4
Bootstrap records written to /home/kern/bacula/working/restore.bsr
The restore job will require the following Volumes:
-
+
test1
1 file selected to restore.
Run Restore job
When: 2003-09-11 10:20:53
Priority: 10
OK to run? (yes/mod/no):
-\end{verbatim}
+\end{lstlisting}
\normalsize
It is possible to automate the selection by file by putting your list of files
-in say {\bf /tmp/file-list}, then using the following command:
+in say {\bf /tmp/file-list}, then using the following command:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
restore client=Rufus file=</tmp/file-list
-\end{verbatim}
+\end{lstlisting}
\normalsize
If in modifying the parameters for the Run Restore job, you find that Bacula
asks you to enter a Job number, this is because you have not yet specified
either a Job number or a Bootstrap file. Simply entering zero will allow you
-to continue and to select another option to be modified.
+to continue and to select another option to be modified.
\label{Replace}
\section{Replace Options}
-When restoring, you have the option to specify a Replace option. This
-directive determines the action to be taken when restoring a file or
-directory that already exists. This directive can be set by selecting
+When restoring, you have the option to specify a Replace option. This
+directive determines the action to be taken when restoring a file or
+directory that already exists. This directive can be set by selecting
the {\bf mod} option. You will be given a list of parameters to choose
from. Full details on this option can be found in the Job Resource section
of the Director documentation.
If all the above sounds complicated, you will probably agree that it really
isn't after trying it a few times. It is possible to do everything that was
shown above, with the exception of selecting the FileSet, by using command
-line arguments with a single command by entering:
+line arguments with a single command by entering:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
restore client=Rufus select current all done yes
-\end{verbatim}
+\end{lstlisting}
\normalsize
The {\bf client=Rufus} specification will automatically select Rufus as the
client, the {\bf current} tells Bacula that you want to restore the system to
the most current state possible, and the {\bf yes} suppresses the final {\bf
-yes/mod/no} prompt and simply runs the restore.
+yes/mod/no} prompt and simply runs the restore.
-The full list of possible command line arguments are:
+The full list of possible command line arguments are:
-\begin{itemize}
-\item {\bf all} -- select all Files to be restored.
-\item {\bf select} -- use the tree selection method.
-\item {\bf done} -- do not prompt the user in tree mode.
+\begin{bsysitemize}
+\item {\bf all} -- select all Files to be restored.
+\item {\bf select} -- use the tree selection method.
+\item {\bf done} -- do not prompt the user in tree mode.
\item {\bf current} -- automatically select the most current set of backups
- for the specified client.
+ for the specified client.
\item {\bf client=xxxx} -- initially specifies the client from which the
backup was made and the client to which the restore will be make. See also
"restoreclient" keyword.
\item {\bf restoreclient=xxxx} -- if the keyword is specified, then the
restore is written to that client.
\item {\bf jobid=nnn} -- specify a JobId or comma separated list of JobIds to
- be restored.
+ be restored.
\item {\bf before=YYYY-MM-DD HH:MM:SS} -- specify a date and time to which
the system should be restored. Only Jobs started before the specified
date/time will be selected, and as is the case for {\bf current} Bacula will
automatically find the most recent prior Full save and all Differential and
Incremental saves run before the date you specify. Note, this command is not
- too user friendly in that you must specify the date/time exactly as shown.
+ too user friendly in that you must specify the date/time exactly as shown.
\item {\bf file=filename} -- specify a filename to be restored. You must
specify the full path and filename. Prefixing the entry with a less-than
sign
(\lt{}) will cause Bacula to assume that the filename is on your system and
contains a list of files to be restored. Bacula will thus read the list from
that file. Multiple file=xxx specifications may be specified on the command
- line.
-\item {\bf jobid=nnn} -- specify a JobId to be restored.
+ line.
+\item {\bf jobid=nnn} -- specify a JobId to be restored.
\item {\bf pool=pool-name} -- specify a Pool name to be used for selection of
Volumes when specifying options 5 and 6 (restore current system, and restore
current system before given date). This permits you to have several Pools,
- possibly one offsite, and to select the Pool to be used for restoring.
+ possibly one offsite, and to select the Pool to be used for restoring.
\item {\bf where=/tmp/bacula-restore} -- restore files in {\bf where} directory.
\item {\bf yes} -- automatically run the restore without prompting for
- modifications (most useful in batch scripts).
+ modifications (most useful in batch scripts).
\item {\bf strip\_prefix=/prod} -- remove a part of the filename when restoring.
\item {\bf add\_prefix=/test} -- add a prefix to all files when restoring (like
where) (can't be used with {\bf where=}).
\item {\bf add\_suffix=.old} -- add a suffix to all your files.
\item {\bf regexwhere=!a.pdf!a.bkp.pdf!} -- do complex filename manipulation
like with sed unix command. Will overwrite other filename manipulation.
-\end{itemize}
+\end{bsysitemize}
\label{restorefilerelocation}
\section{Using File Relocation}
\texttt{/.snap/home/eric/mbox}, which can complicate restores. If you use
\textbf{where=/tmp}, the file will be restored to
\texttt{/tmp/.snap/home/eric/mbox} and you will have to move the file to
-\texttt{/home/eric/mbox.bkp} by hand.
+\texttt{/home/eric/mbox.bkp} by hand.
However, case, you could use the
\textbf{strip\_prefix=/.snap} and \textbf{add\_suffix=.bkp} options and
Bacula will restore the file to its original location -- that is
\texttt{/home/eric/mbox}.
-To use this feature, there are command line options as described in
+To use this feature, there are command line options as described in
the \ilink{restore section}{restorefilerelocation} of this manual;
you can modify your restore job before running it; or you can
-add options to your restore job in as described in
+add options to your restore job in as described in
\ilink{bacula-dir.conf}{confaddprefix}.
-\begin{verbatim}
+\begin{lstlisting}
Parameters to modify:
1: Level
2: Storage
4: Enter a regexp
5: Test filename manipulation
6: Use this ?
-Select parameter to modify (1-6):
-\end{verbatim}
+Select parameter to modify (1-6):
+\end{lstlisting}
-\subsection{RegexWhere Format}
+\subsection{RegexWhere Format}\label{useregexwhere}
The format is very close to that used by sed or Perl (\texttt{s/replace this/by
that/}) operator. A valid regexwhere expression has three fields :
-\begin{itemize}
+\begin{bsysitemize}
\item a search expression (with optionnal submatch)
\item a replacement expression (with optionnal back references \$1 to \$9)
\item a set of search options (only case-insensitive ``i'' at this time)
-\end{itemize}
+\end{bsysitemize}
Each field is delimited by a separator specified by the user as the first
character of the expression. The separator can be one of the following:
-\begin{verbatim}
+\begin{lstlisting}
<separator-keyword> = / ! ; % : , ~ # = &
-\end{verbatim}
+\end{lstlisting}
You can use several expressions separated by a commas.
\subsection*{Examples}
-\begin{tabular}{|c|c|c|l|}
-\hline
-Orignal filename & New filename & RegexWhere & Comments \\
-\hline
-\hline
-\texttt{c:/system.ini} & \texttt{c:/system.old.ini} & \texttt{/.ini\$/.old.ini/} & \$ matches end of name\\
-\hline
-\texttt{/prod/u01/pdata/} & \texttt{/rect/u01/rdata} & \texttt{/prod/rect/,/pdata/rdata/} & uses two regexp\\
-\hline
-\texttt{/prod/u01/pdata/} & \texttt{/rect/u01/rdata} & \texttt{!/prod/!/rect/!,/pdata/rdata/} & use \texttt{!} as separator\\
-\hline
-\texttt{C:/WINNT} & \texttt{d:/WINNT} & \texttt{/c:/d:/i} & case insensitive pattern match \\
-\hline
-
-\end{tabular}
+\LTXtable{0.95\linewidth}{table_regexp}
%\subsubsection{Using group}
%
-%Like with Perl or Sed, you can make submatch with \texttt{()},
+%Like with Perl or Sed, you can make submatch with \texttt{()},
%
%\subsubsection*{Examples}
Depending how you do the restore, you may or may not get the directory entries
back to their original state. Here are a few of the problems you can
-encounter, and for same machine restores, how to avoid them.
+encounter, and for same machine restores, how to avoid them.
-\begin{itemize}
-\item You backed up on one machine and are restoring to another that is
+\begin{bsysitemize}
+\item You backed up on one machine and are restoring to another that is
either a different OS or doesn't have the same users/groups defined. Bacula
does the best it can in these situations. Note, Bacula has saved the
user/groups in numeric form, which means on a different machine, they
\item The {\bf bextract} program does not restore access control lists
(ACLs) to Unix machines.
-\end{itemize}
+\end{bsysitemize}
\label{Windows}
\section{Restoring on Windows}
directories being restored (i.e. written to tape).
The default restore location is {\bf /tmp/bacula-restores/} and if you are
-restoring from drive {\bf E:}, the default will be
+restoring from drive {\bf E:}, the default will be
{\bf /tmp/bacula-restores/e/}, so you should ensure that this directory
exists before doing the restore, or use the {\bf mod} option to
select a different {\bf where} directory that does exist.
positioned and Bacula only needs to write. On the other hand, because restoring
files is done so rarely, Bacula keeps only the start file and block on the
tape for the whole job rather than on a file by file basis which would use
-quite a lot of space in the catalog.
+quite a lot of space in the catalog.
Bacula will forward space to the correct file mark on the tape for the Job,
then forward space to the correct block, and finally sequentially read each
record until it gets to the correct one(s) for the file or files you want to
restore. Once the desired files are restored, Bacula will stop reading the
-tape.
+tape.
Finally, instead of just reading a file for backup, during the restore, Bacula
must create the file, and the operating system must allocate disk space for
-the file as Bacula is restoring it.
+the file as Bacula is restoring it.
For all the above reasons the restore process is generally much slower than
backing up (sometimes it takes three times as long).
\index[general]{Problems Restoring Files }
The most frequent problems users have restoring files are error messages such
-as:
+as:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
04-Jan 00:33 z217-sd: RestoreFiles.2005-01-04_00.31.04 Error:
block.c:868 Volume data error at 20:0! Short block of 512 bytes on
device /dev/tape discarded.
-\end{verbatim}
+\end{lstlisting}
\normalsize
-or
+or
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
04-Jan 00:33 z217-sd: RestoreFiles.2005-01-04_00.31.04 Error:
block.c:264 Volume data error at 20:0! Wanted ID: "BB02", got ".".
Buffer discarded.
-\end{verbatim}
+\end{lstlisting}
\normalsize
Both these kinds of messages indicate that you were probably running your tape
Bacula repositions the tape on a block basis when restoring files because this
will speed up the restore by orders of magnitude when only a few files are being
restored. There are several ways that you can attempt to recover from this
-unfortunate situation.
+unfortunate situation.
Try the following things, each separately, and reset your Device resource to
-what it is now after each individual test:
+what it is now after each individual test:
\begin{enumerate}
\item Set "Block Positioning = no" in your Device resource and try the
- restore. This is a new directive and untested.
+ restore. This is a new directive and untested.
\item Set "Minimum Block Size = 512" and "Maximum Block Size = 512" and
try the restore. If you are able to determine the block size your drive
to continue backing up your data without correcting this condition.
Please see the Tape Testing chapter for more on this.
-\item Try editing the restore.bsr file at the Run xxx yes/mod/no prompt
+\item Try editing the restore.bsr file at the Run xxx yes/mod/no prompt
before starting the restore job and remove all the VolBlock statements.
These are what causes Bacula to reposition the tape, and where problems
occur if you have a fixed block size set for your drive. The VolFile
\item [file count mismatch]
This can occur for the following reasons:
- \begin{itemize}
+ \begin{bsysitemize}
\item You requested Bacula not to overwrite existing or newer
files.
\item A Bacula miscount of files/directories. This is an
on-going problem due to the complications of directories,
soft/hard link, and such. Simply check that all the files you
wanted were actually restored.
- \end{itemize}
+ \end{bsysitemize}
\item [file size error]
When Bacula restores files, it checks that the size of the
- restored file is the same as the file status data it saved
+ restored file is the same as the file status data it saved
when starting the backup of the file. If the sizes do not
agree, Bacula will print an error message. This size mismatch
most often occurs because the file was being written as Bacula
\index[general]{Resource!Example Restore Job }
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Job {
Name = "RestoreFiles"
Type = Restore
Messages = Standard
Pool = Default
}
-\end{verbatim}
+\end{lstlisting}
\normalsize
If {\bf Where} is not specified, the default location for restoring files will
-be their original locations.
+be their original locations.
\label{Selection}
\section{File Selection Commands}
restored. As a default no files are marked to be restored. If you wish to
start with all files, simply enter: {\bf cd /} and {\bf mark *}. Otherwise
proceed to select the files you wish to restore by marking them with the {\bf
-mark} command. The available commands are:
+mark} command. The available commands are:
\begin{description}
It operates much like the Unix {\bf cd} command. Wildcard specifications are
not permitted.
- Note, on Windows systems, the various drives (c:, d:, ...) are treated like a
+ Note, on Windows systems, the various drives (c:, d:, \ldots{}) are treated like a
directory within the file tree while in the file selection mode. As a
consequence, you must do a {\bf cd c:} or possibly in some cases a {\bf cd
C:} (note upper case) to get down to the first directory.
\index[dir]{find}
The {\bf find} command accepts one or more arguments and displays all files
in the tree that match that argument. The argument may have wildcards. It is
- somewhat similar to the Unix command {\bf find / -name arg}.
+ somewhat similar to the Unix command {\bf find / -name arg}.
\item [ls]
The {\bf ls} command produces a listing of all the files contained in the
Any file that is marked to be restored will have its name preceded by an
asterisk ({\bf *}). Directory names will be terminated with a forward slash
- ({\bf /}) to distinguish them from filenames.
+ ({\bf /}) to distinguish them from filenames.
\item [lsmark]
\index[fd]{lsmark}
The {\bf lsmark} command is the same as the {\bf ls} except that it will
print only those files marked for extraction. The other distinction is that
- it will recursively descend into any directory selected.
+ it will recursively descend into any directory selected.
\item [mark]
\index[dir]{mark}
specification, in which case all files that match in the current directory
are marked to be restored. If the argument matches a directory rather than a
file, then the directory and all the files contained in that directory
- (recursively) are marked to be restored. Any marked file will have its name
+ (recursively) are marked to be restored. Any marked file will have its name
preceded with an asterisk ({\bf *}) in the output produced by the {\bf ls}
or
{\bf dir} commands. Note, supplying a full path on the mark command does not
work as expected to select a file or directory in the current directory.
Also, the {\bf mark} command works on the current and lower directories but
- does not touch higher level directories.
+ does not touch higher level directories.
- After executing the {\bf mark} command, it will print a brief summary:
+ After executing the {\bf mark} command, it will print a brief summary:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
No files marked.
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
- If no files were marked, or:
+ If no files were marked, or:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
nn files marked.
-
-\end{verbatim}
+
+\end{lstlisting}
\normalsize
- if some files are marked.
+ if some files are marked.
\item [unmark]
\index[dir]{unmark }
unmarks the specified file or files so that they will not be restored. Note:
the {\bf unmark} command works from the current directory, so it does not
unmark any files at a higher level. First do a {\bf cd /} before the {\bf
- unmark *} command if you want to unmark everything.
+ unmark *} command if you want to unmark everything.
\item [pwd]
\index[dir]{pwd }
The {\bf pwd} command prints the current working directory. It accepts no
- arguments.
+ arguments.
\item [count]
\index[dir]{count }
The {\bf count} command prints the total files in the directory tree and the
- number of files marked to be restored.
+ number of files marked to be restored.
\item [done]
\index[dir]{done }
- This command terminates file selection mode.
+ This command terminates file selection mode.
\item [exit]
\index[fd]{exit }
- This command terminates file selection mode (the same as done).
+ This command terminates file selection mode (the same as done).
\item [quit]
\index[fd]{quit }
This command terminates the file selection and does not run the restore
-job.
+job.
\item [help]
\index[fd]{help }
- This command prints a summary of the commands available.
+ This command prints a summary of the commands available.
\item [?]
- This command is the same as the {\bf help} command.
+ This command is the same as the {\bf help} command.
\end{description}
+If your filename contains some weird caracters, you can use \texttt{?},
+\texttt{*} or \textbackslash{}\textbackslash{}. For example, if your filename
+contains a \textbackslash{}, you can use
+\textbackslash{}\textbackslash{}\textbackslash{}\textbackslash{}.
+
+\begin{lstlisting}
+* mark weird_file\\\\with-backslash
+\end{lstlisting}
+
\label{database_restore}
\section{Restoring When Things Go Wrong}
\index[general]{Restoring When Things Go Wrong }
For SQLite, use the vacuum command to try to fix the database. For either
MySQL or PostgreSQL, see the vendor's documentation. They have specific tools
that check and repair databases, see the \ilink{database
- repair}{DatabaseRepair} sections of this manual for links to vendor
+ repair}{DatabaseRepair} sections of this manual for links to vendor
information.
Assuming the above does not resolve the problem, you will need to restore
or rebuild your catalog. Note, if it is a matter of some
inconsistencies in the Bacula tables rather than a broken database, then
- running \ilink{dbcheck}{dbcheck} might help, but you will need to ensure
+ running the \bsysxrlink{dbcheck}{dbcheck}{utility}{command}\footnote{\utilityman{}}
+might help, but you will need to ensure
that your database indexes are properly setup. Please see
the \ilink{Database Performance Issues}{DatabasePerformance} sections
of this manual for more details.
have made a bootstrap file, you can immediately load back your
database (or the ASCII SQL output). Make a copy of your current
database, then re-initialize it, by running the following scripts:
-\begin{verbatim}
+\begin{lstlisting}
./drop_bacula_tables
./make_bacula_tables
-\end{verbatim}
- After re-initializing the database, you should be able to run
- Bacula. If you now try to use the restore command, it will not
+\end{lstlisting}
+ After re-initializing the database, you should be able to run
+ Bacula. If you now try to use the restore command, it will not
work because the database will be empty. However, you can manually
run a restore job and specify your bootstrap file. You do so
by entering the {bf run} command in the console and selecting the
you with something such as:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Run Restore job
JobName: RestoreFiles
Bootstrap: /home/kern/bacula/working/restore.bsr
When: 2005-07-10 17:33:40
Catalog: MyCatalog
Priority: 10
-OK to run? (yes/mod/no):
-\end{verbatim}
+OK to run? (yes/mod/no):
+\end{lstlisting}
\normalsize
A number of the items will be different in your case. What you want to
Client, Storage, Catalog, and Where are correct. The FileSet is not
used when you specify a bootstrap file. Once you have set all the
correct values, run the Job and it will restore the backup of your
- database, which is most likely an ASCII dump.
+ database, which is most likely an ASCII dump.
You will then need to follow the instructions for your
database type to recreate the database from the ASCII backup file.
See the \ilink {Catalog Maintenance}{CatMaintenanceChapter} chapter of
- this manual for examples of the command needed to restore a
+ this manual for examples of the command needed to restore a
database from an ASCII dump (they are shown in the Compacting Your
XXX Database sections).
-
+
Also, please note that after you restore your database from an ASCII
backup, you do NOT want to do a {\bf make\_bacula\_tables} command, or
you will probably erase your newly restored database tables.
-
+
\item[Solution with a Job listing]
If you did save your database but did not make a bootstrap file, then
recovering the database is more difficult. You will probably need to
Catalog.
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
22-Apr 10:22 HeadMan: Start Backup JobId 7510,
Job=CatalogBackup.2005-04-22_01.10.0
22-Apr 10:23 HeadMan: Bacula 1.37.14 (21Apr05): 22-Apr-2005 10:23:06
FD termination status: OK
SD termination status: OK
Termination: Backup OK
-\end{verbatim}
+\end{lstlisting}
\normalsize
From the above information, you can manually create a bootstrap file,
like the following:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Volume="DLT-22Apr05"
VolSessionId=11
VolSessionTime=1114075126
FileIndex=1-1
-\end{verbatim}
-\normalsize
+\end{lstlisting}
+\normalsize
Where we have inserted the Volume name, Volume Session Id, and Volume
Session Time that correspond to the values in the job report. We've also
used a FileIndex of one, which will always be the case providing that
there was only one file backed up in the job.
-
+
The disadvantage of this bootstrap file compared to what is created when
you ask for one to be written, is that there is no File and Block
specified, so the restore code must search all data in the Volume to find
and Blocks specified as follows:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
Volume="DLT-22Apr05"
VolSessionId=11
VolSessionTime=1114075126
VolFile=118-118
VolBlock=0-4053
FileIndex=1-1
-\end{verbatim}
+\end{lstlisting}
\normalsize
Once you have restored the ASCII dump of the database,
you will then to follow the instructions for your
database type to recreate the database from the ASCII backup file.
See the \ilink {Catalog Maintenance}{CatMaintenanceChapter} chapter of
- this manual for examples of the command needed to restore a
+ this manual for examples of the command needed to restore a
database from an ASCII dump (they are shown in the Compacting Your
XXX Database sections).
-
+
Also, please note that after you restore your database from an ASCII
backup, you do NOT want to do a {\bf make\_bacula\_tables} command, or
you will probably erase your newly restored database tables.
\item [Solution without a Job Listing]
If you do not have a job listing, then it is a bit more difficult.
- Either you use the \ilink{bscan}{bscan} program to scan the contents
- of your tape into a database, which can be very time consuming
- depending on the size of the tape, or you can use the \ilink{bls}{bls}
- program to list everything on the tape, and reconstruct a bootstrap
- file from the bls listing for the file or files you want following
+ Either you use the \bsysxrlink{bscan}{bscan}{utility}{program} to scan the contents
+ of your tape into a database, which can be very time consuming
+ depending on the size of the tape, or you can use the \bsysxrlink{bls}{bls}
+ {utility}{program} to list everything on the tape, and reconstruct a
+ bootstrap file from the bls listing for the file or files you want following
the instructions given above.
There is a specific example of how to use {\bf bls} below.
\item [Problem]
I try to restore the last known good full backup by specifying
- item 3 on the restore menu then the JobId to restore. Bacula
+ item 3 on the restore menu then the JobId to restore. Bacula
then reports:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
1 Job 0 Files
-\end{verbatim}
+\end{lstlisting}
\normalsize
and restores nothing.
important information about the job:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
llist jobid=120
JobId: 120
Job: save.2005-12-05_18.27.33
Pool.Name: Full
Job.FileSetId: 1
FileSet.FileSet: BackupSet
-\end{verbatim}
+\end{lstlisting}
\normalsize
Then you can find the Volume(s) used by doing:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
sql
select VolumeName from JobMedia,Media where JobId=1 and JobMedia.MediaId=Media.MediaId;
-\end{verbatim}
+\end{lstlisting}
\normalsize
Finally, you can create a bootstrap file as described in the previous
You don't have a bootstrap file, and you don't have the Job report for
the backup of your database, but you did backup the database, and you
know the Volume to which it was backed up.
-
+
\item [Solution]
Either bscan the tape (see below for bscanning), or better use {\bf bls}
- to find where it is on the tape, then use {\bf bextract} to
+ to find where it is on the tape, then use {\bf bextract} to
restore the database. For example,
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
./bls -j -V DLT-22Apr05 /dev/nst0
-\end{verbatim}
+\end{lstlisting}
\normalsize
Might produce the following output:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
bls: butil.c:258 Using device: "/dev/nst0" for reading.
21-Jul 18:34 bls: Ready to read from volume "DLT-22Apr05" on device "DLTDrive"
(/dev/nst0).
21-Jul 18:34 bls: End of Volume at file 201 on device "DLTDrive" (/dev/nst0),
Volume "DLT-22Apr05"
21-Jul 18:34 bls: End of all volumes.
-\end{verbatim}
+\end{lstlisting}
\normalsize
Of course, there will be many more records printed, but we have indicated
- the essential lines of output. From the information on the Begin Job and End
+ the essential lines of output. From the information on the Begin Job and End
Job Session Records, you can reconstruct a bootstrap file such as the one
shown above.
If you would like to know the JobId where a file was saved, select
restore menu option 2.
- You can also use the {\bf query} command to find information such as:
+ You can also use the {\bf query} command to find information such as:
\footnotesize
-\begin{verbatim}
+\begin{lstlisting}
*query
Available queries:
1: List up to 20 places where a File is saved regardless of the
15: List Volumes Bacula thinks are in changer
16: List Volumes likely to need replacement from age or errors
Choose a query (1-16):
-\end{verbatim}
+\end{lstlisting}
\normalsize
\item[Problem]
\end{enumerate}
When the above is complete, you can begin bscanning your Volumes. Please
-see the \ilink{bscan}{bscan} section of the Volume Utility Tools of this
-chapter for more details.
+see the \bsysxrlink{bscan}{bscan}{utility}{section} of the \utilityman{}.
\end{description}