4 \chapter{Disaster Recovery Using Bacula}
6 \index[general]{Disaster Recovery Using Bacula}
7 \index[general]{Bacula!Disaster Recovery Using}
8 \index[general]{Recovery!Disaster Recovery}
9 \index[general]{Rescue!Disaster Recovery}
12 \index[general]{General}
14 When disaster strikes, you must have a plan, and you must have prepared in
15 advance otherwise the work of recovering your system and your files will be
16 considerably greater. For example, if you have not previously saved the
17 partitioning information for your hard disk, how can you properly rebuild
18 it if the disk must be replaced?
20 Unfortunately, many of the steps one must take before and immediately after
21 a disaster are very operating system dependent. As a consequence, this
22 chapter will discuss in detail disaster recovery (also called Bare Metal
24 {\bf Linux} and {\bf Solaris}. For Solaris, the procedures are still quite
25 manual. For FreeBSD the same procedures may be used but they are not yet
26 developed. For Win32, a number of Bacula users have reported success using
30 \label{considerations1}
31 \section{Important Considerations}
32 \index[general]{Important Considerations}
33 \index[general]{Considerations!Important}
35 Here are a few important considerations concerning disaster recovery that
36 you should take into account before a disaster strikes.
39 \item If the building which houses your computers burns down or is otherwise
40 destroyed, do you have off-site backup data?
41 \item Disaster recovery is much easier if you have several machines. If you
42 have a single machine, how will you handle unforeseen events if your only
44 \item Do you want to protect your whole system and use Bacula to recover
45 everything? or do you want to try to restore your system from the original
46 installation disks and apply any other updates and only restore user files?
50 \section{Steps to Take Before Disaster Strikes}
51 \index[general]{Steps to Take Before Disaster Strikes}
52 \index[general]{Strikes!Steps to Take Before Disaster}
55 \item Create a Bacula Rescue CDROM for each of your Linux systems. Note, it
56 is possible to create one CDROM by copying the bacula-hostname directory from
57 each machine to the machine where you will be burning the CDROM, so
58 if the Linux distro/version is the same, you can have a single CDROM that can recover
60 \item Ensure that you always have a valid bootstrap file for your backup and
61 that it is saved to an alternate machine. This will permit you to
62 easily do a full restore of your system.
63 \item If possible copy your catalog nightly to an alternate machine. If you
64 have a valid bootstrap file, this is not necessary, but can be very useful if
65 you do not want to reload everything. .
66 \item Ensure that you always have a valid bootstrap file for your catalog
67 backup that is saved to an alternate machine. This will permit you to restore
68 your catalog more easily if needed.
69 \item Test using the Bacula Rescue CDROM before you are forced to use it in
70 an emergency situation.
71 \item Make a copy of your Bacula .conf files, particularly your
72 bacula-dir.conf, and your bacula-sd.conf files, because if your server
73 goes down, these files will be needed to get it back up and running,
74 and they can be difficult to rebuild from memory.
78 \section{Bare Metal Recovery on Linux with a Bacula Rescue CD}
79 \index[general]{Bare Metal Recovery on Linux with a Bacula Rescue CD}
80 \index[general]{CDROM!Bare Metal Recovery on Linux with a Bacula Rescue}
81 %% NOTE: using "CD" instead of "CDROM" so it fits on book page in Table of Contents
83 As an alternative to creating a Bacula Rescue CD, please see the
84 section below entitled \ilink{Bare Metal Recovery using a LiveCD}{LiveCD}.
86 The remainder of this section concerns recovering a {\bf Linux} client
87 computer (i.e. one running just the Bacula File daemon). The {\bf
88 Solaris} procedures can be found below under the \ilink{Solaris Bare Metal
89 Recovery}{solaris} section of this chapter.
91 Previously Bacula supported a floppy rescue disk. This code has been
92 removed in 1.37.40 and later.
94 A so called "Bare Metal" recovery is one where you start with an empty hard
95 disk and you restore your machine. There are also cases where you may lose a
96 file or a directory and want it restored. Please see the previous chapter for
97 more details for those cases.
100 The primary goals of the Bacula rescue CD are:
103 \item NOT to be a general or universal recovery disk.
104 \item to capture and setup a restore environment for a single system running
106 \item to capture the current state of the hard disks on your system, so that
107 they can be easily restored from pre-generated scripts. Note, this is
108 not done by any other rescue CDROM, as far as I am aware.
109 \item to create and save a statically linked copy of your current Bacula FD.
110 Thus you need no packages or other software to be installed before using
111 this CDROM and the Bacula File daemon on it.
112 \item to be relatively easy to create. In most cases you simply type {\bf
113 make all} in the {\bf rescue/linux/cdrom} directory, then burn the ISO image
114 created. In contrast, if you have looked at any of the documentation on how
115 to remaster a CD or how to roll your own rescue CD, your head will spin
117 \item to be easy for you to add any additional files, binaries, or libraries
119 \item to build and work on any (or almost any) Linux flavor or release.
120 \item you might ask why I don't use Knoppix or some other preprepared recovery
121 disk, especially since Knoppix is very kind and provides the Bacula FD on
122 their disk. The answer is that: I am more comfortable having my Linux boot
123 up in rescue mode rather than another flavor. In addition, the Bacula rescue
124 CDROM contains a complete snapshot of your disk partitioning, which is not
125 the case with any other rescue disk. If your harddisk dies, do you remember all
126 the partitions you had and how big they are? I don't, and without that information,
127 you have little hope of reformatting your harddisk and rebuilding your system.
130 One of the main of the advantages of a Bacula Rescue CDROM is that it contains
131 a bootable copy of your system, so you should be familiar with it.
134 Bare Metal Recovery assumes that you have the following items for your system:
137 \item A Bacula Rescue CDROM containing a copy of your OS and a copy of your
138 hard disk information, as well as a statically linked version of the
139 Bacula File daemon. This chapter describes how to build such a CDROM.
140 \item A full Bacula backup of your system possibly including Incremental or
141 Differential backups since the last Full backup
142 \item A second system running the Bacula Director, the Catalog, and the
143 Storage daemon. (this is not an absolute requirement, but how to get
144 around it is not yet documented here)
147 \section{Requirements}
148 \index[general]{Requirements}
150 In addition, to the above assumptions, the following conditions or
154 \item Linux only -- tested only on SuSE and Fedora Core 4, but should work
155 on other Linux distros.
156 \item The scripts handle only SCSI and IDE disks.
157 \item All partitions will be recreated, but only {\bf ext2}, {\bf ext3}, {\bf
158 rfs} and {\bf swap} partitions will be reformatted. Any other partitions such
159 as Windows FAT partitions will not be formatted by the scripts, but you can
161 \item You are using either {\bf lilo} or {\bf grub} as a boot loader, and you
162 know which one (not automatically detected).
163 \item The partitioning and reformatting scripts *should* work with RAID
164 devices, but probably not with other "`complicated"' disk
165 partitioning/formatting schemes. They also should work with Reiser
166 filesystems. Please check them carefully. You will probably need to
167 edit the scripts by hand to make them work.
168 \item You will need mkisofs (might be part of cdrtools, but is a separate rpm
169 on my system); cdrecord or some other tool for burning the CDROM.
172 \section{Directories}
173 \index[general]{Directories}
175 To build the Bacula Rescue CDROM, you must get a copy of the rescue files.
176 In version 1.37 and later, they are separate from the Bacula source. The
177 rescue files are distributed as a compressed tar file on the Source Forge
178 Bacula release area with the name bacula-rescue-xx.yy.zz.tar.gz. They are
179 also automatically installed in /etc/bacula/rescue when installing by rpms.
180 Another place you can find the rescue files is in the Source Forge Bacula
181 SVN module named {\bf rescue}.
183 Please read the README file in the main directory of the
184 Rescue source code. Before using it, you must run configure and
185 specify the location of the Bacula source code (not necessary if installed
186 from rpms). This permits the rescue build scripts to automatically
187 create a statically linked Bacula File daemon.
189 You will find the necessary scripts in {\bf
190 linux/cdrom} subdirectory of the rescue source code. If you installed
191 the bacula rpm package the scripts will be found in the {\bf
192 /etc/bacula/rescue/linux/cdrom} directory.
194 \section{Preparation for a Bare Metal Recovery}
195 \index[general]{Recovery!Preparation for a Bare Metal}
196 \index[general]{Preparation for a Bare Metal Recovery}
198 Before you can do a Bare Metal recovery, you must create a Bacula Rescue
199 CDROM, which will contain everything you need to begin recovery. This assumes
200 that you will have your Director and Storage daemon running on a different
201 machine. If you want to recover a machine where the Director and/or the
202 database were previously running, things will be much more complicated.
205 \section{Creating a Bacula Rescue CDROM}
206 \index[general]{CDROM!Creating a Bacula Rescue}
207 \index[general]{Creating a Bacula Rescue CDROM}
208 \index[general]{Upgrading}
210 You should probably make a new rescue CDROM each time you upgrade a major
211 version of Bacula and whenever you modify your disk partitioning.
213 To build the rescue CDROM from source, you must first configure the
214 rescue package, which is distributed separately from the source.
215 The simplest procedure is for you to pre-build a static-bacula-fd taking
216 care to use a minimum configuration such as:
223 --sbindir=/usr/sbin \
224 --sysconfdir=/etc/bacula \
225 --with-scriptdir=/etc/bacula \
226 --enable-smartalloc \
227 --enable-client-only \
233 Then to copy the src/filed/static-bacula-fd, and a valid
234 working copy of your bacula-fd.conf file to some specific
235 directory. You can then proceed to configure the rescue
242 --with-static-fd=<directory-containing-static-bacula-fd> \
243 --with-bacula-scripts=<directory-containing-bacula-fd.conf>
246 (enter root password)
251 The above instructions were for building the rescue CDROM from
252 a bacula-rescue release. The advantage of the above procedure is
253 that you have explicitly built your static-bacula-fd and you will
254 supply the configuration with a working copy of bacula-fd.conf containing
255 the correct Director name and password.
257 Alternatively when you configure the rescue package, you could supply
258 it with the path to your Bacula source code, and when building the
259 rescue disk, it will attepmpt to build a static-bacula-fd for you.
260 We suggest you manually build your static Bacula File daemon and
261 use the {\bf --with-static-fd} option rather than letting the script
262 attempt to build it (as shown below) because by manually building it,
263 you can ensure that there are no errors, and you can execute it
264 prior to putting it on the CD (e.g. ./bacula-fd -t).
266 To have the rescue scripts automatically build a static File daemon
273 --with-bacula=<bacula-source-directory>
276 (enter root password)
282 If you have multiple kernels installed on your system, you can
283 specify which one using the following configuration option:
289 --with-kernel=<kernel-version> \
294 For example a {\bf kernel-version} might be 2.6.14-1.1653.
296 One additional option that can be useful is to specify the
297 device name of your CDROM on the ./configure. To do so use:
303 --with-dev=<device> \
308 Where \lt{}device\gt{} is typically replaced with something like
309 {\bf /dev/hdc}. This option is needed only if you have a recent OS
310 that used device specifications rather than rather than ATA addresses, and
311 you want to use the Bacula script {\bf make burn} to automatically
312 burn your ISO onto a CDROM.
315 For users of the bacula-rescue rpm the static bacula-fd has already been built
316 and placed in {\bf /etc/bacula/rescue/linux/cdrom/bin/} along with a symbolic link
317 to your {\bf /etc/bacula/bacula-fd.conf} file. Rpm users only need to do the
322 cd /etc/bacula/rescue/linux/cdrom
328 At this point, if the scripts are successful, they should have done the
332 \item Made a copy of your kernel and its essential files.
333 \item Copied a number of binary files from your system.
334 \item Copied all the necessary shared libraries to run the above binary
336 \item Made a statically-linked version of your File daemon and copied it into
337 the CDROM build area.
338 \item Made an ISO image and left it in {\bf bootcd.iso}
341 Once this is accomplished, you need only burn it into a CDROM. This can be
342 done directly from the makefile with:
350 However, you may need to modify the Makefile to properly specify your CD
351 burner as the detection process is complicated especially if you have two
352 CDROMs or do not have {\bf cdrecord} loaded on your system. Users of the
353 rescue rpm package should definitely examine the Makefile since it was
354 configured on the host used to produce the rpm package. If you find that the
355 {\bf make burn} does not work for you, try doing a:
363 and use the output of that to modify the Makefile accordingly.
365 The "make" that you did above actually does the equivalent to the
377 If you wish, you can modify what you put on the CDROM and redo any part of the
378 make that you wish. For example, if you want to add a new directory, you might
379 do the first three makes, then add a new directory to the CDROM, and finally
380 do a "`make iso"'. Please see the README file in the {\bf rescue/linux/cdrom}
381 or {\bf /etc/bacula/rescue/linux/cdrom}directory for instructions on changing the
382 contents of the CDROM.
384 At the current time, the size of the CDROM is about 100MB (compressed to about
385 20MB), so there is quite a bit more room for additional programs. Keep in mind
386 that when this CDROM is booted, *everything* is in memory, so the total size
387 cannot exceed your memory size, and even then you will need some reserve
388 memory for running programs, ...
390 Finally, if you want to be completely responsible for getting your
391 own FD binary on the disk, you can do the following:
400 (add your own Bacula FD to the bacula/bin directory)
406 The rpm\_release file prevents the {\bf make bacula} from attempting to
407 build or copy a File daemon, so that you can do it before the
408 "make iso" step. Once "make iso" is run, you can no longer add
409 anything to the in-memory part of the image. You can still add
410 files to the cdtree directory, and when you do a "make burn" they
411 will be written to the CDROM. However, to access them, you must
412 be able to mount the CDROM after booting it, then copy them into
417 \section{Putting Multiple Systems on Your Rescue Disk}
418 \index[general]{Putting Multiple Systems on Your Rescue Disk}
419 \index[general]{Disk!Putting Multiple Systems on Your CD}
421 You can put multiple systems on the same rescue CD if you wish. This is
422 because the information that is specific to your OS will be stored in the {\bf
423 /bacula-hostname} directory, where {\bf hostname} is the name of the host on
424 which you are building the CD. Suppose for example, you have two systems. One
425 named {\bf client1} and one named {\bf client2}. Assume also that your CD
426 burner is on client1, and that is the machine we start on, and that we can ssh
427 into client2 and also client2's disks are mounted on client1.
433 ./configure --with-static-fd (our options)
435 cd <bacula-rescue-source>
436 ./configure --with-bacula=<path-to-bacula-source>
444 Again, for rpm package users the above command set would be:
449 cd /etc/bacula/rescue/linux/cdrom
451 (enter root password)
457 Thus we have just built a Bacula rescue directory on client2. Now, on client1,
458 we copy the appropriate directory to two places (explained below), then build
464 ./configure (your options)
466 cd <bacula-rescue-source>
467 ./configure --with-bacula=<path-to-bacula-source>
470 c=/mnt/client2/home/user/bacula/rescue/linux/cdrom
471 cp -a $c/roottree/bacula-client2 cdtree
478 And with the rpm package:
482 cd /etc/bacula/rescue/linux/cdrom
484 (enter root password)
485 c=/mnt/client2/etc/bacula/rescue/linux/cdrom
486 cp -a $c/roottree/bacula-client2 cdtree
493 In summary, with the above commands, we first build a Bacula directory on
494 client2 in roottree/bacula-client2, then we copied the bacula-client2
495 directory into the client1's cdtree so it will also be on the CD as
496 a separate directory and thus can be read without booting the CDROM. Then we
497 made and burned the CDROM for client1, which of course, contains the client2
500 \label{restore_client}
501 \section{Restoring a Client System}
502 \index[general]{Restoring a Client System}
503 \index[general]{System!Restoring a Client}
505 Now, let's assume that your hard disk has just died and that you have replaced
506 it with an new identical drive. In addition, we assume that you have:
509 \item A recent Bacula backup (Full plus Incrementals)
510 \item A Bacula Rescue CDROM.
511 \item Your Bacula Director, Catalog, and Storage daemon running on another
512 machine on your local network.
515 This is a relatively simple case, and later in this chapter, as time permits,
516 we will discuss how you might recover from a situation where the machine that
517 crashes is your main Bacula server (i.e. has the Director, the Catalog, and
520 You will take the following steps to get your system back up and running:
523 \item Boot with your Bacula Rescue CDROM.
524 \item Start the Network (local network)
525 \item Re-partition your hard disk(s) as it was before
526 \item Re-format your partitions
527 \item Restore the Bacula File daemon (static version)
528 \item Perform a Bacula restore of all your files
529 \item Re-install your boot loader
533 Now for the details ...
535 \section{Boot with your Bacula Rescue CDROM}
536 \index[general]{CDROM!Boot with your Bacula Rescue}
537 \index[general]{Boot with your Bacula Rescue CDROM}
539 When the CDROM boots, you will be presented with a script that looks like:
544 Welcome to the Bacula Rescue Disk 2.0.0
545 To proceed, press the <ENTER> key or type "linux <runlevel>"
548 linux 2 -> login (default if ENTER pressed)
549 linux 3 -> network started and login (network not working yet)
550 linux debug -> print debug during boot then login
554 Normally, at this point, you simply press ENTER. However, you may supply
555 options for the boot if you wish.
557 Once it has booted, you will be requested to login something like:
565 You will be in the root directory, and you can proceed to
568 The complete Bacula rescue part of the CD will be in the directory: {\bf
569 /bacula-hostname}, where hostname is replaced by the name of the host machine
570 on which you did the build for the CDROM. This naming procedure allows you to
571 put multiple restore environments for each of your machines on a single CDROM
572 if you so wish to do. Please see the README document in the {\bf
573 rescue/linux/cdrom} directory for more information on adding to the CDROM.
575 \paragraph*{Start the Network:}
577 At this point, you should bring up your network. Normally, this is quite
578 simple and requires just a few commands. Please cd into the /bacula-hostname
579 directory before continuing. To simplify your task, we have created a script
580 that should work in most cases by typing:
589 You can test it by pinging another machine, or pinging your broken machine
590 machine from another machine. Do not proceed until your network is up.
592 \paragraph*{Partition Your Hard Disk(s):}
594 Assuming that your hard disk crashed and needs repartitioning, proceed with:
602 If you have multiple disks, do the same for each of them. For SCSI disks, the
603 repartition script will be named: {\bf partition.sda}. If the script complains
604 about the disk being in use, simply go back and redo the {\bf df} command and
605 {\bf umount} commands until you no longer have your hard disk mounted. Note,
606 in many cases, if your hard disk was seriously damaged or a new one installed,
607 it will not automatically be mounted. If it is mounted, it is because the
608 emergency kernel found one or more possibly valid partitions.
610 If for some reason this procedure does not work, you can use the information
611 in {\bf partition.hda} to re-partition your disks by hand using {\bf fdisk}.
613 \paragraph*{Format Your Hard Disk(s):}
615 If you have repartitioned your hard disk, you must format it appropriately.
616 The formatting script will put back swap partitions, normal Unix partitions
617 (ext2) and journaled partitions (ext3) as well as Reiser partitions (rei). Do
618 so by entering for each disk:
626 The format script will ask you if you want a block check done. We recommend to
627 answer yes, but realize that for very large disks this can take hours.
629 \paragraph*{Mount the Newly Formatted Disks:}
631 Once the disks are partitioned and formatted, you can remount them with the
632 {\bf mount\_drives} script. All your drives must be mounted for Bacula to be
633 able to access them. Run the script as follows:
642 The {\bf df} command will tell you if the drives are mounted. If not, re-run
643 the script again. It isn't always easy to figure out and create the mount
644 points and the mounts in the proper order, so repeating the {\bf
645 ./mount\_drives} command will not cause any harm and will most likely work the
646 second time. If not, correct it by hand before continuing.
648 \paragraph*{Start the Network:}
650 Before starting the File Daemon, you must bring up the network
651 so that it can communicate with the Director and Storage daemon.
652 Generally you can do so by running:
662 \paragraph*{Restore and Start the File Daemon:}
664 If you have booted with a Bacula Rescue CDROM, your statically linked Bacula
665 File daemon and the bacula-fd.conf file will be in the /bacula-hostname/bin
666 directory. Make sure {\bf bacula-fd} and {\bf bacula-fd.conf} are both there.
668 If you did not already install a correct conf file, please
669 edit the Bacula configuration file, create the working/pid/subsys directory if
670 you haven't already done so above, and start Bacula. Before starting Bacula,
671 you will need to move it and bacula-fd.conf from /bacula-hostname/bin, to the
672 /mnt/disk/tmp directory so that it will be on your hard disk. Then start it
673 with the following command:
677 chroot /mnt/disk /tmp/bacula-fd -c /tmp/bacula-fd.conf
681 The above command starts the Bacula File daemon with the proper root disk
682 location (i.e. {\bf /mnt/disk/tmp}. If Bacula does not start, correct the
683 problem and start it. You can check if it is running by entering:
691 You can kill Bacula by entering:
699 where {\bf pid} is the first number printed in front of the first occurrence
700 of {\bf bacula-fd} in the {\bf ps fax} command.
702 Now, you should be able to use another computer with Bacula installed to check
703 the status by entering:
711 into the Console program, where xxxx is the name of the client you are
714 One common problem is that your {\bf bacula-dir.conf} may contain machine
715 addresses that are not properly resolved on the stripped down system to be
716 restored because it is not running DNS. This is particularly true for the
717 address in the Storage resource of the Director, which may be very well
718 resolved on the Director's machine, but not on the machine being restored and
719 running the File daemon. In that case, be prepared to edit {\bf
720 bacula-dir.conf} to replace the name of the Storage daemon's domain name with
723 \paragraph*{Restore Your Files:}
725 On the computer that is running the Director, you now run a {\bf restore}
726 command and select the files to be restored (normally everything), but before
727 starting the restore, there is one final change you must make using the {\bf
728 mod} option. You must change the {\bf Where} directory to be the root by using
729 the {\bf mod} option just before running the job and selecting {\bf Where}.
738 then run the restore.
740 You might be tempted to avoid using {\bf chroot} and running Bacula directly
741 and then using a {\bf Where} to specify a destination of {\bf /mnt/disk}. This
742 is possible, however, the current version of Bacula always restores files to
743 the new location, and thus any soft links that have been specified with
744 absolute paths will end up with {\bf /mnt/disk} prefixed to them. In general
745 this is not fatal to getting your system running, but be aware that you will
746 have to fix these links if you do not use {\bf chroot}.
748 \paragraph*{Final Step:}
750 At this point, the restore should have finished with no errors, and all your
751 files will be restored. One last task remains and that is to write a new boot
752 sector so that your machine will boot. For {\bf lilo}, you enter the following
761 If you are using grub instead of lilo, you must enter the following:
769 Note, I've had quite a number of problems with {\bf grub} because it is rather
770 complicated and not designed to install easily under a simplified system.
771 In fact, the ./run\_grub script is not going to work on most Linux 2.6 kernels
772 with the latest grub, because grub-install references /usr/share/grub/...
773 and it uses /dev/pts, which will not be in /dev if you are using udev (as
774 do many 2.6 kernels).
776 So, if you experience errors or end up unexpectedly in a {\bf chroot}
777 shell, simply exit back to the normal shell and type in the appropriate
778 commands from the {\bf run\_grub} script by hand until you get it to
779 install. When you run the run\_grub script, it will print the commands
780 that you should manually enter if that is necessary.
782 In my more recent tests on FC4 running a 2.6.14 kernel and udev, I see that
783 because of the above mentioned problems with grub, you will need version
784 1.8.2 rescue disk or later, and you may be more successful in getting grub
785 to run by running it directly from the command line while logged into the
790 /sbin/grub-install --root-directory=/mnt/disk /dev/hda
794 Note, in this case, you omit the chroot command, and you must
795 replace /dev/hda with your boot device. If you don't know what your
796 boot device is, run the ./run\_grub script once and it will tell
799 Finally, I've even run into a case where grub-install was unable to
800 rewrite the boot block. In my case, it produced the following error
805 /dev/hdx does not have any corresponding BIOS drive.
809 The solution is to insure that all your disks are properly mounted on
810 /mnt/disk, then do the following:
819 Then edit the file {\bf /boot/grub/grub.conf} and uncomment the line
836 Note, the /dev/hda may be /dev/sda or possibly some other drive depending
837 on your configuration, but in any case, it is the same as the one that
838 you previously tried with {\bf grub-install}.
840 Then, enter the following commands:
844 grub --batch --device-map=/boot/grub/device.map \
845 --config-file=/boot/grub/grub.conf --no-floppy
852 If the {\bf grub} call worked, you will get a prompt of {\bf grub\gt{}}
853 before the {\bf root}, {\bf setup}, and {\bf quit} commands, and after
854 entering the {\bf setup} command, it should indicate that it successfully
855 wrote the MBR (master boot record).
860 First unmount all your hard disks, otherwise they will not be cleanly
861 shutdown, then reboot your machine by entering {\bf exit} until you get to the
862 main prompt then enter {\bf Ctrl-d}. Once back to the main CDROM prompt, you
863 will need to turn the power off, then back on to your machine to get it to
866 If everything went well, you should now be back up and running. If not,
867 re-insert the emergency boot CDROM, boot, and figure out what is wrong.
869 \label{restore_server}
870 \section{Restoring a Server}
871 \index[general]{Restoring a Server}
872 \index[general]{Server!Restoring a}
874 Above, we considered how to recover a client machine where a valid Bacula
875 server was running on another machine. However, what happens if your server
876 goes down and you no longer have a running Director, Catalog, or Storage
877 daemon? There are several solutions:
880 \item Bring up static versions of your Director, Catalog, and Storage daemon
881 on the damaged machine.
883 \item Move your server to another machine.
885 \item Use a Hot Spare Server on another Machine.
888 The first option, is very difficult because it requires you to have created a
889 static version of the Director and the Storage daemon as well as the Catalog.
890 If the Catalog uses MySQL or PostgreSQL, this may or may not be possible. In
891 addition, to loading all these programs on a bare system (quite possible), you
892 will need to make sure you have a valid driver for your tape drive.
894 The second suggestion is probably a much simpler solution, and one I have done
895 myself. To do so, you might want to consider the following steps:
898 \item If you are using MySQL or PostgreSQL, configure, build and install it
899 from source (or use rpms) on your new system.
900 \item Load the Bacula source code onto your new system, configure, install
901 it, and create the Bacula database.
902 \item Ideally, you will have a copy of all the Bacula conf files that
903 were being used on your server. If not, you will at a minimum need
904 create a bacula-dir.conf that has the same Client resource that
905 was used to backup your system.
906 \item If you have a valid saved Bootstrap file as created for your damaged
907 machine with WriteBootstrap, use it to restore the files to the damaged
908 machine, where you have loaded a static Bacula File daemon using the
909 Bacula Rescue disk). This is done by using the restore command and at
910 the yes/mod/no prompt, selecting {\bf mod} then specifying the path to
912 \item If you have the Bootstrap file, you should now be back up and running,
913 if you do not have a Bootstrap file, continue with the suggestions below.
914 \item Using {\bf bscan} scan the last set of backup tapes into your MySQL,
915 PostgreSQL or SQLite database.
916 \item Start Bacula, and using the Console {\bf restore} command, restore the
917 last valid copy of the Bacula database and the Bacula configuration
919 \item Move the database to the correct location.
920 \item Start the database, and restart Bacula. Then use the Console {\bf
921 restore} command, restore all the files on the damaged machine, where you
922 have loaded a Bacula File daemon using the Bacula Rescue disk.
925 For additional details of restoring your database, please see the
926 \ilink{Restoring When Things Go Wrong}{database_restore} section
927 of the Console Restore Command chapter of this manual.
931 \section{Linux Problems or Bugs}
932 \index[general]{Bugs!Linux Problems or}
933 \index[general]{Linux Problems or Bugs}
935 Since every flavor and every release of Linux is different, there are likely
936 to be some small difficulties with the scripts, so please be prepared to edit
937 them in a minimal environment. A rudimentary knowledge of {\bf vi} is very
938 useful. Also, these scripts do not do everything. You will need to reformat
939 Windows partitions by hand, for example.
941 Getting the boot loader back can be a problem if you are using {\bf grub}
942 because it is so complicated. If all else fails, reboot your system from your
943 floppy but using the restored disk image, then proceed to a reinstallation of
944 grub (looking at the run-grub script can help). By contrast, lilo is a piece
948 \section{Bare Metal Recovery using a LiveCD}
949 \index[general]{Bare Metal Recovery using a LiveCD}
950 \index[general]{Recovery!Bare Metal Recovery using a LiveCD}
951 \index[general]{Rescue!Bare Metal Recovery using a LiveCD}
952 \index[general]{LiveCD!Bare Metal Recovery using a LiveCD}
954 Rather than building a full Bacula Rescue CDROM, you can use any
955 system rescue or LiveCD to recover your system. The big problem
956 with most rescue or LiveCDs is that they are not designed to
957 capture the current state of your system, so when you boot them on
958 a damaged system, you might be somewhat lost -- e.g. how many of
959 you remember your exact hard disk partitioning.
961 This lack can be easily corrected by running the part of the
962 Bacula Rescue code that creates a directory containing a
963 static-bacula-fd, a snapshot of your current system disk
964 configuration, and scripts that help restoring it.
966 The procedure is similar to creating and your Bacula Rescue CDROM
967 described above, but with the following differences:
969 Before a disaster strikes:
971 \item Run only the {\bf make bacula} part of the
972 Bacula Rescue procedure to create the static Bacula
973 File daemon, and system disk snapshot.
974 \item Save the directory generated (more details below)
975 preferrably on a CDROM or alternatively to some other
977 \item Possibly run {\bf make bacula} every night as
978 part of your backup process to ensure that you have
979 a current snapshot of your system.
982 Then when disaster strikes, do the following:
985 \item Boot with your system rescue disk or LiveCD
987 \item Start the Network (local network).
988 \item Copy the Bacula recovery directory to the
989 damaged system using ftp, scp, wget or if your
990 boot disk permits it reading it directly from a
992 \item Continue as documented above as if you were
993 using the Bacula Rescue CDROM -- that is.
994 \item Re-partition your hard disk(s) as it was before,
996 \item Re-format your partitions, if necessary.
997 \item Restore the Bacula File daemon (static version).
998 \item Perform a Bacula restore of all your files.
999 \item Re-install your boot loader.
1003 In order to create the Bacula recovery directory, you need
1004 a copy of the Bacula Rescue code as described above, and
1005 you must first configure that directory (and possibly your
1006 Bacula source) as described above in the section entitled
1007 \ilink{Creating a Bacula Rescue CDROM}{CreateRescue}.
1009 Once the configuration is done, you can do the following
1010 to create the Bacula recovery directory:
1014 cd <bacula-rescue-source>/linux/cdrom
1020 The directory you want to save will be created in
1021 the current directory with the name {\bf bacula}. You
1022 need only save that directory either as a directory or
1023 possibly as a compressed tar file. If you run this procedure
1024 on multiple machines, you will probably want to rename this directory
1025 to something like {\bf bacula-hostname}.
1030 \section{FreeBSD Bare Metal Recovery}
1031 \index[general]{Recovery!FreeBSD Bare Metal}
1032 \index[general]{Rescue!FreeBSD Bare Metal}
1033 \index[general]{FreeBSD Bare Metal Recovery}
1035 The same basic techniques described above also apply to FreeBSD. Although we
1036 don't yet have a fully automated procedure, Alex Torres Molina has provided us
1037 with the following instructions with a few additions from Jesse Guardiani and
1041 \item Boot with the FreeBSD installation disk
1042 \item Go to Custom, Partition and create your slices and go to Label and
1043 create the partitions that you want. Apply changes.
1044 \item Go to Fixit to start an emergency console.
1045 \item Create devs ad0 .. .. if they don't exist under /mnt2/dev (in my situation)
1046 with MAKEDEV. The device or devices you create depend on what hard drives you
1047 have. ad0 is your first ATA drive. da0 would by your first SCSI drive. Under
1048 OS version 5 and greater, your device files are most likely automatically
1050 \item mkdir /mnt/disk
1051 this is the root of the new disk
1052 \item mount /mnt2/dev/ad0s1a /mnt/disk
1053 mount /mnt2/dev/ad0s1c /mnt/disk/var
1054 mount /mnt2/dev/ad0s1d /mnt/disk/usr
1056 The same hard drive issues as above apply here too. Note, under OS version 5
1057 or higher, your disk devices may be in /dev not /mnt2/dev.
1058 \item Network configuration (ifconfig xl0 ip/mask + route add default
1060 \item mkdir /mnt/disk/tmp
1061 \item cd /mnt/disk/tmp
1062 \item Copy bacula-fd and bacula-fd.conf to this path
1063 \item If you need to, use sftp to copy files, after which you must do this:
1064 ln -s /mnt2/usr/bin /usr/bin
1065 \item chmod u+x bacula-fd
1066 \item Modify bacula-fd.conf to fit this machine
1067 \item Copy /bin/sh to /mnt/disk, necessary for chroot
1068 \item Don't forget to put your bacula-dir's IP address and domain name in
1069 /mnt/disk/etc/hosts if it's not on a public net. Otherwise the FD on the
1070 machine you are restoring to won't be able to contact the SD and DIR on the
1072 \item mkdir -p /mnt/disk/var/db/bacula
1073 \item chroot /mnt/disk /tmp/bacula-fd -c /tmp/bacula-fd.conf
1075 \item Now you can go to bacula-dir and restore the job with the entire
1076 contents of the broken server.
1077 \item You must create /proc
1081 \section{Solaris Bare Metal Recovery}
1082 \index[general]{Solaris Bare Metal Recovery}
1083 \index[general]{Recovery!Solaris Bare Metal}
1085 The same basic techniques described above apply to Solaris:
1088 \item the same restrictions as those given for Linux apply
1089 \item you will need to create a Bacula Rescue disk
1092 However, during the recovery phase, the boot and disk preparation procedures
1096 \item there is no need to create an emergency boot disk since it is an
1097 integrated part of the Solaris boot.
1098 \item you must partition and format your hard disk by hand following manual
1099 procedures as described in W. Curtis Preston's book "`Unix Backup \&
1103 Once the disk is partitioned, formatted and mounted, you can continue with
1104 bringing up the network and reloading Bacula.
1106 \section{Preparing Solaris Before a Disaster}
1107 \index[general]{Preparing Solaris Before a Disaster}
1108 \index[general]{Disaster!Preparing Solaris Before a}
1110 As mentioned above, before a disaster strikes, you should prepare the
1111 information needed in the case of problems. To do so, in the {\bf
1112 rescue/solaris} subdirectory enter:
1122 The {\bf getdiskinfo} script will, as in the case of Linux described above,
1123 create a subdirectory {\bf diskinfo} containing the output from several system
1124 utilities. In addition, it will contain the output from the {\bf SysAudit}
1125 program as described in Curtis Preston's book. This file {\bf
1126 diskinfo/sysaudit.bsi} will contain the disk partitioning information that
1127 will allow you to manually follow the procedures in the "`Unix Backup \&
1128 Recovery"' book to repartition and format your hard disk. In addition, the
1129 {\bf getdiskinfo} script will create a {\bf start\_network} script.
1131 Once you have your disks repartitioned and formatted, do the following:
1134 \item Start Your Network with the {\bf start\_network} script
1135 \item Restore the Bacula File daemon as documented above
1136 \item Perform a Bacula restore of all your files using the same commands as
1137 described above for Linux
1138 \item Re-install your boot loader using the instructions outlined in the
1139 "`Unix Backup \& Recovery"' book using installboot
1144 \section{Bugs and Other Considerations}
1145 \index[general]{Considerations!Bugs and Other}
1146 \index[general]{Bugs and Other Considerations}
1148 \paragraph*{Directory Modification and Access Times are Modified on pre-1.30
1151 When a pre-1.30 version of Bacula restores a directory, it first must create
1152 the directory, then it populates the directory with its files and
1153 subdirectories. The act of creating the files and subdirectories updates both
1154 the modification and access times associated with the directory itself. As a
1155 consequence, all modification and access times of all directories will be
1156 updated to the time of the restore.
1158 This has been corrected in Bacula version 1.30 and later. The directory
1159 modification and access times are reset to the value saved in the backup after
1160 all the files and subdirectories have been restored. This has been tested and
1161 verified on normal restore operations, but not verified during a bare metal
1164 \paragraph*{Strange Bootstrap Files:}
1166 If any of you look closely at the bootstrap file that is produced and used for
1167 the restore (I sure do), you will probably notice that the FileIndex item does
1168 not include all the files saved to the tape. This is because in some instances
1169 there are duplicates (especially in the case of an Incremental save), and in
1170 such circumstances, {\bf Bacula} restores only the last of multiple copies of
1171 a file or directory.
1174 \section{Disaster Recovery of Win32 Systems}
1175 \index[general]{Systems!Disaster Recovery of Win32}
1176 \index[general]{Disaster Recovery of Win32 Systems}
1178 Due to open system files, and registry problems, Bacula cannot save and
1179 restore a complete Win2K/XP/NT environment.
1181 A suggestion by Damian Coutts using Microsoft's NTBackup utility in
1182 conjunction with Bacula should permit a Full bare metal restore of Win2K/XP
1183 (and possibly NT systems). His suggestion is to do an NTBackup of the critical
1184 system state prior to running a Bacula backup with the following command:
1188 ntbackup backup systemstate /F c:\systemstate.bkf
1192 The {\bf backup} is the command, the {\bf systemstate} says to backup only the
1193 system state and not all the user files, and the {\bf /F
1194 c:\textbackslash{}systemstate.bkf} specifies where to write the state file.
1195 this file must then be saved and restored by Bacula. This command
1196 can be put in a Client Run Before Job directive so that it is automatically
1197 run during each backup, and thus saved to a Bacula Volume.
1199 To restore the system state, you first reload a base operating system, then
1200 you would use Bacula to restore all the users files and to recover the {\bf
1201 c:\textbackslash{}systemstate.bkf} file, and finally, run {\bf NTBackup} and
1202 {\bf catalogue} the system statefile, and then select it for restore. The
1203 documentation says you can't run a command line restore of the systemstate.
1205 This procedure has been confirmed to work by Ludovic Strappazon -- many
1208 A new tool is provided in the form of a bacula plugin for the BartPE rescue
1209 CD. BartPE is a self-contained WindowsXP boot CD which you can make using the
1210 PeBuilder tools available at
1211 \elink{http://www.nu2.nu/pebuilder/}{\url{http://www.nu2.nu/pebuilder/}} and a valid
1212 Windows XP SP1 CDROM. The plugin is provided as a zip archive. Unzip the file
1213 and copy the bacula directory into the plugin directory of your BartPE
1214 installation. Edit the configuration files to suit your installation and build
1215 your CD according to the instructions at Bart's site. This will permit you to
1216 boot from the cd, configure and start networking, start the bacula file client
1217 and access your director with the console program. The programs menu on the
1218 booted CD contains entries to install the file client service, start the file
1219 client service, and start the WX-Console. You can also open a command line
1220 window and CD Programs\textbackslash{}Bacula and run the command line console
1223 \section{Ownership and Permissions on Win32 Systems}
1224 \index[general]{Systems!Resetting Directory and File Ownership and Permissions
1226 \index[general]{Resetting Directory and File Ownership and Permissions on
1228 % TODO: should this be in the win32 chapter?
1230 Bacula versions after 1.31 should properly restore ownership and permissions
1231 on all WinNT/XP/2K systems. If you do experience problems, generally in
1232 restores to alternate directories because higher level directories were not
1233 backed up by Bacula, you can correct any problems with the {\bf SetACL}
1234 available under the GPL license at:
1235 \elink{http://sourceforge.net/projects/setacl/}{\url{http://sourceforge.net/project%
1238 \section{Alternate Disaster Recovery Suggestion for Win32 Systems}
1239 \index[general]{Systems!Alternate Disaster Recovery Suggestion for Win32}
1240 \index[general]{Alternate Disaster Recovery Suggestion for Win32 Systems}
1241 % TODO: should this be in the win32 chapter??
1243 Ludovic Strappazon has suggested an interesting way to backup and restore
1244 complete Win32 partitions. Simply boot your Win32 system with a Linux Rescue
1245 disk as described above for Linux, install a statically linked Bacula, and
1246 backup any of the raw partitions you want. Then to restore the system, you
1247 simply restore the raw partition or partitions. Here is the email that Ludovic
1248 recently sent on that subject:
1252 I've just finished testing my brand new cd LFS/Bacula
1253 with a raw Bacula backup and restore of my portable.
1254 I can't resist sending you the results: look at the rates !!!
1255 hunt-dir: Start Backup JobId 100, Job=HuntBackup.2003-04-17_12.58.26
1256 hunt-dir: Bacula 1.30 (14Apr03): 17-Apr-2003 13:14
1258 Job: HuntBackup.2003-04-17_12.58.26
1259 FileSet: RawPartition
1261 Client: sauvegarde-fd
1262 Start time: 17-Apr-2003 12:58
1263 End time: 17-Apr-2003 13:14
1265 Bytes Written: 10,058,586,272
1267 Software Compression: None
1268 Volume names(s): 000103
1269 Volume Session Id: 2
1270 Volume Session Time: 1050576790
1271 Last Volume Bytes: 10,080,883,520
1272 FD termination status: OK
1273 SD termination status: OK
1274 Termination: Backup OK
1275 hunt-dir: Begin pruning Jobs.
1276 hunt-dir: No Jobs found to prune.
1277 hunt-dir: Begin pruning Files.
1278 hunt-dir: No Files found to prune.
1279 hunt-dir: End auto prune.
1280 hunt-dir: Start Restore Job RestoreFilesHunt.2003-04-17_13.21.44
1281 hunt-sd: Forward spacing to file 1.
1282 hunt-dir: Bacula 1.30 (14Apr03): 17-Apr-2003 13:54
1284 Job: RestoreFilesHunt.2003-04-17_13.21.44
1285 Client: sauvegarde-fd
1286 Start time: 17-Apr-2003 13:21
1287 End time: 17-Apr-2003 13:54
1289 Bytes Restored: 10,056,130,560
1291 FD termination status: OK
1292 Termination: Restore OK
1293 hunt-dir: Begin pruning Jobs.
1294 hunt-dir: No Jobs found to prune.
1295 hunt-dir: Begin pruning Files.
1296 hunt-dir: No Files found to prune.
1297 hunt-dir: End auto prune.
1303 \section{Restoring to a Running System}
1304 \index[general]{System!Restoring to a Running}
1305 \index[general]{Restoring to a Running System}
1307 If for some reason you want to do a Full restore to a system that has a
1308 working kernel (not recommended), you will need to take care not to
1309 overwrite the following files:
1326 \section{Additional Resources}
1327 \index[general]{Additional Resources}
1328 \index[general]{Resources!Additional}
1330 Many thanks to Charles Curley who wrote
1331 \elink{Linux Complete Backup and Recovery HOWTO}
1332 {\url{http://www.tldp.org/HOWTO/Linux-Complete-Backup-and-Recovery-HOWTO/index.html%
1334 \elink{The Linux Documentation Project}{\url{http://www.tldp.org/}}. This is an
1335 excellent document on how to do Bare Metal Recovery on Linux systems, and it
1336 was this document that made me realize that Bacula could do the same thing.
1338 You can find quite a few additional resources, both commercial and free at
1339 \elink{Storage Mountain}{\url{http://www.backupcentral.com}}, formerly known as
1342 And finally, the O'Reilly book, "`Unix Backup \& Recovery"' by W. Curtis
1343 Preston covers virtually every backup and recovery topic including bare metal
1344 recovery for a large range of Unix systems.