Introduction

Bacula is a sophisticated backup solution that can handle local and remote backups by leveraging a client-server model. It has very flexible configuration options that provide complete control over the backup environment.

Install Postgres

Before we install postgres, we should quick perform a quick update of the apt-get repository:

apt-get update

Once apt-get has updated go ahead and download Postgres and its helpful accompanying dependencies:

sudo apt-get install postgresql postgresql-contrib

With that, postgres is installed on your server.

Create Your PostgreSQL Roles and Databases

Once Postgres has been installed on your server, you can start to configure the database. Postgres uses the concept of roles to distinguish the variety of users that can connect to a database. When it is first installed on a server, the default postgres user is actual named “postgres”. The other users are specified in one of variety of ways. The common methods are ident and md5. The postgres default is to use ident authentication, tying each server user to a Postgres account. The alternative which can be set in the authentication configuration, located in “/etc/postgresql/9.1/main/pg_hba.conf “ is md5 which asks the client to supply an encrypted password. To begin creating custom users, first switch into the default user:

sudo su – postgres

Once logged in as this user, you can move forward to create more roles in your PostgreSQL system:

createuser
Enter name of role to add: newuser
Shall the new role be a superuser? (y/n) y

To outfit your user with a password, you can add the words –pwprompt to the createuser command:

createuser --pwprompt

Installing Bacula

Next, we will install the bacula components:

sudo apt-get install bacula-server bacula-director-pgsql bacula-common-pgsql bacula-console

You will be prompted to set up a database for bacula. Select “yes” to allow dbconfig-common to automatically configure the database.

Filesystem Configuration

Next, we need to create some directories to act as our backup and restore points.

Using the “-p” flag with the “mkdir” command creates any necessary parent directories along with the target directory:

sudo mkdir -p /bacula/backup /bacula/restore /etc/bacula/conf.d/clients /etc/bacula/conf.d/filesets /etc/bacula/conf.d/jobs

We need to change the file permissions so that only the bacula process can access these locations.

sudo chown -R bacula /etc/bacula
sudo chmod -R 700 /etc/bacula

Configuring Bacula

Bacula has several components that must be configured independently in order to function correctly. The configuration files can all be found in the /etc/bacula/ directory.

Configuring bacula-dir.conf

Start by editing the bacula-dir.conf file:

sudo nano /etc/bacula/bacula-dir.conf

A few different sections must be modified for the backups that we will be performing in this guide.

First, search for the “Standard Restore template” section. Under the “Job” settings, change the Where parameter to point to the restore point we created:

Job {
  Name = "RestoreFiles"
  Type = Restore
  Client=Blank-fd
  FileSet="Full Set"
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /bacula/restore
}

Next, search for the “List of files to be backed up” section. Under the “FileSet” settings, we will add an option to use gzip to compress our archives.

We will then specify exactly what we would like to backup with the “File =” parameter. You can have multiple “File =” declarations in this section, each with a different path.

For this guide, we will be backing up the entire root (/) file system. Change the parameters to reflect that:

Include {
    Options {
      signature = MD5
      compression = GZIP
    }
# 
#  Put your list of files here, preceded by 'File =', one per line
#    or include an external list with:
#
#    File = file-name
#
#  Note: / backs up everything on the root partition.
#    if you have other partitions such as /usr or /home
#    you will probably want to add them too.
#
#  By default this is defined to point to the Bacula binary
#    directory to give a reasonable FileSet to backup to
#    disk storage during initial testing.
#
    File = /
  }

Finally, add file paths to be excluded from the backup. This is done in the Exclude section of the FileSet directory by using the same “File =” syntax that we used in the Include section.

The defaults are generally good here, but we need to change the path to the archive directory. We do not want to backup the backup folder. Change the second “File =” to reflect our root bacula file path:

Exclude {
    File = /var/lib/bacula
    File = /bacula
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck
  }

Save and close the file.

Configuring bacula-sd.conf

The next file we need to edit is the bacula-sd.conf file. This will define the area where bacula stores its backups.

Open the bacula-sd.conf file with sudo privileges:

sudo nano /etc/bacula/bacula-sd.conf

Under the “Devices supported by this Storage daemon” section, in the “Device” configuration, change the Archive Device to reflect the backup location we set up earlier:

Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /bacula/backup
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
}

Save and close the file.

Checking Configuration Syntax

Before continuing, check that the configuration options that we used are recognized by bacula. We can use bacula’s internal testing utilities to ensure that there are no syntax errors in the files we modified.

First, check the bacula director configuration:

sudo bacula-dir -tc /etc/bacula/bacula-dir.conf

If the command executes without returning any output, the configuration file is syntactically correct. Next, check the bacula storage configuration:

sudo bacula-sd -tc /etc/bacula/bacula-sd.conf

Again, no output signifies that our configuration file is valid.

At this time, restart the bacula services we modified to make the changes propagate:

sudo service bacula-sd restart
sudo service bacula-director restart

We are now ready to test our backups.

Install Reportula

1. Install Apache, php5

sudo apt-get install php5 php5-pgsql apache2 php5-mcrypt php5-json
sudo service apache2 restart 

2. Donwload Reportula

 https://github.com/oliveiraped/Reportula

3. Decompress to directory on your webserver

4. Open the file Reportula Instalation “reportula/application/config/database.php” and edit you database settings.

Database.php

5. Open your browser and put the url “http://yourserver/public/index.php/install”

1

 

6. Fill Up the Form and click Install

2

7. After Login Reportula at the url : “http://yourserver/public/index.php/login”

Login

8. Add Apache user to Bacula Group “apache” or “www-data”

sudo usermod apache --append --groups bacula


9. Check if Apache user can read and write /etc/bacula configuration directory.

sudo chmod ugo+wr bacula/ -R

10 . Reportula needs acess to Bacula Console (bconsole) and Bacula Director. Reportula uses “sudo”  functionality for that In this case there is need to add to /etc/sudoers below

apache_user ALL= NOPASSWD:      bconsole_path
apache_user ALL= NOPASSWD:      bacula-dir_path

For example for user called “www-data” from that HTTP service working with Reportula
there is need to add line like below:

www-data        ALL= NOPASSWD:  /usr/sbin/bconsole
www-data        ALL= NOPASSWD:  /usr/sbin/bacula-dir

Reportula is installed.