Subsections

- Installing and Configuring SQLite -- Phase I
- Installing and Configuring SQLite -- Phase II
- Linking Bacula with SQLite
- Testing SQLite
- Re-initializing the Catalog Database
- The internal database is not supported, please do not use it.
- Internal Bacula Database

#
Installing and Configuring SQLite

Please note that SQLite both versions 2 and 3 are not network enabled, which means that they must be linked into the Director rather than accessed by the network as MySQL and PostgreSQL are. This has two consequences:

1. SQLite cannot be used in the bweb web GUI package.
2. If you use SQLite, and your Storage daemon is not on the same machine as your Director, you will need to transfer your database to the Storage daemon's machine before you can use any of the SD tools such as bscan, ...

# Installing and Configuring SQLite -- Phase I

If you use the ./configure `--`with-sqlite statement for configuring Bacula, you will need SQLite version 2.8.16 or later installed. Our standard location (for the moment) for SQLite is in the dependency package depkgs/sqlite-2.8.16. Please note that the version will be updated as new versions are available and tested.

Installing and Configuring is quite easy.

1. Download the Bacula dependency packages
2. Detar it with something like:

   tar xvfz depkgs.tar.gz

   Note, the above command requires GNU tar. If you do not have GNU tar, a command such as:

   zcat depkgs.tar.gz | tar xvf -

   will probably accomplish the same thing.

3. cd depkgs

4. make sqlite

Please note that the ./configure used to build Bacula will need to include `--`with-sqlite or `--`with-sqlite3 depending one which version of SQLite you are using. You should not use the `--`enable-batch-insert configuration parameter for Bacula if you are using SQLite version 2 as it is probably not thread safe. If you are using SQLite version 3, you may use the `--`enable-batch-insert configuration option with Bacula, but when building SQLite3 you MUST configure it with `--`enable-threadsafe and `--`enable-cross-thread-connections.

By default, SQLite3 is now run with PRAGMA synchronous=OFF this increases the speed by more than 30 time, but it also increases the possibility of a corrupted database if your server crashes (power failure or kernel bug). If you want more security, you can change the PRAGMA that is used in the file src/version.h.

At this point, you should return to completing the installation of Bacula.

#
Installing and Configuring SQLite -- Phase II

This phase is done after you have run the ./configure command to configure Bacula.

Bacula will install scripts for manipulating the database (create, delete, make tables etc) into the main installation directory. These files will be of the form *_bacula_* (e.g. create_bacula_database). These files are also available in the <bacula-src>/src/cats directory after running ./configure. If you inspect create_bacula_database, you will see that it calls create_sqlite_database. The *_bacula_* files are provided for convenience. It doesn't matter what database you have chosen; create_bacula_database will always create your database.

At this point, you can create the SQLite database and tables:

1. cd <install-directory>

   This directory contains the Bacula catalog interface routines.

2. ./make_sqlite_tables

   This script creates the SQLite database as well as the tables used by Bacula. This script will be automatically setup by the ./configure program to create a database named bacula.db in Bacula's working directory.

# Linking Bacula with SQLite

If you have followed the above steps, this will all happen automatically and the SQLite libraries will be linked into Bacula.

# Testing SQLite

We have much less "production" experience using SQLite than using MySQL. SQLite has performed flawlessly for us in all our testing. However, several users have reported corrupted databases while using SQLite. For that reason, we do not recommend it for production use.

If Bacula crashes with the following type of error when it is started:

    Using default Catalog name=MyCatalog DB=bacula
    Could not open database "bacula".
    sqlite.c:151 Unable to open Database=/var/lib/bacula/bacula.db.
    ERR=malformed database schema - unable to open a temporary database file
    for storing temporary tables

this is most likely caused by the fact that some versions of SQLite attempt to create a temporary file in the current directory. If that fails, because Bacula does not have write permission on the current directory, then you may get this errr. The solution is to start Bacula in a current directory where it has write permission.

# Re-initializing the Catalog Database

After you have done some initial testing with Bacula, you will probably want to re-initialize the catalog database and throw away all the test Jobs that you ran. To do so, you can do the following:

      cd <install-directory>
      ./drop_sqlite_tables
      ./make_sqlite_tables

Please note that all information in the database will be lost and you will be starting from scratch. If you have written on any Volumes, you must write an end of file mark on the volume so that Bacula can reuse it. Do so with:

       (stop Bacula or unmount the drive)
       mt -f /dev/nst0 rewind
       mt -f /dev/nst0 weof

Where you should replace /dev/nst0 with the appropriate tape drive device name for your machine.

#
The internal database is not supported, please do not use it.

# Internal Bacula Database

Previously it was intended to be used primarily by Bacula developers for testing; although SQLite is also a good choice for this. We do not recommend its use in general.

This database is simplistic in that it consists entirely of Bacula's internal structures appended sequentially to a file. Consequently, it is in most cases inappropriate for sites with many clients or systems with large numbers of files, or long-term production environments.

Below, you will find a table comparing the features available with SQLite and MySQL and with the internal Bacula database. At the current time, you cannot dynamically switch from one to the other, but must rebuild the Bacula source code. If you wish to experiment with both, it is possible to build both versions of Bacula and install them into separate directories.

Feature | SQLite or MySQL | Bacula
Job Record | Yes | Yes
Media Record | Yes | Yes
FileName Record | Yes | No
File Record | Yes | No
FileSet Record | Yes | Yes
Pool Record | Yes | Yes
Client Record | Yes | Yes
JobMedia Record | Yes | Yes
List Job Records | Yes | Yes
List Media Records | Yes | Yes
List Pool Records | Yes | Yes
List JobMedia Records | Yes | Yes
Delete Pool Record | Yes | Yes
Delete Media Record | Yes | Yes
Update Pool Record | Yes | Yes
Implement Verify | Yes | No
MD5 Signatures | Yes | No

In addition, since there is no SQL available, the Console commands: sqlquery, query, retention, and any other command that directly uses SQL are not available with the Internal database.