Saturday, February 25, 2012

Installing Bacula 5.2.6 with webmin on Centos 6.2

If you are looking for a free open source network backup solution, Bacula is your answer.
It's a network Client/Server based backup program that has many benefits.
To list a few:
  • Cross- platform (I installed clients on different OS's, Centos, Ubuntu, Mac OS X, Win7, WinXP, Win Vista, Solaris)
  • Totally free (It's main advantage over Amanda is that all the clients are for free and so is the GUI)
  • Relatively easy to install and manage.
  • In addition to many backup features such as: Schedules, Data & Communication encryption, Data compression, many backup levels, open files backup...
Detailed info can be found on the Project's official website: http://www.bacula.org


Installation on Centos 6.2:


The installation on Bacula is relatively easy for the Linux experienced user.


First we need to install the C and C++ compiler. As a root user:


#yum install gcc gcc-c++ autoconf automake


Bacula supports many databases engines, i will be using MySQL:
Install MySQL
#yum install mysql-server mysql mysql-devel php-mysql
Start MySQL
#service mysqld start
Set the MySQL root user password: (replace the password between brackets)
#mysql
 >use mysql;
 >UPDATE user SET Password=PASSWORD('password') WHERE user='root';
 >flush privileges;
 >exit


Installing Bacula:


#wget http://sourceforge.net/projects/bacula/files/bacula/5.2.6/bacula-5.2.6.tar.gz
#tar -xvzf bacula-5.2.6.tar.gz
#cd bacula-5.2.6
# CFLAGS="-g -Wall" ./configure \
 --prefix=/usr \
  --sbindir=/usr/sbin \
  --sysconfdir=/etc/bacula \
  --with-scriptdir=/etc/bacula \
  --enable-smartalloc \
  --with-mysql \
  --with-openssl \
  --with-working-dir=/var/bacula \
  --with-pid-dir=/var/run \
  --enable-batch-insert \
  --enable-tray-monitor \
#make
#make install

Create the Bacula MySQL Database and Tables:

#/etc/bacula/create_mysql_database -u root -p
#/etc/bacula/make_mysql_tables -u root -p
#/etc/bacula/grant_mysql_privileges -u root -p
#/etc/bacula/grant_bacula_privileges -u root -p

Set the MySQL Bacula user bacula password:

#mysql -u root -p
>UPDATE mysql.user SET Password=PASSWORD('password') WHERE user='bacula';
>flush privileges;
>exit

Configure Bacula:

#cd /etc/bacula
#vi bacula-dir.conf
Change the Director password, the Client password, the Storage password, insert the MySQL bacula user password under Catalog dbpassword = "password" and the Console password.

#vi bacula-sd.conf
Change the bacula-dir and bacula-mon password to the ones supplied in the bacula-dir.conf,   and the Archive Device under Device to whatever location on your server you want to backup up on, e.g Archive Device = /backup and later create that directory and grant it the privileges: 
#mkdir /backup
#chown bacula /backup


#vi bacula-fd.conf
Change the bacula-dir and bacula-mon passwords.


#vi bconsole.conf
Change the bacula-dir password


Start Bacula:
#cd /etc/bacula
#./bacula start


If iptables is turned on, it will be blocking the ports 9101, 9102 and 9103 that Bacula needs to communicate with its different components.
You can either turn off iptables #/etc/init.d/iptables stop or create rules to allow the above ports.


You can manage bacula from its console:
#bconsole
 Connecting to Director bacula:9101
1000 OK: bacula-dir Version: 5.2.6 (21 February 2012)
Enter a period to cancel a command.
*


For more information about the Bacula Console commands check the documentation on the website.


Webmin:


Managing bacula from a GUI interface can be done with webmin. Webmin a web-based interface for system administration for *nix.


Installing webmin:


#cat > /etc/yum.repos.d/webmin.repo << EOF
> [Webmin]
> name=Webmin Distribution Neutral
> #baseurl=http://download.webmin.com/download/yum
> mirrorlist=http://download.webmin.com/download/yum/mirrorlist
> enabled=1
> EOF

#rpm --import http://www.webmin.com/jcameron-key.asc
#yum install webmin

After its installed, you can access it from your browser by going to http://youripaddress:10000 and login with your server root user credentials.

Note: if iptables is on, either turn it off or allow port 10000.

You will find Bacula Backup System under System on the left. When you access it for the first time, it will fait to connect to the database, click on module configuration and under Bacula Database Settings chose MySQL and set the MySQL root password and finally Save.

Now you need to understand how the Pools, Volumes, Devices and Storage Daemons work together in order to properly set it up.

Clients Installation:

I will be updating this post later on client installation on different OSs, for now i have successfully installed and backed up: Windows XP, Windows Vista, Windows 7, CentOS, Ubuntu, Solaris, Mac OS X.

Contact me for any further related configuration and questions.







14 comments:

  1. If you have many *nix clients to backup with bacula and need to be able to upgrade them quickly:

    http://ccsales.com/wpblog/bacula-backup-easily-upgrade-linux-unix-based-client-shell-script/

    ReplyDelete
  2. Bless you for helping get this going. Very good document indeed.
    I did have to go back and reset the mysql pw often but all is up and running now.

    ReplyDelete
    Replies
    1. You are most welcome, let me know if you need additional help later on setting it up and configuring it.

      Delete
    2. If any have problems intalling on a centos x64 add this line “--libdir=/usr/lib64″ to your configure string when compiling Bacula from Source.

      http://www.newitperson.com/2011/01/solve-bacula-error-error-loading-shared-libraries-libbacfind-5-0-3-so-open-shared-object-file-file-directory/

      Delete
  3. I have Bacula 5.2.6(upgrading from 5.0) installed on Centos 6.2 and while it all starts OK, Bacula-Dir terminates without error and the only message I can seem to find on the server is: bacula-dir dead but subsys locked

    If I remove the subsys file that error goes away and it will then show as down, but restarting it, the server and or MySQL only brings me back to the same problem. Any ideas?

    Thanks,

    David

    ReplyDelete
    Replies
    1. Hi David,

      Actually i never upgraded from 5.0.x to 5.2.x, the upgrade i have done is from 5.2.5 to 5.2.6 which went pretty well and very smoothly.

      Did you check the official upgrade documents?

      Wassim.

      Delete
  4. i can not to make install
    i have message
    make:** no rule to make target 'install'. stop

    can you help me pleas

    ReplyDelete
  5. Thank you very much for laying this out for us. Saved me a lot of time!

    ReplyDelete
  6. here is a good tutorial, some steps e.g volume labeling were not included.

    https://sites.google.com/site/tadbirsistem/backup

    ReplyDelete
  7. Thanks for the great tutorial! Great job!

    Is there a need to install it from a tar but not from RPM? In repos CentOS 6.4 has only version 5.0 or something? On the website it's much greater?

    Could you please tell me if I will be able to set up full system backup of the system drive? For example to make such back ups in case my system SSD fails so the system immediately would load from my RAID10 where Bacula made full system backup beforehand?

    ReplyDelete
  8. Hi Wassim,

    The tutorial was very good and simple. I was able to easily install Bacula 5.2.6 on RHEL 5.5. But after installation I wasn't able to locate any way to run the bat console.

    Can you please guide on how I can run the bat console.

    Regards,
    Muzaffar Ansari

    ReplyDelete
  9. when i restore a job on webmin, it will restore

    but when i try to restore a job again... it stops responding.. seems it is waiting for something..

    but when i restore a job manually.. it runs fine

    ReplyDelete
  10. I just wanted to say thank you very much for this info. You and every body were a great help to me.

    ReplyDelete