NOTE: This post is now outdated and the latest post covering Bacula & PostgreSQL can be found here.

Bacula Tapes Bacula is an open-source, enterprise-level computer backup system for heterogeneous networks. Bacula is by far the most popular Open Source backup program. It is designed to automate backup tasks that had often required intervention from a systems administrator or computer operator. Bacula supports Linux, UNIX, Windows, and macOS backup clients, and a range of professional backup devices including tape libraries.

In this post, I will install and configure Bacula with PostgreSQL. PostgreSQL is the default database for Bacula on FreeBSD. Using MySQL requires installing Bacula from ports and setting make options, which I will not be covering in this post.

Bacula PostgreSQL Setup

First and foremost we install, initialize and then start our PostgreSQL server.

pkg install postgresql93-server
service postgresql initdb
service postgresql start

Next we log into the PostgreSQL server and add the Bacula user. First we su into the user pgsql that was created when we installed PostgresSQL. Then we access the server via the psql command before finally adding the Bacula user. The -d flag allows the user to create databases.

# su - pgsql
> psql 
postgres=# createuser -d bacula

Bacula provides 3 scripts (grant_bacula_privileges, create_bacula_database and make_bacula_table) in the /usr/local/share/bacula/ directory that we will use to assist us in creating the Bacula database and its user.

Follow these commands to setup our database for Bacula.

cd /usr/local/share/bacula/
./create_bacula_database
./make_bacula_tables
./grant_bacula_privileges

That almost takes care of all the configuration that is needed for Bacula. We still have to set access for Bacula which is as follows.

Setup Host Based Authentication in PostgreSQL

Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in the database cluster’s data directory. (HBA stands for host-based authentication.) A default pg_hba.conf file is installed when the data directory is initialized by initdb. Here we set directives to allow Bacula access.

sed -i -e 's/^local.*$/local   all     pgsql   trust/' /usr/local/pgsql/data/pg_hba.conf
echo "local   bacula  bacula  md5" >> /usr/local/pgsql/data/pg_hba.conf 
service postgresql restart

Finally we create the password in PostgreSQL

# su - pgsql
> psql bacula
bacula=# alter user bacula with password 'secret';
ALTER ROLE
bacula=# \q

Starting Bacula

As always, We need to add the necessary directives to the /etc/rc.conf file.

cat  << EOF >>  /etc/rc.conf
bacula_dir_enable="YES"
bacula_fd_enable="YES"
bacula_sd_enable="YES"
EOF

And then it is just a matter of starting all the necessary services.

service bacula-dir start
service bacula-sd start
service bacula-fd start

Wrapping Up

Over the next few weeks I will post on a detailed Bacula configuration. From dealing with the bacula-dir.conf file all the way to formatting & labeling media so that you can use Bacula in your environment. Whilst, the Bacula Main Document is very detailed, I hope my posts will provide a good start in a real world situation.