1.. _RescueChapter:
2
3Disaster Recovery Using Bareos
4==============================
5
6:index:`\ <single: Disaster; Recovery>`\  :index:`\ <single: Recovery; Disaster Recovery>`\
7
8General
9-------
10
11When 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?
12
13Unfortunately, many of the steps one must take before and immediately after a disaster are very much dependent on the operating system in use. As a consequence, this chapter will discuss in detail disaster recovery only for selected operating systems.
14
15Important Considerations
16~~~~~~~~~~~~~~~~~~~~~~~~
17
18Here are a few important considerations concerning disaster recovery that you should take into account before a disaster strikes.
19
20-  If the building which houses your computers burns down or is otherwise destroyed, do you have off-site backup data?
21
22-  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?
23
24-  Do you want to protect your whole system and use Bareos to recover everything? Or do you want to try to restore your system from the original installation disks, apply any other updates and only restore the user files?
25
26.. _section-before-disaster:
27
28Steps to Take Before Disaster Strikes
29-------------------------------------
30
31:index:`\ <single: Disaster; Before>`\
32
33-  Create a rescue or CDROM for your systems. Generally, they are offered by each distribution, and there are many good rescue disks on the Web
34
35-  Ensure that you always have a valid bootstrap file for your backup and that it is saved to an alternate machine. This will permit you to easily do a full restore of your system.
36
37-  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.
38
39-  Ensure that you always have a valid :ref:`bootstrap <BootstrapChapter>` file for your catalog backup that is saved to an alternate machine. This will permit you to restore your catalog more easily if needed.
40
41-  Try out how to use the Rescue CDROM before you are forced to use it in an emergency situation.
42
43-  Make a copy of your Bareos .conf files, particularly your bareos-dir.conf, and your bareos-sd.conf files, because if your server goes down, these files will be needed to get it back up and running, and they can be difficult to rebuild from memory.
44
45.. _section-BareMetalRestoreClient:
46
47Bare Metal Recovery of Bareos Clients
48-------------------------------------
49
50A so called "Bare Metal" recovery is one where you start with an empty hard disk and you restore your machine.
51
52Generally, following components are required for a Bare Metal Recovery:
53
54-  A rescue CDROM containing a copy of your OS and including the Bareos File daemon, including all libraries
55
56-  The Bareos client configuration files
57
58-  Useful: a copy of your hard disk information
59
60-  A full Bareos backup of your system
61
62.. _section-rear:
63
64Linux
65~~~~~
66
67:index:`\ <single: Disaster; Recovery; Linux>`\
68
69From the Relax-and-Recover web site (`http://relax-and-recover.org <http://relax-and-recover.org>`_):
70
71   Relax-and-Recover is a setup-and-forget Linux bare metal disaster recovery solution. It is easy to set up and requires no maintenance so there is no excuse for not using it.
72
73Relax-and-Recover (ReaR) is quite easy to use with Bareos.
74
75Installation
76^^^^^^^^^^^^
77
78Bareos is a supported backend for ReaR >= 1.15. To use the :strong:`BAREOS_CLIENT` option, ReaR >= 1.17 is required. If ReaR >= 1.17 is not part of your distribution, check the `download section on the
79ReaR website <http://relax-and-recover.org/download/>`_.
80
81Configuration
82^^^^^^^^^^^^^
83
84Assuming you have a working Bareos configuration on the system you want to protect with ReaR and Bareos references this system by the name :strong:`bareosclient-fd`, the only configuration for ReaR is:
85
86.. code-block:: cfg
87
88   BACKUP=BAREOS
89   BAREOS_CLIENT=bareosclient-fd
90
91You also need to specify in your ReaR configuration file (:file:`/etc/rear/local.conf`) where you want to store your recovery images. Please refer to the `ReaR documentation <http://relax-and-recover.org/documentation/>`_ for details.
92
93For example, if you want to create an ISO image and store it to an NFS server with the IP Address 192.168.10.1, you can use the following configuration:
94
95.. code-block:: cfg
96   :caption: Full Rear configuration in /etc/rear/local.conf
97
98   # This is default:
99   #OUTPUT=ISO
100   # Where to write the iso image
101   # You can use NFS, if you want to write your iso image to a nfs server
102   # If you leave this blank, it will
103   # be written to: /var/lib/rear/output/
104   OUTPUT_URL=nfs://192.168.10.1/rear
105   BACKUP=BAREOS
106   BAREOS_CLIENT=bareosclient-fd
107
108Backup
109^^^^^^
110
111If you have installed and configured ReaR on your system, type
112
113.. code-block:: shell-session
114   :caption: Create Rescue Image
115
116   <command>rear</command><parameter> -v mkrescue</parameter>
117
118to create the rescue image. If you used the configuration example above, you will get a bootable ISO image which can be burned onto a CD.
119
120
121
122.. warning::
123
124   This will not create a Bareos backup on your system! You will have to do that by
125   other means, e.g. by a regular Bareos backup schedule.
126   Also :command:`rear mkbackup` will not create a backup.
127   In this configuration it will only create the rescue ISO
128   (same as the :command:`rear mkrescue` command).
129
130Recovery
131^^^^^^^^
132
133In case, you want to recover your system, boot it using the generated ReaR recovery ISO. After booting log in as user **root** and type
134
135.. code-block:: shell-session
136   :caption: Restore your system using Rear and Bareos
137
138   <command>rear</command><parameter> recover</parameter>
139
140ReaR will now use the most recent backup from Bareos to restore your system. When the restore job has finished, ReaR will start a new shell which you can use to verify if the system has been restored correctly. The restored system can be found under the :file:`/mnt/local` directory. When you are done< with the verification, type ’exit’ to leave the shell, getting back to the recovery process. Finally, you will be asked to confirm that everything is correct. Type ’yes’ to continue. After that,
141ReaR will restore your bootloader. Recovery is complete.
142
143
144
145
146
147
148
149Restoring a Bareos Server
150-------------------------
151
152:index:`\ <single: Restore; Bareos Server>`\
153
154.. _section-RestoreServer:
155
156
157
158Above, we considered how to recover a client machine where a valid Bareos 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:
159
160#. Bring up static versions of your Director, Catalog, and Storage daemon on the damaged machine.
161
162#. Move your server to another machine.
163
164#. Use a Hot Spare Server on another Machine.
165
166The 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.
167
168The 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:
169
170-  Install the same database server as on the original system.
171
172-  Install Bareos and initialize the Bareos database.
173
174-  Ideally, you will have a copy of all the Bareos conf files that were being used on your server. If not, you will at a minimum need create a bareos-dir.conf that has the same Client resource that was used to backup your system.
175
176-  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 Bareos File daemon using the Rescue disk). This is done by using the restore command and at the yes/mod/no prompt, selecting mod then specifying the path to the bootstrap file.
177
178-  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.
179
180-  Using bscan scan the last set of backup tapes into your MySQL, PostgreSQL or SQLite database.
181
182-  Start Bareos, and using the Console restore command, restore the last valid copy of the Bareos database and the Bareos configuration files.
183
184-  Move the database to the correct location.
185
186-  Start the database, and restart Bareos. Then use the Console restore command, restore all the files on the damaged machine, where you have loaded a Bareos File daemon using the Rescue disk.
187
188For additional details of restoring your database, please see the :ref:`section-RestoreCatalog` chapter.
189
190
191
192
193