Bacula Rescue CD
1. Introduction
Bacula is an open source backup software which permits to make full backup or incremental backup. It allows to restore a machine after a big crash with a liveCD, this method is called Bare Metal.
The default Bacula Rescue CD is very complex to implement and need a good knowledge of unix. When we execute tests on Linux Debian with the default RescueCD, we can see it can’t load differents modules such as network card (3COM) or PATA disk whereas it integrates the kernel of the machine to restore. So you should manually load modules and create devices in /dev. Moreover majority of scripts didn’t work immediately. Nevertheless the online documentary is precious and complete but this isn’t always sufficient.
If you have a good linux skills the Bacula Rescue Cd can works but the aim of this functionnality is to be useful and transparent for users who have only basic linux skills.
The idea was to simplify the work of users and to integrate this functionnality into a recent and complete live CD for a restoration. Many scripts has been rewritten such as the script to backup table of partitions, filesystem types, etc (It generates a tarball which countains 4 configuration files needed for the restoration). Moreover they didn’t need compilation like the genuine one.
We have choosen the liveCD SystemRescueCd to integrate our scripts written in bash and a Bacula client which support all except the SSL feature (problem of library libssl’s inclusion in static mode, see TODO).
2. Contents
The aim of the differents scripts are to recover a system after a disaster, of course this system has been saved before the disaster. These scripts and process are in TEST. This process is probably not fully explained, we have only used some Debian Sarge and Debian Etch for our tests. All remarks and contributions are welcome. You will find below some explainations of each liveCD’s scripts we’ve coded.
The Script copy_file.sh permits to copy the differents needed scripts into a tmpfs area to allow modifications (if you have an error and want to fix it to fit your need)
The script uapv_rescue.sh is the main script. It manages all the process.
- It manages the network configuration to allow the retrieving of the backup
- It downloads dedicated configuration files to execute many operations (format, partitioning, launch bacula’s client) from usb keys or from a tarball host on a web site
- It recreates partitions on the hard drive with configuration file specifications
- It formats the hard drive
- It mounts the formated partitions
The script launch_bacula.sh launchs the Bacula client into memory. This client has been configured in function of the original machine configuration file which should be backuped with the script make_bare.sh make_beer.sh. Make_beer.sh needs dd and sfdisk on the host to properly generate a config files tarball.
Finally the last script grub_install.sh restores grub to boot correctly.
3. Todo & possibles improvements :
- Make an option which take directly a tarball configuration file in parameter
- Realize a similar solution for Windows stations
- Improve the shell script code
- Included SSL mode in bacula client
4. Manual for a restoration with our customized LiveCD
Warning, before performing a bare metal restoration, we must dump configurations files with the script make_beer.sh and then transfer the resulting tarball on a usb key or a web site.
In your machine you’d like to restore, insert the liveCD.
- Launch the script copy_file.sh which creates directories and copy necessary scripts (copy into /root/config/)
- Go in the directory /root/config/ (cd /root/config)
- Execute uapv_rescue.sh (with option -usb if your files were on a usb key)
example : ./uapv_rescue -usb /dev/sdb1 (this mounts the usb key) - Then launch the script launch_bacula.sh which creates needed directories and execute bacula’s client with configuration countain in the dump.
- Launch bacula in the server and connect on this console (/usr/sbin/bacula-console) to restore data.
- Perform restore’s job (restore jobid=xx) on the client and modify the destination directory to /root/disk/
- When restoration is finished, you should launch the script grub_install.sh which should restore your grub (known bug with sarge:)
- Finally when the script is successfully executed, you can reboot.
5. Example of commented uapv_rescue.sh
- 1. Configuration of the network : Enter IP adress of the dead computer you'd like to restore: 192.168.10.101 Enter interface network (eth0,...): eth0 Enter your network gateway: 192.168.10.254 Enter the IP of your DNS server : 192.168.10.253 - 1. Network configuration : DONE !
You have to type the network parameters of the host you want to restore. Then if option -usb has been defined, the script should mount the usb key and finally read the tarball /save/foo.tar.gz. This file is on the root of the usb key and not in liveCD root.
- 2. Creation of some needed directories : DONE ! - 3. Mounting USB key : Usb keys online Enter a relative path of your configuration files from your usb key: /mysave/foo.tar.gz - 3. Configuration of directories and usb keys to get configuration files : DONE !
If usb’s option isn’t specified, the script asks you one or more URLs to download. It’s possible to give a directory to download all his content, for example it downloads all the tarballs in this directory. After that, you can choose with a menu your wished tarball. Enter the number of the tarball you want to use:
- 3. Configuration of url to get configuration files : Enter the number of urls to download your configuration files, usually one ? 1 Enter your HTTP URL : http://mywebserver/mysave/ - 3. Configuration of url to get configuration files : DONE ! - 4. Deflating the configuration files : - 4. Configuration choice
Choose your configuration to restore with the associated number (press 0 to exit): 1 -> confsql02c.tar.gz 2 -> conftmpstagetom1.tar.gz 3 -> confwindows.tar.gz
After the choice, It will execute automatically the script if your disk is detected.
- 4. Choice of the config files : DONE !
- 5. Counting if the number of configuration files are correct : - 5. Counting if the number of configuration files are correct : DONE ! - 6. Launching the partitioning process: This script will rewrite your partition table on /dev/hda YOU WILL LOSE ALL YOUR DATA ON DISK /dev/hda !
Are really you sure you want to continue? yes/no: yes
Partitioning disk /dev/hda
Sfdisk error !
There is an error because disks of original machine was recognized as hda, hdb … while the liveCD recognized them as sda, sdb, etc. The script should modified the configuration’s files to fit theses changes. It’s recommanded to answer yes.
- 6.1 Launching conversion of your disk if the partitioning process failed Do you want to convert your disk into hda or sda (only for the restore process, your backup will not be altered) ? (yes/no): yes Converting hda -> sda ... dump.sda Converting hda -> sda ... fstab.sda - 6.2 Relaunching partitioning with tuned configuration to fit the sysrescCD requirements : This script will rewrite your partition table on /dev/sda
The script of partitionning has launched with modifications.
YOU WILL LOSE ALL YOUR DATA ON DISK /dev/sda ! Are really you sure you want to continue? yes/no: yes
Partitioning disk /dev/sdaDisk /dev/sda: 1229 cylinders, 255 heads, 63 sectors/track Old situation: Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 364 365- 2931831 83 Linux /dev/sda2 365 1228 864 6940080 5 Extended /dev/sda5 365+ 400 36- 289138+ 82 Linux swap / Solaris New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sda1 * 63 5863724 5863662 83 Linux /dev/sda2 5863725 19743884 13880160 5 Extended /dev/sda5 5863788 6442064 578277 82 Linux swap / Solaris Successfully wrote the new partition table Re-reading the partition table ...
Sfdisk finished
Display of new partitionning table
The new partition table is: Disk /dev/sda: 1229 cylinders, 255 heads, 63 sectors/track Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System /dev/sda1 * 0+ 364 365- 2931831 83 Linux /dev/sda2 365 1228 864 6940080 5 Extended /dev/sda5 365+ 400 36- 289138+ 82 Linux swap / Solaris - 6. Launch of processus of partitioning : Done ! ! !
sfdisk sucessfull
- 7. Formatting all your partitions :
After partitionning correctly the hard disk, this script deals with formating part. Answer yes to get a clean disk.
This script will format all partitions on disk /dev/sda. IT WILL DESTROY ALL DATA ON DISK /dev/sda !!!! Are you sure you want to continue? yes/no:
Formatting /dev/sda1 -- ext3 partition Formatting ext3 success
- 8. Mounting your hard disk :
It mounts partitions in the directory mentionned in the configuration file.
Mount ext3 success partition /dev/sda1 mounted in /
Finally it umounts the usb key.
Umount usb key sucess ! ! !
Well done.
Now you have to execute launch_bacula.sh to launch a bacula client on this server.
After that, restore your files with a bacula server console AND change your restore path to : /root/disk/ (not /)
When bacula has done his job, you may want to execute grub_install script to put a bootloader… but sometimes it fails
Compilation :
This is options of compilation to generate the static-bacula-fd and the static-bacula-console
Into bacula-source :
./configure –sbindir=/root/disk/bacula-tmp/sbin –sysconfdir=/etc/bacula –with-scriptdir=/etc/bacula/scripts –enable-smartalloc –enable-static-fd –localstatedir=/root/disk/bacula-tmp –with-pid-dir=/root/disk/bacula-tmp –with-smtp-host=univ-avignon.fr –with-working-dir=/root/disk/bacula-tmp –with-subsys-dir=/root/disk/bacula-tmp –mandir=/root/disk/bacula-tmp –with-readline=yes –with-gzip –with-acl –with-mysql –enable-static-cons
Links
