]> git.sur5r.net Git - bacula/docs/blob - docs/manual/sqlite.tex
Update FOSDEM talk
[bacula/docs] / docs / manual / sqlite.tex
1 %%
2 %%
3
4 \chapter{Installing and Configuring SQLite}
5 \label{SqlLiteChapter}
6 \index[general]{Installing and Configuring SQLite }
7 \index[general]{SQLite!Installing and Configuring }
8
9 \section{Installing and Configuring SQLite -- Phase I}
10 \index[general]{Phase I!Installing and Configuring SQLite -- }
11 \index[general]{Installing and Configuring SQLite -- Phase I }
12
13 If you use the {\bf ./configure \verb:--:with-sqlite} statement for configuring {\bf
14 Bacula}, you will need SQLite version 2.8.16 or later installed. Our standard
15 location (for the moment) for SQLite is in the dependency package {\bf
16 depkgs/sqlite-2.8.16}. Please note that the version will be updated as new
17 versions are available and tested. 
18
19 You may install and use SQLite version 3.x with Bacula by using:
20 {\bf ./configure \verb:--:with-sqlite3}. You should ensure that
21 when the database is created that you have used 
22 \begin{verbatim}
23 PRAGMA synchronous = NORMAL;
24 \end{verbatim}
25 otherwise SQLite version 3.x is four to ten times slower than version 2.8.16.
26
27 Installing and Configuring is quite easy. 
28
29 \begin{enumerate}
30 \item Download the Bacula dependency packages  
31 \item Detar it with something like:
32
33    {\bf tar xvfz depkgs.tar.gz}  
34
35    Note, the above command requires GNU tar. If you do not  have GNU tar, a
36    command such as:
37
38    {\bf zcat depkgs.tar.gz | tar xvf -}
39
40    will probably accomplish the same thing. 
41
42 \item {\bf cd depkgs}
43
44 \item {\bf make sqlite}  
45
46 \end{enumerate}
47
48 At this point, you should return to completing the installation of {\bf
49 Bacula}. 
50
51 Please note that the {\bf ./configure} used to build {\bf Bacula} will need to
52 include {\bf \verb:--:with-sqlite}. 
53
54 \section{Installing and Configuring SQLite -- Phase II}
55 \label{phase2}
56 \index[general]{Phase II!Installing and Configuring SQLite -- }
57 \index[general]{Installing and Configuring SQLite -- Phase II }
58
59 This phase is done {\bf after} you have run the {\bf ./configure} command to
60 configure {\bf Bacula}. 
61
62 {\bf Bacula} will install scripts for manipulating the database (create,
63 delete, make tables etc) into the main installation directory. These files
64 will be of the form *\_bacula\_* (e.g. create\_bacula\_database). These files
65 are also available in the \lt{}bacula-src\gt{}/src/cats directory after
66 running ./configure. If you inspect create\_bacula\_database, you will see
67 that it calls create\_sqlite\_database. The *\_bacula\_* files are provided
68 for convenience. It doesn't matter what database you have chosen;
69 create\_bacula\_database will always create your database. 
70
71 At this point, you can create the SQLite database and tables: 
72
73 \begin{enumerate}
74 \item cd \lt{}install-directory\gt{}
75
76    This directory contains the Bacula catalog  interface routines.  
77
78 \item ./make\_sqlite\_tables
79
80    This script creates the SQLite database as well as the  tables used by {\bf
81    Bacula}. This script will be  automatically setup by the {\bf ./configure}
82    program  to create a database named {\bf bacula.db} in {\bf Bacula's}  working
83    directory. 
84 \end{enumerate}
85
86 \section{Linking Bacula with SQLite}
87 \index[general]{SQLite!Linking Bacula with }
88 \index[general]{Linking Bacula with SQLite }
89
90 If you have followed the above steps, this will all happen automatically and
91 the SQLite libraries will be linked into {\bf Bacula}. 
92
93 \section{Testing SQLite}
94 \index[general]{SQLite!Testing }
95 \index[general]{Testing SQLite }
96
97 We have much less "production" experience
98 using SQLite than using MySQL. SQLite has
99 performed flawlessly for us in all our testing. However,
100 several users have reported corrupted databases while using
101 SQLite. For that reason, we do not recommend it for production
102 use.
103
104 If Bacula crashes with the following type of error when it is started:
105 \footnotesize
106 \begin{verbatim}
107 Using default Catalog name=MyCatalog DB=bacula
108 Could not open database "bacula".
109 sqlite.c:151 Unable to open Database=/var/lib/bacula/bacula.db.
110 ERR=malformed database schema - unable to open a temporary database file
111 for storing temporary tables
112 \end{verbatim}
113 \normalsize
114
115 this is most likely caused by the fact that some versions of
116 SQLite attempt to create a temporary file in the current directory.
117 If that fails, because Bacula does not have write permission on
118 the current directory, then you may get this errr.  The solution is
119 to start Bacula in a current directory where it has write permission.
120
121
122 \section{Re-initializing the Catalog Database}
123 \index[general]{Database!Re-initializing the Catalog }
124 \index[general]{Re-initializing the Catalog Database }
125
126 After you have done some initial testing with {\bf Bacula}, you will probably
127 want to re-initialize the catalog database and throw away all the test Jobs
128 that you ran. To do so, you can do the following: 
129
130 \footnotesize
131 \begin{verbatim}
132   cd <install-directory>
133   ./drop_sqlite_tables
134   ./make_sqlite_tables
135 \end{verbatim}
136 \normalsize
137
138 Please note that all information in the database will be lost and you will be
139 starting from scratch. If you have written on any Volumes, you must write an
140 end of file mark on the volume so that Bacula can reuse it. Do so with: 
141
142 \footnotesize
143 \begin{verbatim}
144    (stop Bacula or unmount the drive)
145    mt -f /dev/nst0 rewind
146    mt -f /dev/nst0 weof
147 \end{verbatim}
148 \normalsize
149
150 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
151 device name for your machine.