]> git.sur5r.net Git - bacula/docs/blobdiff - docs/manual/restore.tex
Update
[bacula/docs] / docs / manual / restore.tex
index 79487cf9f275ffc971d8cb139728d76861057352..4085e7748516a7c34545b1bd521a20bd9ca8fbb2 100644 (file)
@@ -582,25 +582,38 @@ 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 
    either a different OS or doesn't have the same users/groups defined.  Bacula
-   does the best it can in these situations.  
-\item You are restoring into a directory that is already created and has  file
-   creation restrictions. Bacula tries to reset everything  but without walking
-   up the full chain of directories and modifying  them all during the restore,
-   which Bacula does and will not do,  getting permissions back correctly in
-this
-   situation depends to a  large extent on your OS.  
-\item You selected one or more files in a directory, but did not select  the
-   directory entry to be restored. In that case, if the directory  is not on
-disk
-   Bacula simply creates the directory with some default  attributes which may
-   not be the same as the original.  If you do not select a directory and all
-its
-   contents to be restored,  you can still select items within the directory to
-   be restored by  individually marking those files, but in that case, you
-should
-   individually use the "markdir" command to select all higher level 
-   directory entries (one at a time) to be restored if you want the  directory
-   entries properly restored. 
+   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
+   may map to different user/group names.
+\item You are restoring into a directory that is already created and has
+   file creation restrictions.  Bacula tries to reset everything but
+   without walking up the full chain of directories and modifying them all
+   during the restore, which Bacula does and will not do, getting
+   permissions back correctly in this situation depends to a large extent
+   on your OS.
+\item You are doing a recursive restore of a directory tree.  In this case
+   Bacula will restore a file before restoring the file's parent directory
+   entry.  In the process of restoring the file Bacula will create the
+   parent directory with open permissions and ownership of the file being
+   restored.  Then when Bacula tries to restore the parent directory Bacula
+   sees that it already exists (Similar to the previous situation).  If you
+   had set the Restore job's "Replace" property to "never" then Bacula will
+   not change the directory's permissions and ownerships to match what it
+   backed up, you should also notice that the actual number of files
+   restored is less then the expected number.  If you had set the Restore
+   job's "Replace" property to "always" then Bacula will change the
+   Directory's ownership and permissions to match what it backed up, also
+   the actual number of files restored should be equal to the expected
+   number.
+\item You selected one or more files in a directory, but did not select the
+   directory entry to be restored.  In that case, if the directory is not
+   on disk Bacula simply creates the directory with some default attributes
+   which may not be the same as the original.  If you do not select a
+   directory and all its contents to be restored, you can still select
+   items within the directory to be restored by individually marking those
+   files, but in that case, you should individually use the "markdir"
+   command to select all higher level directory entries (one at a time) to
+   be restored if you want the directory entries properly restored.
 \end{itemize}
 
 \label{Windows}
@@ -620,11 +633,10 @@ File daemon runs under the SYSTEM account, the directory will be created
 with SYSTEM ownership and permissions.  In this case, you may have problems
 accessing the newly restored files.
 
-To avoid this problem, you should create any alternate directory before doing
-the
-restore. Bacula will not change the ownership and permissions of the directory
-if it is already created as long as it is not one of the directories being
-restored (i.e. written to tape). 
+To avoid this problem, you should create any alternate directory before
+doing the restore.  Bacula will not change the ownership and permissions of
+the directory if it is already created as long as it is not one of the
+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 
@@ -704,23 +716,57 @@ what it is now after each individual test:
 \item Set "Block Positioning = no" in your Device resource  and try the
    restore. This is a new directive and untested. 
 \item Set "Minimum Block Size = 512" and "Maximum  Block Size = 512" and
-   try the restore. Again send me the  full job report output. If you are able
-   to
-   determine the  block size your drive was previously using, you should try 
-   that size if 512 does not work. 
+   try the restore.  If you are able to determine the block size your drive
+   was previously using, you should try that size if 512 does not work.
 \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 commands also
-   cause repositioning,  but this will work regardless of the block size. 
+   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
+   commands also cause repositioning, but this will work regardless of the
+   block size.
 \item Use bextract to extract the files you want -- it reads the  Volume
-   sequentially if you use the include list feature, or  if you use a .bsr file,
-   but remove all the VolBlock statements  after the .bsr file is created (at
-   the
-   Run yes/mod/no) prompt but  before you start the restore. 
+   sequentially if you use the include list feature, or if you use a .bsr
+   file, but remove all the VolBlock statements after the .bsr file is
+   created (at the Run yes/mod/no) prompt but before you start the restore.
 \end{enumerate}
 
+\subsection*{Restore Errors}
+\index[general]{Errors!Restore}
+\index[general]{Restore Errors}
+\addcontentsline{toc}{subsection}{Restore Errors}
+
+There are a number of reasons why there may be restore errors or
+warning messages. Some of the more common ones are:
+
+\begin{description}
+
+\item [file count mismatch]
+  This can occur for the following reasons:
+  \begin{itemize}
+  \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}
+\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 
+   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
+   backed up the file. In this case, the size that Bacula
+   restored will be greater than the status size.  This often
+   happens with log files.
+
+   If the restored size is smaller, then you should be concerned
+   about a possible tape error and check the Bacula output as
+   well as your system logs.
+\end{description}
+
+
+
 \subsection*{Example Restore Job Resource}
 \index[general]{Example Restore Job Resource }
 \index[general]{Resource!Example Restore Job }
@@ -889,28 +935,42 @@ job.
    This command is the same as the {\bf help} command.  
 \end{description}
 
+\label{database_restore}
 \subsection*{Restoring When Things Go Wrong}
 \index[general]{Restoring When Things Go Wrong }
+\index[general]{Restoring Your Database}
+\index[general]{Database!Restoring}
 \addcontentsline{toc}{subsection}{Restoring When Things Go Wrong}
 
 This and the following sections will try to present a few of the kinds of
 problems that can come up making restoring more difficult. I'll try to
 provide a few ideas how to get out of these problem situations.
+In addition to what is presented here, there is more specific information
+on restoring a \ilink{Client}{restore_client} and your
+\ilink{Server}{restore_server} in the \ilink{Disaster Recovery Using
+Bacula}{_ChapterRescue} chapter of this manual.
 
 \begin{description}
-\item [Problem]
-   Your catalog has been damaged and Bacula either doesn't work or prints
-   errors.
+\item[Problem]
+   My database is broken.
 \item[Solution]
    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.
+   that check and repair databases, see the \ilink{database
+   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.
+   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
+   that your database indexes are properly setup.  Please see
+   the \ilink{Database Performance Issues}{DatabasePerformance} sections
+   of this manual for more details.
+
 \item[Problem]
    How do I restore my catalog?
-\item[Solution]
+\item[Solution with a Catalog backup]
    If you have backed up your database nightly (as you should) and you
    have made a bootstrap file, you can immediately load back your
    database (or the ASCII SQL output).  Make a copy of your current
@@ -943,27 +1003,35 @@ Priority:   10
 OK to run? (yes/mod/no): 
 \end{verbatim}
 \normalsize
-   A number of the items will be different in your case. What you want
-   to do is: to use the mod option to change the Bootstrap to point to 
-   your saved bootstrap file; and to make sure all the other items
-   such as 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. You will then
-   need to follow the instructions for your database type to
-   recreate the database from the ASCII backup file.
+   A number of the items will be different in your case.  What you want to
+   do is: to use the mod option to change the Bootstrap to point to your
+   saved bootstrap file; and to make sure all the other items such as
+   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. 
+
+   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}{_ChapterStart12} chapter of
+   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]
-   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 use bextract to extract the
-   backup copy.
-   First you should locate the listing of the job report from the last catalog
-   backup.  It has important information that will allow you to quickly find
-   your database file.  For example, in the job report for the CatalogBackup
-   shown below, the critical items are the Volume name(s), the Volume Session Id
-   and the Volume Session Time.  If you know those, you can easily restore your
+\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
+   use bextract to extract the backup copy.  First you should locate the
+   listing of the job report from the last catalog backup.  It has
+   important information that will allow you to quickly find your database
+   file.  For example, in the job report for the CatalogBackup shown below,
+   the critical items are the Volume name(s), the Volume Session Id and the
+   Volume Session Time.  If you know those, you can easily restore your
    Catalog.
 \footnotesize
 \begin{verbatim}
@@ -998,10 +1066,12 @@ Job=CatalogBackup.2005-04-22_01.10.0
 
 \end{verbatim}
 \normalsize
+
   From the above information, you can manually create a bootstrap file,
   and then follow the instructions given above for restoring your database.
   A reconstructed bootstrap file for the above backup Job would look
   like the following:
+
 \footnotesize
 \begin{verbatim}
 Volume="DLT-22Apr05"
@@ -1010,19 +1080,18 @@ VolSessionTime=1114075126
 FileIndex=1-1
 \end{verbatim}
 \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.
+
+  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 the requested
-  file. A fully specified bootstrap file would have the File and Blocks
-specified
-  as follows:
+  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
+  the requested file.  A fully specified bootstrap file would have the File
+  and Blocks specified as follows:
+
 \footnotesize
 \begin{verbatim}
 Volume="DLT-22Apr05"
@@ -1033,13 +1102,98 @@ VolBlock=0-4053
 FileIndex=1-1
 \end{verbatim}
 \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}{_ChapterStart12} chapter of
+   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 withou 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
+   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 
+   then reports:
+
+\footnotesize
+\begin{verbatim}
+   1 Job 0 Files
+\end{verbatim}
+\normalsize
+   and restores nothing.
+\item[Solution]
+   Most likely the File records were pruned from the database either due
+   to the File Retention period expiring or by explicitly purging the
+   Job. By using the "llist jobid=nn" command, you can obtain all the
+   important information about the job:
+\footnotesize
+\begin{verbatim}
+llist jobid=120
+           JobId: 120
+             Job: save.2005-12-05_18.27.33
+        Job.Name: save
+     PurgedFiles: 0
+            Type: B
+           Level: F
+    Job.ClientId: 1
+     Client.Name: Rufus
+       JobStatus: T
+       SchedTime: 2005-12-05 18:27:32
+       StartTime: 2005-12-05 18:27:35
+         EndTime: 2005-12-05 18:27:37
+        JobTDate: 1133803657
+    VolSessionId: 1
+  VolSessionTime: 1133803624
+        JobFiles: 236
+       JobErrors: 0
+ JobMissingFiles: 0
+      Job.PoolId: 4
+       Pool.Name: Full
+   Job.FileSetId: 1
+ FileSet.FileSet: BackupSet
+\end{verbatim}
+\normalsize
+
+   Then you can find the Volume(s) used by doing:
+\footnotesize
+\begin{verbatim}
+sql
+select VolumeName from JobMedia,Media where JobId=1 and JobMedia.MediaId=Media.MediaId;
+\end{verbatim}
+\normalsize
+   Finally, you can create a bootstrap file as described in the previous
+   problem above using this information.
+
+   If you are using Bacula version 1.38.0 or greater, when you select
+   item 3 from the menu and enter the JobId, it will ask you if
+   you would like to restore all the files in the job, and it will
+   collect the above information and write the bootstrap file for
+   you.
+
 \item [Problem]
   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]
-  Use {\bf bls} to indicate where it is on the tape. For example:
+  Either bscan the tape, or use {\bf bls} to indicate where it is on the
+  tape.  For example:
 
 \footnotesize
 \begin{verbatim}
@@ -1076,16 +1230,12 @@ Volume "DLT-22Apr05"
   How can I find where a file is stored.
 \item[Solution]
   Normally, it is not necessary, you just use the {\bf restore} command to
-restore the 
-  most recently saved version (menu option 5), or a version saved before a given
-date (menu
-  option 8).  If you know the JobId of the job in which it was saved, you can
-use menu 
-  option 3 to enter that JobId.
+  restore the most recently saved version (menu option 5), or a version
+  saved before a given date (menu option 8).  If you know the JobId of the
+  job in which it was saved, you can use menu option 3 to enter that JobId.
 
-  If you would like to know the JobId where a file was saved, select restore
-menu option
-  2.
+  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: 
 \footnotesize
@@ -1111,4 +1261,5 @@ Choose a query (1-15):
 \end{verbatim}
 \normalsize
 
+
 \end{description}