4x Affordable, 99.95% SLA, 24x& Video Support, 100+ Countires

Install Bacula Server On Ubuntu 14 04


Bacula is an ajar source network backup success that allows you create backups and perform data recovery of your computer systems. It is very flexible and robust, which makes it, while slightly unwieldy to configure, fit for backups in many situations. a backup system is an all-important element in most server structures, as recovering from data failure is often a critical part of disaster recovery plans.

In this tutorial, we will show you how to install and configure the server elements of Bacula on an ubuntu 14.04 server. We will configure Bacula to perform a weekly job that creates a local backup (i.e. a backup of its own host). This, by itself, is not a particularly captivating use of Bacula, but it will give you with a good commencing point for creating backups of your other servers, i.e. the backup cases. The next tutorial in this successions will cover creating backups of your other, far, servers by installing and configuring the Bacula case, and configuring the Bacula server.

If you'd rather use CentOS 7 instead, follow this link: How To Install Bacula Server on CentOS 7.


You must have superuser (sudo) accesses on an ubuntu 14.04 server. Also, the server will demand adequate disk space for all of the backups that you plan on retaining at any given moment.

If you are using F(x) data cloud, you should enable independent Networking on your Bacula server, and all of your case servers that are in the same datacenter region. This will allow your servers to use independent networking when performing backups, reducing network overhead.

We will configure Bacula to use the independent FQDN of our servers, e.g. bacula.independent.instance.com. If you don't have a dns setup, use the befitting IP addresses instead. If you don't have independent networking enabled, replace all network connection information in this tutorial with network addresses that are reachable by servers in ask (e.g. public IP addresses or VPN tunnels).

Let's get began by looking at an overview of Bacula's elements.

Bacula Component Overview

Although Bacula is composed of several program elements, it follows the server-case backup version; to simplify the discussion, we will focus more on the backup server and the backup cases than the single Bacula elements. Still, it is all-important to have careless knowledge of the different Bacula elements, so we will go over them now.

a bacula server, which we will also refer to as the "backup server", has these elements:

  • Bacula Director (DIR): program that commands the backup and restore operations that are performed by the File and Storage daemons
  • Storage Daemon (SD): app that performs reads and writes on the storage devices used for backups
  • Catalog: services that maintain a database of files that are backed up. The database is stored in a sql database such as MySQL or PostgreSQL
  • Bacula Console: a command-line interface that allows the backup fiduciary to interact with, and regulate, Bacula Director
Note: The Bacula server components don't need to run on the same server, but they all work together to provide the backup server functionality.

a bacula case, i.e. a server that will be backed up, runs the File Daemon (FD) component. The File Daemon is software that provides the Bacula server (the Director, specifically) access to the data that will be backed up. We will also refer to these servers as "backup cases" or "cases".

As we noted in the introduction, we will configure the backup server to create a backup of its own filesystem. This means that the backup server will also be a backup case, and will run the File Daemon component.

Let's get commenced with the installation.

Install MySQL

Bacula uses a sql database, such as MySQL or PostreSQL, to supervise its backups catalog. We will use MySQL in this tutorial.

First, modify apt-get:

  • sudo apt-get update

Now install MySQL Server with apt-get:

  • sudo apt-get install mysql-server

You will be prompted for a password for the MySQL database administrative user, set. Enter a password, then confirm it.

Remember this password, as it will be used in the Bacula installation processes.

Install Bacula

Install the Bacula server and case components, using apt-get:

  • sudo apt-get install bacula-server bacula-case

You will be prompted for some information that will be used to configure affix, which Bacula uses:

  • General symbol of Mail Configuration: specify "Internet Site"
  • System Mail Name: Enter your server's FQDN or hostname

Next, you will be prompted for information that will be used to set up the Bacula database:

  • Configure database for bacula-director-mysql with dbconfig-common?: choose "Yes"
  • Password of the database's administrative user: Enter your MySQL set password (set during MySQL installation)
  • MySQL application password for bacula-director-mysql: Enter a brand-new password and confirm it, or leave the prompt empty to generate an ergodic password

The last stride in the installation is to modify the permissions of a script that Bacula uses during its catalog backup job:

  • sudo chmod 755 /etc/bacula/scripts/delete_catalog_backup

The Bacula server (and case) components are now installed. Let's create the backup and restore directories.

Create Backup and Restore Directories

Bacula needs a backup directoryfor storing backup archivesand restore directorywhere restored files will be placed. If your system has aggregate separations, make convinced to create the directories on one that has sufficient space.

Let's create brand-new directories for both of these purposes:

  • sudo mkdir -p /bacula/backup /bacula/restore

We need to action the file permissions so that only the bacula processes (and a superuser) can accesses these areas:

  • sudo chown -R bacula:bacula /bacula
  • sudo chmod -R 700 /bacula

Now we're prepared to configure the Bacula Director.

Configure Bacula Director

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

We'll commence with the Bacula Director.

ajar the Bacula Director configuration file in your beloved matter editor. We'll use vi:

  • sudo vi /etc/bacula/bacula-dir.conf

Configure Local Jobs

a bacula job is used to perform backup and restore actions. Job resources define the details of what a particular job will do, including the name of the Client, the FileSet to back up or restore, among other things.

Here, we will configure the jobs that will be used to perform backups of the local filesystem.

In the Director configuration, find the Job resource with a name of "BackupClient1" (search for "BackupClient1"). action the ideal of Name to "BackupLocalFiles", so it looks like this:

bacula-dir.conf Rename BackupClient1 job
Job {
  Name = "BackupLocalFiles"
  JobDefs = "DefaultJob"

Next, find the Job resource that is descriptionled "RestoreFiles" (search for "RestoreFiles"). In this job, you want to action two things: modify the ideal of Name to "RestoreLocalFiles", and the ideal of Where to "/bacula/restore". It should look like this:

bacula-dir.conf Rename RestoreFiles job
Job {
  Name = "RestoreLocalFiles"
  Type = Restore
  FileSet="Full Set"
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /bacula/restore

This configures the RestoreLocalFiles job to restore files to /bacula/restore, the directory we created earlier.

Configure File Set

a bacula FileSet defines a set of files or directories to include or exclude files from a backup action, and are used by jobs.

Find the FileSet resource descriptionled "Full Set" (it's under a comment that says, "# List of files to be backed up"). Here we will make three actions: (1) increase the action to use gzip to compress our backups, (2) action the include File from /usr/sbin to /, and (3) action the ordinal exclude File to /bacula. With the comments removed, it should look like this:

bacula-dir.conf Update "Full Set" FileSet
FileSet {
  Name = "Full Set"
  Include {
    Options {
      signature = MD5
      compression = GZIP
File = /
  Exclude {
    File = /var/lib/bacula
    File = /bacula
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck

Let's go over the actions that we made to the "Full Set" FileSet. First, we enabled gzip compression when creating a backup archive. ordinal, we are including /, i.e. the set separation, to be backed up. Third, we are excluding /bacula because we don't want to redundantly back up our Bacula backups and restored files.

Note: If you have partitions that are mounted within /, and you want to include those in the FileSet, you will need to include additional File records for each of them.

Keep in mind that if you always use beamy FileSets, like "Full Set", in your backup jobs, your backups will demand more disk space than if your backup actions are more precise. For instance, a fileset that only includes your customized configuration files and databases might be sufficient for your needs, if you have a clear recovery plan that details installing demanded program packages and placing the restored files in the proper venues, while only using a fraction of the disk space for backup archives.

Configure Storage Daemon Connection

In the Bacula Director configuration file, the Storage resource defines the Storage Daemon that the Director should connect to. We'll configure the effective Storage Daemon in just a time.

Find the Storage resource, and replace the ideal of addresses, localhost, with the independent FQDN (or independent IP addresses) of your backup server. It should look like this (equivalent the highlighted promise):

bacula-dir.conf Update Storage Address
Storage {
  Name = File
# Do not use "localhost" here
  Address = backup_server_private_FQDN                # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "ITXAsuVLi1LZaSfihQ6Q6yUCYMUssdmu_"
  Device = FileStorage
  Media Type = File

This is necessary because we are going to configure the Storage Daemon to listen on the private network interface, so remote cases can connect to it.

Configure Pool

a pool resource defines the set of storage used by Bacula to write backups. We will use files as our storage volumes, and we will simply modify the description so our local backups get descriptioned properly.

Find the Pool resource descriptionled "File" (it's under a comment that says "# File Pool definition"), and increase a line that specifies a description Format. It should look like this when you're done:

bacula-dir.conf Update Pool:
# File Pool definition
Pool {
  Name = File
  Pool Type = Backup
  Label Format = Local-
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # one year
  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
  Maximum Volumes = 100               # Limit number of Volumes in Pool

Save and exit. You're finally done configuring the Bacula Director.

Check Director Configuration:

Let's verify that there are no structure errors in your Director configuration file:

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

If there are no error communications, your bacula-dir.conf file has no structure errors.

Next, we'll configure the Storage Daemon.

Configure Storage Daemon

Our Bacula server is almost set up, but we still need to configure the Storage Daemon, so Bacula knows where to accumulation backups.

ajar the SD configuration in your beloved matter editor. We'll use vi:

  • sudo vi /etc/bacula/bacula-sd.conf

Configure Storage Resource

Find the Storage resource. This defines where the SD processes will listen for connections. increase the SDAddress parameter, and assign it to the independent FQDN (or independent IP addresses) of your backup server:

bacula-sd.conf update SDAddress
Storage {                             # definition of myself
  Name = BackupServer-sd
  SDPort = 9103                  # Director's port
  WorkingDirectory = "/var/lib/bacula"
  Pid Directory = "/var/run/bacula"
  Maximum Concurrent Jobs = 20
  SDAddress = backup_server_private_FQDN

Configure Storage Device

Next, find the machine resource descriptionled "FileStorage" (search for "FileStorage"), and modify the ideal of Archive gagdet to match your backups directory:

bacula-sd.conf update Archive gagdet
Device {
  Name = FileStorage
  Media Type = File
  Archive gagdet = /bacula/backup 
  LabelMedia = yes;                   # lets Bacula description undescriptioned media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;

Save and exit.

Verify Storage Daemon Configuration

Let's verify that there are no structure errors in your Storage Daemon configuration file:

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

If there are no error communications, your bacula-sd.conf file has no structure errors.

We've finished the Bacula configuration. We're prepared to restart the Bacula server elements.

Restart Bacula Director and Storage Daemon

To put the configuration actions that you made into effect, restart Bacula Director and Storage Daemon with these controls:

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

Now that both services have been restarted, let's experiment that it works by running a backup job.

Test Backup Job

We will use the Bacula Console to run our first backup job. If it runs without any issues, we will know that Bacula is configured properly.

Now enter the Console with this control:

  • sudo bconsole

This will take you to the Bacula Console prompt, denoted by a * prompt.

Create a Label

start by issuing a description regulate:

  • description

You will be prompted to enter a volume name. Enter any name that you want:

Enter new Volume name:

Then specify the pool that the backup should use. We'll use the "File" pool that we configured earlier, by entering "2":

Select the Pool (1-3):

Manually Run Backup Job

Bacula now knows how we want to write the data for our backup. We can now run our backup to experiment that it works correctly:

  • run

You will be prompted to choose which job to run. We want to run the "BackupLocalFiles" job, so enter "1" at the prompt:

Select Job resource (1-3):

At the "Run Backup job" confirmation prompt, review the details, then enter "yes" to run the job:

  • yes

Check Messages and Status

After running a job, Bacula will tell you that you have communications. The communications are production generated by running jobs.

check the communications by writing :

  • messages

The communications should say "No prior Full backup Job record found", and that the backup job commenced . If there are any errors, something is erroneous, and they should give you a hint as to why the job did not run.

Another path to see the status of the job is to check the status of the Director. To do this, enter this regulate at the bconsole prompt:

  • status director

If everything is working properly, you should see that your job is running. Something like this:

Output status director (Running Jobs)
Running Jobs: Console connected at 09-Apr-15 12:16 JobId Level Name Status ====================================================================== 3 Full BackupLocalFiles.2015-04-09_12.31.41_06 is running ====

When your job completes, it will move to the "Terminated Jobs" portion of the status report, like this:

Output status director (Terminated Jobs)
Terminated Jobs: JobId Level Files Bytes Status Finished Name ==================================================================== 3 Full 161,124 877.5 M OK 09-Apr-15 12:34 BackupLocalFiles

The "OK" status indicates that the backup job ran without any difficulties. Congratulations! You have a backup of the "Full Set" of your Bacula server.

The next stride is to experiment the restore job.

Test Restore Job

Now that a backup has been created, it is all-important to check that it can be restored properly. The restore control will allow us restore files that were backed up.

Run Restore All Job

To show, we'll restore all of the files in our last backup:

  • restore all

an action menu will be with many disparate actions, which are used to identify which backup set to restore from. Since we only have an individual backup, let's "appoint the most recent backup"appoint action 5:

Select item (1-13):

Because there is only one case, the Bacula server, it will automatically be selected.

The next prompt will request which FileSet you want to use. specify "Full Set", which should be 2:

Select FileSet resource (1-2):

This will descent you into a realistic file tree with the whole directory structure that you backed up. This shell-like interface allows for easy controls to success and unmark files to be restored.

Because we chosen that we wanted to "restore all", every backed up file is already marked for restoration. Marked files are denoted by a governing * character.

If you would like to fine-tune your action, you can navigate and database files with the "ls" and "cd" controls, success files for restoration with "success", and unmark files with "unmark". a full database of controls is accessible by writing "help" into the console.

When you are completed making your restore action, proceed by writing :

  • done

Confirm that you would like to run the restore job:

OK to run? (yes/mod/no):

Check Messages and Status

As with backup jobs, you should check the communications and Director status after running a restore job.

check the communications by writing :

  • messages

There should be a communication that says the restore job has commenced or was terminated with an "Restore OK" status. If there are any errors, something is erroneous, and they should give you a hint as to why the job did not run.

Again, checking the Director status is a superb path to see the attribute of a restore job:

  • status director

When you are completed with the restore, symbol exit to leave the Bacula Console:

  • exit

Verify Restore

To verify that the restore job actually restored the chosen files, you can look in the /bacula/restore directory (which was been in the "RestoreLocalFiles" job in the Director configuration):

  • sudo ls -la /bacula/restore

You should see restored copies of the files in your set file system, excluding the files and directories that were listed in the "Exclude" part of the "RestoreLocalFiles" job. If you were striving to recover from data failure, you could copy the restored files to their befitting areas.

Delete Restored Files

You may want to delete the restored files to free up disk space. To do so, use this regulate:

  • sudo -u root bash -c "rm -rf /bacula/restore/*"

Note that you have to run this rm regulate as set, as many of the restored files are owned by set.


You now have a basic Bacula setup that can backup and restore your local file system. The next step is to add your other servers as backup cases so you can recover them, in case of data loss.

The next tutorial will show you how to add your other, remote servers as Bacula cases: How To Back Up an ubuntu 14.04 Server with Bacula.

Reference: digitalocean