
#include "bacula_template.inc" title="Installing and Configuring SQLite" num=26

<h1>Installing and Configuring SQLite</h1>

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

<p>Installing and Configuring is quite easy.

<p>
<ol type="1">
    <li>Download the Bacula dependency packages</li>
        <li>Detar it with something like:<p></p>
        <b>tar xvfz depkgs.tar.gz</b>
        <p>Note, the above command requires GNU tar. If you do not
        have GNU tar, a command such as:<p>
        <b>zcat depkgs.tar.gz | tar xvf -</b><p>
        will probably accomplish the same thing. </li>
        <p>
        <li><b>cd depkgs</b><p></p></li>
        <p>
        <li><b>make sqlite</b></li>
        <p>

</ol>
At this point, you should return to completing the installation
of <b>Bacula</b>.  

<p>Please note that the <b>./configure</b> used to build
<b>Bacula</b> will need to include <b>--with-sqlite</b>.

<h2>Installing and Configuring SQLite -- Phase II</h2>
This phase is done <b>after</b> you have run the 
<b>./configure</b> command to configure <b>Bacula</b>. 

<p>
<b>Bacula</b> 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 &lt;bacula-src&gt;/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.

<p>
At this point, you can create the SQLite database and
tables:
<p>
<ol type="1">
  <li>cd &lt;install-directory&gt;<p></p>
     This directory contains the Bacula catalog 
     interface routines.</li>
     <p>
  <li>./make_sqlite_tables<p></p>
     This script creates the SQLite database as well as the
     tables used by <b>Bacula</b>. This script will be
     automatically setup by the <b>./configure</b> program
     to create a database named <b>bacula.db</b> in <b>Bacula's</b>
     working directory. </li>
</ol>
<p></p>


<h2>Linking Bacula with SQLite</h2>
If you have followed the above steps, this will all
happen automatically and the SQLite libraries will be
linked into <b>Bacula</b>.

<h2>Testing SQLite</h2>
As of this date (20 March 2002), we have much less 
&quot;production&quot; experience
using SQLite than using MySQL. That said, we should note that
SQLite has performed flawlessly for us in all our testing.

<h2>Re-initializing the Catalog Database</h2>
After you have done some initial testing with <b>Bacula</b>, 
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:
<pre>
  cd &lt;install-directory&gt;
  ./drop_sqlite_tables
  ./make_sqlite_tables
</pre>
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 and end of file
mark on the volume so that Bacula can reuse it.
Do so with:
<pre>
   (stop Bacula or unmount the drive)
   mt -f /dev/nst0 rewind
   mt -f /dev/nst0 weof
</pre>

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

<page_prev name="Installing and Configuring PostgreSQL" url="postgresql.html">
<page_next name="Internal Bacula Database" url="internaldb.html">
