Friday, August 27, 2010

How to install and configure Bacula

SkyHi @ Friday, August 27, 2010
Bacula is an on-linebased back up tool. Which is used to backup files from different servers into back up server where the bacula is running. For setup this backup tool across network first you have to install bacula server package on backup server machine where you are storing your backup contents ,and install bacula client daemon on all other servers from where we are going to backup data.


Bacula has five main components.

1.Director daemon

This daemon co-ordinate all working of backup,and through its configuration file we can specify all these things.

2.File daemon

This daemon works in all clients from that client we are backup data. Director daemon connect to this daemon after authentication and backup the files from this client.

3.Storage daemon

This daemon is for store the backup data from client in to hard disk of backup server,usually this daemon and director daemon works in the same backup server. director works as intermediate between the file daemon and storage daemon.

4.Console daemon

This is a terminal to control all works.This console connect to director daemon and using its commands we can define all things related with backup .

5.Catalog Database

The database used here is for store all information related to the backup, including the file indexing.Commonly used database for bacula is Mysql.


This figure shows how the different bacula daemon configuration files were linked together.
bacula

Install and Configure Bacula Server

You can install bacula from rpm packages or from Source compilation. Here we are focusing on the source method,which is tested and is working fine.
* Download latest version of bacula from bacula.org site .
Here we are using following versions

 
1. bacula-3.0.3.tar.gz (http://sourceforge.net/projects/bacula/files/bacula/3.0.3/bacula-3.0.3.tar.gz/download)

2. depkgs-18Feb09.tar.gz or later versions (http://sourceforge.net/projects/bacula/files/depkgs/18Feb09/depkgs-18Feb09.tar.gz/download)


 This two packages are used to setup a bacula,In which you have to install depkgs-18Feb09.tar.gz first to solve remaining dependency problems before starting bacula-3.0.3.tar.gz. You should not hesitate to install depkgs-18Feb09.tar.gz ,it contains different packages ,in which you can install “mtx and qwt”. you need not install sqlite database because mysql is the default database.

tar -xzf depkgs-18Feb09.tar.gz
cd depkgs
make qwt
make mtx
gmake mtx-instal
 
 
Then Enter in to the bacula source directory and Use the following configurations settings to install bacula (Or You can use system default configuration)
  
 
CFLAGS="-g -O2" \
./configure \
--sbindir=/usr/local/bacula/bin \
--sysconfdir=/usr/local/bacula/bin \
--with-pid-dir=/usr/local/bacula/bin/working \
--with-subsys-dir=/usr/local/bacula/bin/working \
--enable-smartalloc \
--with-mysql \
--with-working-dir=/usr/local/bacula/ \
 --with-dump-email=user.name=@????.se \     #The mail addresses is to mail all activities of your backup in to your inbox.
--with-job-email=user.name@????.se \
--with-smtp-host=localhost \
--enable-bat \
--with-qwt=/usr/local/qwt-5.0.2/        #path to qwt source folder( usually it is inside depkg folder that you are installed previously)
 
 
make

make install

make install-autostart   #only supported for the officially supported systems (Redhat/Fedora...).This will put all startup script into the /etc/init.d/ folder and corresponding syslinks , so automatically start corresponding daemon at  startup.
make distclean  # type this to clear all configuration settings if you are starting ./configure from beginning.
 

Now you are successful completed the installation of bacula server , then type
Then we have to setup the Database to store the catalog information.Most commonly used database is Mysql,and setup the corresponding users,databases and privileges for the bacula application.
 /etc/init.d/mysqld start

Bacula installation has included some scripts to complete the initial database and other server setups, these scripts are under your bin folder of the installed directory.
 
cd /bin

./grant_mysql_privileges -u root -p
 
 Create database
./create_mysql_database -u root -p
./make_mysql_tables -u root -p
 
 
create a directory called working under /usr/local/bacula/bin/
Afrer installation of bacula. navigate to installed folder and run bacula by typing
 
./bacula start
 
 
 
This will start all three daemons ( bacula-dir,bacula-sd and bacula-fd)
And then check ports where these daemons are listening.
 
 
default case:

daemon    |  port
===================
bacula-dir   9101
bacula-fd    9102
bacula-sd    9103

make sure that the above mentioned ports are added and opened in the csf.conf file of the server or in some other firewall settings
 
 
 
After successful installation to start the sample backup from same system where you installed all three daemons . Follow this simple tutorial :
http://www.bacula.org/en/rel-manual/Brief_Tutorial.html#TutorialChapter
To administrate  bacula it  provide a console or terminal named as bconsole . Using this console we can do all work from back end.
NB: For installation from source package, after detar you should read the README and INSTALL files. Most of the time this will helps you to complete installation.

Install and Configure Bacula Client

CFLAGS="-g -O2" ./configure  --bindir=/usr/local/bacula/bin --sysconfdir=/usr/local/bacula/bin --with-pid-dir=/usr/local/bacula/bin/working --with-subsys-dir=/usr/local/bacula/bin/working --enable-smartalloc --with-working-dir=/usr/local/bacula/ --with-dump-email=user@yourdomain.com --with-job-email=user@yourdomain.com  --with-smtp-host=localhost  --with-qwt=../depkgs/qwt-5.0.2/(here path to qwt source) --enable-client-only
 
 
If your system is 64-bit(To know it use the command arch ) then add –libdir=/usr/local/lib64

make

make install

make install-autostart-fd     //It helps start client daemon at start up.


create a directory called working under /usr/local/bacula/bin/
start the file daemon using
 /etc/init.d/bacula-fd start
 
add a new “client”and “job” in to the bacula-dir.conf
and set the password in the in the conf’s as shown in the above figure (Use above tutorial also)

Use Follwing configuration checking if you have any problems with the bacula setup

 

 
a) Client bacula-fd daemon listening to 9102
b) Edit bacula-fd.conf ,Change the Director name and password to Director name and client resource password in the  bacula-dir.conf
    file of the Server.
c) Add server hostname to the /etc/hosts of the client system, inorder to ensure correct resolution.

d) Also check the ports 9102 to listen server request and 9103 to contact server storage daemon by typing

telnet server-hostname 9103 (from client )
telnet client-hostname 9102  (from server)
 
 
========================================================================================
Above procedure is the standard installation steps ; You can download and use the documentation (*.gz) package from bacula.org for more details.
========================================================================================

SET UP WEB BASED INTERFACE TO MONITOR BACULA( php and perl based)

—————————————————————————————————————-
( Install this package in your backup server where your bacula-server is installed)
1.Bweb web based comprehensive admin tool
Bweb developed up on perl,so in order to install bweb we need to install some perl dependencies files.
you can use cpan.
You can install this tool just following the INSTALL file under bacula-gui-XXX/bweb/. This file is more than enough to complete the installation of bweb.
2. bacula-gui-3.0.3.tar.gz
Download this package to setup web interface .
Detar this package and Read README to complete installtaion [in this package You need not type ‘make or make install’ , just
1./configure --with-bacula=(path to bacula source folder)
Then copy the bacula-web from this source folder and place it in your document root of the apache.
NB: This gui was only tested with php 4.3.4 and php-5.0.4,later. you may get blank page while you are using later versions.check the error log and correct it (may be some permission error ). If you have any problem to install php 4.3.4 with your latest apache 2.2.* then go for apache 2.0.* versions.
Here we tested the following versions.
1.Install pear DB by typing “#pear install DB ”
2.apache 2.0.63
3.php-4.3.4
After installation web-servercopy copy folder bacula-web to its document root , then type : http://system-ip:/bacula-web

Some Error Fixes:

————————————
1.If your configuration of server and clients seems to be correct, but you still receiving  this error
eg:”: Fatal error: bsock.c:135 Unable to connect to Client: server.client.com-fd on server.client.com:9102. ERR=Interrupted system call ”
* Please check the firewall configurations,whether ports 9102 not blocked at client server and 9101or 9102 are not blocked at server .
* To check this telnet to destination port. If the system is installed with csf ,then check the TCP IN and OUT allowed ports.

 REFERENCES