
#include "bacula_template.inc" title="Disaster Recovery Using Bacula"

<h1>Disaster Recovery Using Bacula</h1>

<h2>General</h2>
When disaster strikes, you must have a plan, and you must have
prepared in advance otherwise the work of recovering your
system and your files will be considerably greater.  For example, if you
have not previously saved the partitioning information for your hard
disk, how can you properly rebuild it if the disk must be replaced?
<p>
Unfortunately, many of the steps one must take before and immediately
after a disaster are very operating system dependent.  As a consequence,
this chapter will discuss in detail disaster recovery (also called Bare
Metal Recovery) for <b>Linux</b> and <b>Solaris</b>. For Solaris, the
procedures are still quite manual. For FreeBSD the same procedures
may be used but they are not yet developed.  For Win32, no luck.
Apparently an &quot;emergency boot&quot; disk allowing
access to the full system API without interference does not exist.

<a name="considerations"></a>
<h2>Important Considerations</h2>
Here are a few important considerations concerning disaster recovery
that you should take into account before a disaster strikes.
<ul>
 <li>If the building which houses your computers burns down or is otherwise
     destroyed, do you have off-site backup data?</li>
 <li>Disaster recovery is much easier if you have several machines. If
     you have a single machine, how will you handle unforeseen events
     if your only machine is down?</li>
 <li>Do you want to protect your whole system and use Bacula to 
     recover everything? or do you want to try to restore your system from
     the original installation disks and apply any other updates and
     only restore user files?
</ul>

<a name="steps"></a>
<h2>Steps to Take Before Disaster Strikes</h2>
<ul>
  <li>Create a Bacula Rescue CDROM for each of your Linux systems. Note, 
      it is possible to create one CDROM by copying the bacula-hostname
      directory from each machine to the machine where you will be
      burning the CDROM.</li>
  <li>Ensure that you always have a valid bootstrap file for your
      backup that is saved to an alternate machine. This will permit
      you to easily do a full restore of your system. </li>
  <li>If possible copy your catalog nightly to an alternate machine. 
      If you have a valid bootstrap file, this is not necessary, but
      can be very useful if you do not want to reload everything. .</li>
  <li>Ensure that you always have a valid bootstrap file for your
      catalog  backup that is saved to an alternate machine. This will
      permit you to restore your catalog more easily if needed.</li>
  <li>Test using the Bacula Rescue CDROM before you are forced to use
      it in an emergency situation.</li>
</ul>

<a name="rescueCDROM"></a>
<h2>Bare Metal Recovery on Linux with a Bacula Rescue CDROM</h2>
The remainder of this section concerns recovering a <b>Linux</b> computer,
and parts of it relate to the Red Hat version of Linux.  The <b>Solaris</b>
procedures can be found below under the <a href="rescue.html#solaris">Solaris
Bare Metal Recovery</a> section of this chapter.
<p>If you wish to use a floppy for restoration, please see the chapter
<a href="rescuefloppy.html">Bare Metal Floppy Recovery on Linux 
with a Bacula Floppy Rescue Disk</a>.
<p>
A so called &quot;Bare Metal&quot; recovery is one where you start with
an empty hard disk and you restore your machine.
There are also cases where you may lose a file or a directory and want
it restored. Please see the previous chapter for more details for
those cases.                
<p>Bare Metal Recovery assumes that you have the following
items for your system:
<ul>
  <li>A Bacula Rescue CDROM containing a copy of your OS and
      a copy of your hard disk information, as well as a
      statically linked version of the Bacula File daemon.</li>
  <li>A full Bacula backup of your system possibly including
      Incremental or Differential backups since the last Full
      backup </li>
  <li>A second system running the Bacula Director, the Catalog,
      and the Storage daemon. (this is not an absolute requirement,
      but how to get around it is not yet documented here)</li>
</ul>

<h2>Restrictions</h2>
In addition, to the above assumptions, the following conditions or
restrictions apply:
<ul>
  <li>Linux only -- tested only on Red Hat, but should work on other Linuxes</li>
  <li>The scripts handle only SCSI and IDE disks</li>
  <li>All partitions will be recreated, but only <b>ext2</b>,
      <b>ext3</b>, <b>rfs</b> and <b>swap</b> partitions will be reformatted.
      Any other partitions such as Windows FAT partitions will
      not be formatted by the scripts, but you can do it by hand</li>
  <li>You are using either <b>lilo</b> or <b>grub</b> as a boot
      loader, and you know which one (not automatically detected)</li>
  <li>The partitioning and reformating scripts will *should* work with RAID
      devices, but probably not with other &quot;complicated&quot; disk
      partitioning/formating schemes.  They also should work with
      Reiser filesystems. Please check them carefully.  You
      will probably need to edit the scripts by hand to make them work.</li>
</ul>

<h2>Directories</h2>
To build the Bacula Rescue CDROM, 
you will find the necessary scripts in <b>rescue/linux/cdrom</b>
subdirectory of the Bacula source code. If you installed the 
bacula-rescue rpm package the scripts will be found in the 
<b>/etc/bacula/rescue/cdrom</b> directory.

<h2>Preparation for a Bare Metal Recovery</h2>
Before you can do a Bare Metal recovery, you must create
a Bacula Rescue CDROM, which will contain everything you
need to begin recovery. This assumes that you will have
your Directory and Storage daemon running on a different
machine. If you want to recover a machine where the Director
and/or the database were previously running things will be
much more complicated.

<h3>Creating a Bacula Rescue CDROM</h3>
The primary goals of the Bacula rescue CD are:
<ul>
 <li>NOT to be a general or universal recovery disk.</li>
 <li>to capture and setup a restore environment for a
  single system running as a Client.</li>
 <li>to capture the current state of the hard disks on
  your system, so that they can be easily restored from pre-generated
  scripts.</li>
 <li>to create and save a statically linked copy of your
  current Bacula FD.</li>
 <li>to be relatively easy to create. In most cases
  you simply type <b>make all</b> in the <b>rescue/linux/cdrom</b>
  directory, then burn the ISO image created. In contrast,
  if you have looked at
  any of the documentation on how to remaster a CD or how to roll your 
  own, your head will spin (at least mine did).</li>
 <li>to be easy for you to add any additional files, binaries,
  or libraries to the CD.</li>
 <li>to build and work on any (or almost any) Linux
  flavor or release.</li>
</ul>
On of the main of the advantages of a Bacula Rescue CDROM is that it
contains a bootable copy of your system, so you should be
familiar with it. 
<p>
You should probably make a new rescue CDROM each time you make any major 
updates to your kernel, and every time you upgrade a major version of Bacula.
<p>
The whole process with the exception of burning the CDROM is
done with the following commands:
<pre>
(Build a working version of Bacula in the 
 bacula-source directory)
cd &lt;bacula-source&gt;
./configure (your options)
make
cd &lt;bacula-source&gt;/rescue/linux/cdrom
su (become root)
make all
</pre>
For users of the bacula-rescue rpm the static bacula-fd has already been built 
and placed in <b>/etc/bacula/rescue/cdrom/bin/</b> along with a symbolic link 
to your <b>/etc/bacula/bacula-fd.conf</b> file. Rpm users only need to do the 
second step:
<pre>
cd /etc/bacula/rescue/cdrom
su (become root)
make all
</pre>
At this point, if the scripts are successful, they should have
done the following things:
<ul>
  <li>Made a copy of your kernel and its essential files.</li>
  <li>Copied a number of binary files from your system.</li>
  <li>Copied all the necessary shared libraries to run the above
      binary files.</li>
  <li>Made a statically-linked version of your File daemon and
      copied it into the CDROM build area.
  <li>Made an ISO image and left it in <b>bootcd.iso</b>
</ul>
Once this is accomplished, you need only burn it into a CDROM.
This can be done directly from the makefile with:
<pre>
make burn
</pre>
However, you may need to modify the Makefile to properly specify
your CD burner as the detection process is complicated especially
if you have two CDROMs or do not have <b>cdrecord</b> loaded on your
system. Users of the rescue rpm package should definitely examine the 
Makefile since it was configured on the host used to produce the rpm package.
If you find that the <b>make burn</b> does not work for you,
try doing a:
<pre>
make scan
</pre>
and use the output of that to modify the Makefile accordingly.
<p>
The &quot;make all&quot; that you did above actually does the equivalent
to the following:
<pre>
make kernel
make binaries
make bacula
make iso
</pre>
If you wish, you can modify what you put on the CDROM and redo any
part of the make that you wish.  For example, if you want to add a new
directory, you might do the first three makes, then add a new directory to
the CDROM, and finally do a &quot;make iso&quot;. Please see the README file
in the <b>rescue/linux/cdrom</b> or <b>/etc/bacula/rescue/cdrom</b>directory 
for instructions on changing the contents of the CDROM.
<p>
At the current time, the size of the CDROM is about 50MB
(compressed to about 20MB), so there is quite a bit more room for
additional program.  Keep in mind that when this CDROM is booted,
*everything* is in memory, so the total size cannot exceed your
memory size, and even then you will need some reserve memory for
running programs, ...

<a name="twosystemcd"></a>
<h2>Putting Two or More Systems on Your Rescue Disk</h2>
You can put multiple systems on the same rescue CD if you wish.
This is because the information that is specific to your OS 
will be stored in the <b>/bacula-hostname</b> directory, where
<b>hostname</b> is the name of the host on which you are building
the CD. Suppose for example, you have two systems. One named
<b>client1</b> and one named <b>client2</b>. Assume also that your
CD burner is on client1, and that is the machine we start on, and
that we can ssh into client2 and also client2's disks are mounted on
client1.
<pre>
ssh client2
cd &lt;bacula-source&gt;
./configure (your options)
make
cd rescue/linux/cdrom
su
(enter root password)
make bacula
exit
exit
</pre>
Again, for rpm package users the above command set would be:
<pre>
ssh client2
cd /etc/bacula/rescue/cdrom
su
(enter root password)
make bacula
exit
exit
</pre>
Thus we have just built a Bacula rescue directory on client2.
Now, on client1, we copy the appropriate directory to two
places (explained below), then build an ISO and burn it:
<pre>
cd &lt;bacula-source&gt;
./configure (your options)
make
cd rescue/linux/cdrom
su
(enter root password)
c=/mnt/client2/home/user/bacula/rescue/linux/cdrom
cp -a $c/roottree/bacula-client2 roottree
cp -a $c/roottree/bacula-client2 cdtree
make all
make burn
exit
</pre>
And with the rpm package:
<pre>
cd /etc/bacula/rescue/cdrom
su
(enter root password)
c=/mnt/client2/etc/bacula/rescue/cdrom
cp -a $c/roottree/bacula-client2 roottree
cp -a $c/roottree/bacula-client2 cdtree
make all
make burn
exit
</pre>
In summary, with the above commands, we first build a Bacula
directory on client2 in roottree/bacula-client2, then
we copied the bacula-client2 directory into the client1's
roottree so it is available in memory after booting, and
we also copied it into the cdtree so it will also be
on the CD as a separate directory and thus can be read without
booting the CDROM.  Then we made and burned the CDROM for
client1, which of course, contains the client2 data.


<a name="restore"></a>
<h2>Restoring a Client System</h2>
Now, let's assume that your hard disk has just died and that
you have replaced it with an new identical drive. In addition,
we assume that you have:
<ol>
  <li>A recent Bacula backup (Full plus Incrementals)</li>
  <li>A Bacula Rescue CDROM.
  <li>Your Bacula Director, Catalog, and Storage daemon running
      on another machine on your local network.</li>
</ol>
This is a relatively simple case, and later in this chapter,
as time permits, we will discuss how you might recover from a situation
where the machine that crashes is your main Bacula server (i.e.  has the
Director, the Catalog, and the Storage daemon).
<p>You will take the following steps to get your system
back up and running:
<ol>
  <li>Boot with your Bacula Rescue CDROM.
  <li>Start the Network (local network)</li>
  <li>Re-partition your hard disk(s) as it was before</li>
  <li>Re-format your partitions</li>
  <li>Restore the Bacula File daemon (static version)</li>
  <li>Perform a Bacula restore of all your files</li>
  <li>Re-install your boot loader</li>
  <li>Reboot</li>
</ol>
Now for the details ...

<h3>Boot with your Bacula Rescue CDROM</h3>
When the CDROM boots, you will be presented with a script 
that looks like:
<pre>

 
      Welcome to the Bacula Rescue Disk 1.1.0

To proceed, press the &lt;ENTER&gt; key or type "linux &lt;runlevel&gt;"
 
   linux 1     -&gt; shell
   linux 2     -&gt; login  (default if ENTER pressed)
   linux 3     -&gt; network started and login (network not working yet)
   linux debug -&gt; print debug during boot then login
</pre>
Normally, at this point, you simply press ENTER. However, you may supply
options for the boot if you wish.   
<p> 
Once it has booted, you will be requested to login something like:
<pre>
Welcome to the Bacula Rescue CDROM
2.4.21-15.0.4.EL #1 Wed Aug 4 03:08:03 EDT 2004

Please login using root and your root password ...
RescueCD login:
</pre>
Note, you must enter the root password for the system on which you loaded
the kernel or on which you did the build of the CDROM.
Once you are logged in, your will be in the home directory for <b>root</b>,
and you can proceed to examine your system.
<p>
The complete Bacula rescue part of the CD will be in the directory:
<b>/bacula-hostname</b>, where hostname is replaced by the name of the
host machine on which you did the build for the CDROM. This naming procedure
allows you to put multiple restore environments for each of your machines
on a single CDROM if you so wish to do.  Please see the README document in
the <b>rescue/linux/cdrom</b> directory for more information on adding to
the CDROM.

<h4>Start the Network</h4>
At this point, you should bring up your network. Normally,
this is quite simple and requires just a few commands.
Please
cd into the /bacula-hostname directory before continuing.
To simplify your task, we have created a script that should
work in most cases by typing:
<pre>
cd /bacula-hostname
./start_network
</pre>
You can test it by pinging another machine, or pinging your broken
machine machine from another machine.  Do not proceed until your network
is up.

<h4>Partition Your Hard Disk(s)</h4>
Assuming that your hard disk crashed and needs repartitioning,
proceed with:
<pre>
./partition.hda
</pre>
If you have multiple disks, do the same for each of them.  For SCSI
disks, the repartition script will be named: <b>partition.sda</b>.  If
the script complains about the disk being in use, simply go back and
redo the <b>df</b> command and <b>umount</b> commands until you no
longer have your hard disk mounted.  Note, in many cases, if your hard
disk was seriously damaged or a new one installed, it will not
automatically be mounted.  If it is mounted, it is because the emergency
kernel found one or more possibly valid partitions.
<p>
If for some reason this procedure does not work,
you can use the information in <b>partition.hda</b> to 
re-partition your disks by hand using <b>fdisk</b>.

<h4>Format Your Hard Disk(s)</h4>
If you have repartitioned your hard disk, 
you must format it appropriately.
The formatting script will put back swap partitions, normal Unix
partitions (ext2) and journaled partitions (ext3) as well
as Reiser partitions (rei). Do so by
entering for each disk:
<pre>
./format.hda
</pre>
The format script will ask you if you want a block check done. We
recommend to answer yes, but realize that for very large disks this
can take hours.

<h4>Mount the Newly Formatted Disks</h4>
Once the disks are partitioned and formatted, you can remount them
with the <b>mount_drives</b> script.  
All your drives
must be mounted for Bacula to be able to access them. 
Run the script as follows:
<pre>
./mount_drives
df
</pre>
The <b>df</b> command
will tell you if the drives are mounted.
If not, re-run the script again. It isn't always easy
to figure out and create the mount points and the mounts
in the proper order, so repeating the <b>./mount_drives</b>
command will not cause any harm and will most likely work
the second time.  If not, correct it by hand before
continuing.

<h4>Restore and Start the File Daemon</h4>
If you have booted with a Bacula Rescue CDROM, your statically
linked Bacula File daemon and the bacula-fd.conf file with be
in the /bacula-hostname/bin directory.
Make sure <b>bacula-fd</b> and <b>bacula-fd.conf</b>
are both there.
<p>
Edit the Bacula configuration file, create the
working/pid/subsys directory if you haven't
already done so above, and start Bacula.
Before starting Bacula, you will need to move
it and bacula-fd.conf from /bacula-hostname/bin, to the /mnt/disk/tmp
directory so that it will be on your hard disk.
Then start it with the following command:
<pre>
chroot /mnt/disk /tmp/bacula-fd -c /tmp/bacula-fd.conf
</pre>
The above command starts the Bacula File daemon
with your the proper root disk location (i.e.
<b>/mnt/disk/tmp</b>.
If Bacula does not start correct the problem and
start it.  You can check if it is running by
entering:
<pre>
ps fax
</pre>
You can kill Bacula by entering:
<pre>
kill -TERM &lt;pid&gt;
</pre>
where <b>pid</b> is the first number printed in front
of the first occurrence of <b>bacula-fd</b> in the
<b>ps fax</b> command.
<p>
Now, you should be able to use another computer
with Bacula installed to check the status by entering:
<pre>
status client=xxxx
</pre>
into the Console program, where xxxx is the name of the
client you are restoring.
<p>
One common problem is that your <b>bacula-dir.conf</b> may
contain machine addresses that are not properly resolved on the
stripped down system to be restored because it is not running
DNS. This is particularly true for the address in the Storage
resource of the Director, which may be very well resolved on the
Director's machine, but not on the machine being restored and
running the File daemon.  In that case, be prepared to edit
<b>bacula-dir.conf</b> to replace the name of the
Storage  daemon's domain name with its IP address. 

<h4>Restore Your Files</h4>
On the computer that is running the Director, you now
run a <b>restore</b> command and select the files to
be restored (normally everything), but before starting
the restore, there is one final change you must make 
using the <b>mod</b> option.  You must change the 
<b>Where</b> directory to be the root by using the 
<b>mod</b> option just before running the job and
selecting <b>Where</b>. Set it to:
<pre>
/
</pre>
then run the restore.
<p>
You might be tempted to avoid using <b>chroot</b> and
running Bacula directly and then using a <b>Where</b>
to specify a destination of <b>/mnt/disk</b>. This is
possible, however, the current version of Bacula always
restores files to the new location, and thus any
soft links that have been specified with absolute
paths will end up with <b>/mnt/disk</b> prefixed to them.
In general this is not fatal to getting your system
running, but be aware that you will have to fix these
links if you do not use <b>chroot</b>.

<h4>Final Step</h4>
At this point, the restore should have finished with no errors,
and all your files will be restored. One last task remains and
that is to write a new boot sector so that your machine will
boot.  For <b>lilo</b>, you enter the following command:
<pre>
./run_lilo
</pre>
If you are using grub instead of lilo, you must enter
the following:
<pre>
./run_grub
</pre>
Note, I've had quite a number of problems with <b>grub</b>
because it is rather complicated and not designed to install
easily under a simplified system. So, if you experience
errors or end up unexpectedly in a <b>chroot</b> shell,
simply exit back to the normal shell and type in the
appropriate commands from the <b>run_grub</b> script
by hand until you get it to install. When you run the
run_grub script, it will print the commands that you
should manually enter if that is necessary.
 
<h4>Reboot</h4>
First unmount all your hard disks, otherwise they
will not be cleanly shutdown, then
reboot your machine by entering <b>exit</b> until
you get to the main prompt then enter <b>ctl-d</b>.
Once back to the main CDROM prompt, you will need
to turn the power off then back on to your machine
to get it to reboot.
<p>
If everything went well, you should now be back up and running.
If not, re-insert the emergency boot CDROM, boot, and figure
out what is wrong.

<a name="server"></a>
<h2>Restoring a Server</h2>
Above, we considered how to recover a client machine where a
valid Bacula server was running on another machine.  However,
what happens if your server goes down and you no longer have a running
Director, Catalog, or Storage daemon?  There are several solutions:
<ol>
  <li>Bring up static versions of your Director, Catalog, and Storage
      daemon. </li>                               
  <li>Move your server to another machine.</li>
</ol>
The first option, is very difficult because it requires you to have
created a static version of the Director and the Storage daemon as
well as the Catalog. If the Catalog uses MySQL or PostgreSQL, this may or may not
be possible. In addition, to loading all these programs on a bare
system (quite possible), you will need to make sure you have a valid
driver for your tape drive.
<p>
The second suggestion is probably a much simpler solution, and one
I have done myself. To do so, you might want to consider the following
steps:
<ul>
  <li>If you are using MySQL or PostgreSQL, configure, build and install it from
      source (or user rpms) on your new system.</li>
  <li>Load the Bacula source code onto your new system, configure,
      install it, and create the Bacula database.</li>
  <li>If you have a valid saved Bootstrap file as created for your
      damaged machine with WriteBootstrap, use it to restore the
      files to the damaged machine, where you have loaded a static Bacula
      File daemon using the Bacula Rescue disk). This is done by
      using the restore command and at the yes/mod/no prompt, 
      selecting <b>mod</b> then specifying the path to the bootstrap
      file. </li>   
  <li>If you have the Bootstrap file, you should now be back up and
      running, if you do not have a Bootstrap file, continue with the
      suggestions below.</li>
  <li>Using <b>bscan</b> scan the last set of backup tapes into your
      MySQL, PostgreSQL or SQLite database.</li>     
  <li>Start Bacula, and using the Console <b>restore</b> command, 
      restore the last valid copy of the Bacula database and the
      the Bacula configuration files.</li>
   <li>Move the database to the correct location. </li>
   <li>Start the database, and restart Bacula. Then use
       the Console <b>restore</b> command, restore all the files 
       on the damaged machine, where you have loaded a Bacula File
       daemon using the Bacula Rescue disk.</li>
</ul>

<a name="problems"></a>
<h2>Linux Problems or Bugs</h2>
Since every flavor and every release of Linux is different,
there are likely to be some small difficulties with the scripts,
so please be prepared to edit them in a minimal environment. 
A rudimentary knowledge of <b>vi</b> is very useful.  Also,
these scripts do not do everything. You will need to reformat
Windows partitions by hand, for example.
<p>
Getting the boot loader back can be a problem if you are
using <b>grub</b> because it is so complicated. If all else
fails, reboot your system from your floppy but using the 
restored disk image, then proceed to a reinstallation of
grub (looking at the run-grub script can help).  By contrast,
lilo is a piece of cake.

<a name="FreeBSD"></a>
<h2>FreeBSD Bare Metal Recovery</h2>
The same basic techniques described above also apply to FreeBSD.
Although we don't yet have a fully automated procedure,      
Alex Torres Molina has provided us with the following
instructions with a few additions from Jesse Guardiani and
Dan Languille:
<ol>
 <li>Boot with the FreeBSD installation disk</li>
 <li>Go to Custom, Partition and create your slices and go to Label and
     create the particions that you want. Apply changes.</li>
 <li>Go to Fixit to start a emergency console.</li>
 <li>Create devs ad0 .. .. if don't exist under /mnt2/dev (in my
     situation) with MAKEDEV. The device or devices you
     create depend on what hard drives you have. ad0 is your
     first ATA drive. da0 would by your first SCSI drive.
     Under OS version 5 and greater, your device files are
     most likely automatically created for you. </li>
 <li>mkdir /mnt/disk<br>this is the root of the new disk</li>
 <li>mount /mnt2/dev/ad0s1a /mnt/disk<br>
     mount /mnt2/dev/ad0s1c /mnt/disk/var<br>
     mount /mnt2/dev/ad0s1d /mnt/disk/usr<br>
     .....<br>
     The same hard drive isssues as above apply here too.
     Note, under OS version 5 or higher, your disk devices may
     be in /dev not /mnt2/dev.</li>
 <li>Network configuraion (ifconfig xl0 ip/mask + route add default
     ip-gateway)</li>
 <li>mkdir /mnt/disk/tmp</li>
 <li>cd /mnt/disk/tmp</li>
 <li>Copy bacula-fd and bacula-fd.conf to this path</li>
 <li>If you need to use sftp to copy files then you must do this:<br>
     ln -s /mnt2/usr/bin /usr/bin</li>
 <li>chmod u+x bacula-fd</li>
 <li>Modify bacula-fd.conf to fit this machine</li>
 <li>Copy /bin/sh to /mnt/disk, neccesary for chroot</li>
 <li>Don't forget to put your bacula-dir's IP address and domain
     name in /mnt/disk/etc/hosts if it's not on a public net.
     Otherwise the FD on the machine you are restoring to
     won't be able to contact the SD and DIR on the remote machine.</li>
 <li>mkdir -p /mnt/disk/var/db/bacula</li>
 <li>chroot /mnt/disk /tmp/bacula-fd -c /tmp/bacula-fd.conf<br>
     to start bacula-fd</li>
 <li>Now you can go to bacula-dir and restore the job with the entire
     contents of the broken server.</li>
 <li>You must create /proc</li>
</ol>


<a name="solaris"></a>
<h2>Solaris Bare Metal Recovery</h2>
The same basic techniques described above apply to Solaris:
<ul>
  <li>the same restrictions as those given for Linux apply</li>
  <li>you will need to create a Bacula Rescue disk</li>
</ul>
However, during the recovery phase, the boot and disk preparation
procedures are different:
<ul>
  <li>there is no need to create an emergency boot disk 
      since it is an integrated part of the Solaris boot.</li>
  <li>you must partition and format your hard disk by hand
      following manual procedures as described in W. Curtis Preston's
      book &quot;Unix Backup & Recovery&quot;</li>
</ul>
Once the disk is partitioned, formatted and mounted,
you can continue with bringing up the network and
reloading Bacula.
</ul>

<h3>Preparing Solaris Before a Disaster</h3>
As mentioned above, before a disaster strikes, you should
prepare the information needed in the case of problems.
To do so, in the <b>rescue/solaris</b> subdirectory enter:
<pre>
su
./getdiskinfo
./make_rescue_disk
</pre>
The <b>getdiskinfo</b> script will, as in the case of Linux described
above, create a subdirectory <b>diskinfo</b> containing the output
from several system utilities. In addition, it will contain the
output from the <b>SysAudit</b> program as described in 
Curtis Preston's book. This file <b>diskinfo/sysaudit.bsi</b>
will contain the disk partitioning information that will allow
you to manually follow the procedures in the &quot;Unix Backup & Recovery&quot;
book to repartition and format your hard disk. In addition, the
<b>getdiskinfo</b> script will create a <b>start_network</b>
script.
<p>
Once you have your your disks repartitioned and formatted, do   
the following:
<ul>
  <li>Start Your Network with the <b>start_network</b> script</li>
  <li>Restore the Bacula File daemon as documented above</li>
  <li>Perform a Bacula restore of all your files using the same
      commands as described above for Linux</li>
  <li>Re-install your boot loader using the instructions outlined
      in the &quot;Unix Backup & Recovery&quot; book
      using installboot</li>
</ul>
 


<a name="genbugs"></a>
<h2>Bugs and Other Considerations</h2>
<h4>Directory Modification and Access Times are Modified on pre-1.30 Baculas </h4>
When a pre-1.30 version of Bacula restores a directory, it first
must create the directory, then it populates the directory with its
files and subdirectories.  The act of creating the files and
subdirectories updates both the modification and access times associated
with the directory itself.  As a consequence, all modification and
access times of all directories will be updated to the time of the
restore.
<p>
This has been corrected in Bacula version 1.30 and later. The directory
modification and access times is reset to the value saved in the backup
after all the files and subdirectories have been restored. This has been
tested and verified on normal restore operations, but not verified
during a bare metal recovery.

<h4>Strange Bootstrap Files</h4>
If any of you look closely at the bootstrap file that is produced
and used for the restore (I sure do), you will probably notice that
the FileIndex item does not include all the files saved to the tape.
This is because in some instances there are duplicates (especially
in the case of an Incremental save), and in such circumstances, <b>Bacula</b>
restores only the last of multiple copies of a file or directory.

<a name="Win32"></a>
<h2>Disaster Recovery of Win32 Systems</h2>
Due to open system files, and registry problems, Bacula cannot 
save and restore a complete Win2K/XP/NT environment.
<p>
A suggestion by Damian Coutts <dcoutts at voip dot com do au> using Microsoft's 
NTBackup utility in conjunction with Bacula should permit a Full bare 
metal restore of Win2K/XP (and possibly NT systems).  His suggestion is to
do an NTBackup of the critical system state prior to running a Bacula 
backup with the following command:
<pre>
ntbackup backup systemstate /F c:\systemstate.bkf
</pre>
The <b>backup</b> is the command, the <b>systemstate</b> says to backup
only the system state and not all the user files, and the
<b>/F c:\systemstate.bkf</b> specifies where to write the state file.
this file must then be saved and restored by Bacula.
<p>
To restore the system state, you first reload a base operating system, then
you would use Bacula to restore all the users files and to
recover the <b>c:\systemstate.bkf</b> file, and finally, run <b>NTBackup</b>
and <b>catalogue</b> the system statefile, and then select it for restore.
The documentation says you can't run a command line restore of the systemstate.
<p>
This procedure has been confirmed to work by Ludovic Strappazon -- many thanks!
<p>
A new tool is provided in the form of a bacula plugin for the BartPE rescue CD. 
BartPE is a self-contained WindowsXP boot CD which you can make using the PeBuilder 
tools available at <a href="http://www.nu2.nu/pebuilder/">http://www.nu2.nu/pebuilder/</a> 
and a valid Windows XP SP1 CDROM. The plugin is provided as a zip archive. Unzip the 
file and copy the bacula directory into the plugin directory of your BartPE installation. 
Edit the configuration files to suit your installation and build your CD according to the 
instructions at Bart's site. This will permit you to boot from the cd, configure and 
start networking, start the bacula file client and access your director with the console 
program. The programs menu on the booted CD contains entries to install the file client 
service, start the file client service, and start the WX-Console. You can also open a 
command line window and CD Programs\Bacula and run the command line console bconsole.

<h2>Resetting Directory and File Ownership and Permissions on Win32 Systems</h2>
Bacula versions after 1.31 should properly restore ownership and permissions
on all WinNT/XP/2K systems. If you do experience problems, generally in 
restores to alternate directories because higher level directories were
not backed up by Bacula, you can correct any problems with the
<b>SetACL</b> available under the GPL license at:
<a href="http://sourceforge.net/projects/setacl/">http://sourceforge.net/projects/setacl/</a>.

<h2>Alternate Disaster Recovery Suggestion for Win32 Systems</h2>
Ludovic Strappazon has suggested an interesting way to backup and 
restore complete Win32 partitions. Simply boot your Win32 system with
a Linux Rescue disk as described above for Linux, install a statically
linked Bacula, and backup any of the raw partitions you want. Then to
restore the system, you simply restore the raw partition or partitions.
Here is the email that Ludovic recently sent on that subject:
<pre>
I've just finished testing my brand new cd LFS/Bacula 
with a raw Bacula backup and restore of my portable.

I can't resist sending you the results: look at the rates !!!

hunt-dir: Start Backup JobId 100, Job=HuntBackup.2003-04-17_12.58.26
hunt-dir: Bacula 1.30 (14Apr03): 17-Apr-2003 13:14
JobId:                  100
Job:                    HuntBackup.2003-04-17_12.58.26
FileSet:                RawPartition
Backup Level:           Full
Client:                 sauvegarde-fd
Start time:             17-Apr-2003 12:58
End time:               17-Apr-2003 13:14
Files Written:          1
Bytes Written:          10,058,586,272
Rate:                   10734.9 KB/s
Software Compression:   None
Volume names(s):        000103
Volume Session Id:      2
Volume Session Time:    1050576790
Last Volume Bytes:      10,080,883,520
FD termination status:  OK
SD termination status:  OK
Termination:            Backup OK

hunt-dir: Begin pruning Jobs.
hunt-dir: No Jobs found to prune.
hunt-dir: Begin pruning Files.
hunt-dir: No Files found to prune.
hunt-dir: End auto prune.


hunt-dir: Start Restore Job RestoreFilesHunt.2003-04-17_13.21.44
hunt-sd: Forward spacing to file 1.
hunt-dir: Bacula 1.30 (14Apr03): 17-Apr-2003 13:54
JobId:                  101
Job:                    RestoreFilesHunt.2003-04-17_13.21.44
Client:                 sauvegarde-fd
Start time:             17-Apr-2003 13:21
End time:               17-Apr-2003 13:54
Files Restored:         1
Bytes Restored:         10,056,130,560
Rate:                   5073.7 KB/s
FD termination status:  OK
Termination:            Restore OK

hunt-dir: Begin pruning Jobs.
hunt-dir: No Jobs found to prune.
hunt-dir: Begin pruning Files.
hunt-dir: No Files found to prune.
hunt-dir: End auto prune.
</pre>

<a name="running"></a>
<h2>Restoring to a Running System</h2>
If for some reason you want to do a Full restore to a
system that has a working kernel, you will need to 
take care not to overwrite the following files:
<pre>
/etc/grub.conf
/etc/X11/Conf
/etc/fstab
/etc/mtab
/lib/modules
/usr/modules
/usr/X11R6
/etc/modules.conf
</pre>

<a name="Resources"></a>
<h2>Additional Resources</h2>
Many thanks to Charles Curley who wrote 
<a href="http://www.tldp.org/HOWTO/Linux-Complete-Backup-and-Recovery-HOWTO/index.html">
Linux Complete Backup and Recovery HOWTO</a> for the 
<a href="http://www.tldp.org/">The Linux Documentation Project</a>.
This is an excellent document on how to do Bare Metal Recovery on Linux
systems, and it was this document that made me realize that Bacula could
do the same thing. 
<p>
You can find quite a few additional resources, both commercial and
free at <a href="http://www.backupcentral.com">Storage Mountain</a>, formerly
known as Backup Central.
<p>And finally, the O'Reilly book,  &quot;Unix Backup & Recovery&quot; by
W. Curtis Preston covers virtually every backup and recovery topic including
bare metal recovery for a large range of Unix systems.


<page_prev name="The Windows Version of Bacula" url="win32.html">
<page_next name="Disaster Recovery Using a Bacula Rescue Floppy" url="rescuefloppy.html">
