]> git.sur5r.net Git - bacula/docs/blob - docs/manual-de/postgresql.tex
Add base for German manual
[bacula/docs] / docs / manual-de / postgresql.tex
1 %%
2 %%
3
4 \section*{Installing and Configuring PostgreSQL}
5 \label{_ChapterStart10}
6 \index[general]{PostgreSQL!Installing and Configuring }
7 \index[general]{Installing and Configuring PostgreSQL }
8 \addcontentsline{toc}{section}{Installing and Configuring PostgreSQL}
9
10 \subsection*{Installing and Configuring PostgreSQL -- Phase I}
11 \index[general]{Installing and Configuring PostgreSQL -- Phase I }
12 \index[general]{Phase I!Installing and Configuring PostgreSQL -- }
13 \addcontentsline{toc}{subsection}{Installing and Configuring PostgreSQL --
14 Phase I}
15
16 If you use the {\bf ./configure \verb{--{with-postgresql=PostgreSQL-Directory}
17 statement for configuring {\bf Bacula}, you will need PostgreSQL version 7.3
18 or later installed. NOTE! PostgreSQL versions earlier than 7.3 do not work
19 with Bacula. If PostgreSQL is installed in the standard system location, you
20 need only enter {\bf \verb{--{with-postgresql} since the configure program will
21 search all the standard locations. If you install PostgreSQL in your home
22 directory or some other non-standard directory, you will need to provide the
23 full path with the {\bf \verb{--{with-postgresql} option. 
24
25 Installing and configuring PostgreSQL is not difficult but can be confusing
26 the first time. If you prefer, you may want to use a package provided by your
27 chosen operating system. Binary packages are available on most PostgreSQL
28 mirrors. 
29
30 If you prefer to install from source, we recommend following the instructions
31 found in the 
32 \elink{PostgreSQL documentation}{http://www.postgresql.org/docs/}. 
33
34 If you are using FreeBSD, 
35 \elink{this FreeBSD Diary article}{http://www.freebsddiary.org/postgresql.php}
36 will be useful. Even if you are not using FreeBSD, the article will contain
37 useful configuration and setup information. 
38
39 After installing PostgreSQL, you should return to completing the installation
40 of {\bf Bacula}. Later, after Bacula is installed, come back to this chapter
41 to complete the installation. Please note, the installation files used in the
42 second phase of the PostgreSQL installation are created during the Bacula
43 Installation. 
44 \label{PostgreSQL_phase2}
45
46 \subsection*{Installing and Configuring PostgreSQL -- Phase II}
47 \index[general]{Phase II!Installing and Configuring PostgreSQL -- }
48 \index[general]{Installing and Configuring PostgreSQL -- Phase II }
49 \addcontentsline{toc}{subsection}{Installing and Configuring PostgreSQL --
50 Phase II}
51
52 At this point, you should have built and installed PostgreSQL, or already have
53 a running PostgreSQL, and you should have configured, built and installed {\bf
54 Bacula}. If not, please complete these items before proceeding. 
55
56 Please note that the {\bf ./configure} used to build {\bf Bacula} will need to
57 include {\bf \verb{--{with-postgresql=PostgreSQL-directory}, where {\bf
58 PostgreSQL-directory} is the directory name that you specified on the
59 ./configure command for configuring PostgreSQL (if you didn't specify a
60 directory or PostgreSQL is installed in a default location, you do not need to
61 specify the directory). This is needed so that Bacula can find the necessary
62 include headers and library files for interfacing to PostgreSQL. 
63
64 {\bf Bacula} will install scripts for manipulating the database (create,
65 delete, make tables etc) into the main installation directory. These files
66 will be of the form *\_bacula\_* (e.g. create\_bacula\_database). These files
67 are also available in the \lt{}bacula-src\gt{}/src/cats directory after
68 running ./configure. If you inspect create\_bacula\_database, you will see
69 that it calls create\_postgresql\_database. The *\_bacula\_* files are
70 provided for convenience. It doesn't matter what database you have chosen;
71 create\_bacula\_database will always create your database. 
72
73 Now you will create the Bacula PostgreSQL database and the tables that Bacula
74 uses. These instructions assume that you already have PostgreSQL running. You
75 will need to perform these steps as a user that is able to create new
76 databases. This can be the PostgreSQL user (on most systems, this is the pgsql
77 user). 
78
79 \begin{enumerate}
80 \item cd \lt{}install-directory\gt{}
81
82    This directory contains the Bacula catalog  interface routines.  
83
84 \item ./create\_bacula\_database
85
86    This script creates the PostgreSQL {\bf bacula} database.  
87
88 \item ./make\_bacula\_tables
89
90    This script creates the PostgreSQL tables used by {\bf Bacula}.  
91 \item ./grant\_bacula\_privileges
92
93    This script creates the database user {\bf bacula}  with restricted access
94 rights. You may  want to modify it to suit your situation. Please note that 
95 this database is not password protected.  
96
97 \end{enumerate}
98
99 Each of the three scripts (create\_bacula\_database, make\_bacula\_tables, and
100 grant\_bacula\_privileges) allows the addition of a command line argument.
101 This can be useful for specifying the user name. For example, you might need
102 to add {\bf -h hostname} to the command line to specify a remote database
103 server. 
104
105 To take a closer look at the access privileges that you have setup with the
106 above, you can do: 
107
108 \footnotesize
109 \begin{verbatim}
110 PostgreSQL-directory/bin/psql --command \\dp bacula
111 \end{verbatim}
112 \normalsize
113
114 \subsection*{Re-initializing the Catalog Database}
115 \index[general]{Database!Re-initializing the Catalog }
116 \index[general]{Re-initializing the Catalog Database }
117 \addcontentsline{toc}{subsection}{Re-initializing the Catalog Database}
118
119 After you have done some initial testing with {\bf Bacula}, you will probably
120 want to re-initialize the catalog database and throw away all the test Jobs
121 that you ran. To do so, you can do the following: 
122
123 \footnotesize
124 \begin{verbatim}
125   cd <install-directory>
126   ./drop_bacula_tables
127   ./make_bacula_tables
128   ./grant_bacula_privileges
129 \end{verbatim}
130 \normalsize
131
132 Please note that all information in the database will be lost and you will be
133 starting from scratch. If you have written on any Volumes, you must write an
134 end of file mark on the volume so that Bacula can reuse it. Do so with: 
135
136 \footnotesize
137 \begin{verbatim}
138    (stop Bacula or unmount the drive)
139    mt -f /dev/nst0 rewind
140    mt -f /dev/nst0 weof
141 \end{verbatim}
142 \normalsize
143
144 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
145 device name for your machine. 
146
147 \subsection*{Converting from MySQL to PostgreSQL}
148 \index[general]{PostgreSQL!Converting from MySQL to }
149 \index[general]{Converting from MySQL to PostgreSQL }
150 \addcontentsline{toc}{subsection}{Converting from MySQL to PostgreSQL}
151
152 The conversion procedure presented here was worked out by Norm Dressler
153 \lt{}ndressler at dinmar dot com\gt{} 
154
155 This process was tested using the following software versions: 
156
157 \begin{itemize}
158 \item Linux Mandrake 10/Kernel 2.4.22-10 SMP 
159 \item Mysql Ver 12.21 Distrib 4.0.15, for mandrake-linux-gnu (i586) 
160 \item PostgreSQL 7.3.4 
161 \item Bacula 1.34.5 
162    \end{itemize}
163
164 WARNING: Always as a precaution, take a complete backup of your databases
165 before proceeding with this process! 
166
167 \begin{enumerate}
168 \item Shutdown bacula (cd /etc/bacula;./bacula stop)  
169 \item Run the following command to dump your Mysql database:  
170
171    \footnotesize
172 \begin{verbatim}
173        mysqldump -f -t -n >bacula-backup.dmp>
174     
175 \end{verbatim}
176 \normalsize
177
178 \item Make a backup of your /etc/bacula directory (but leave the  original in
179    place).  
180 \item Go to your Bacula source directory and rebuild it to include  PostgreSQL
181    support rather then Mysql support. Check the  config.log file for your
182    original configure command and replace  enable-mysql with enable-postgresql.  
183 \item Recompile Bacula with a make and if everything compiles  completely,
184    perform a make install.  
185 \item Shutdown Mysql. 
186 \item Start PostgreSQL on your system.  
187 \item Create a bacula user in Postgres with the createuser command.  Depending on
188    your Postgres install, you may have to SU to the  user who has privileges to
189    create a user.  
190 \item Verify your pg\_hba.conf file contains sufficient permissions to  allow
191    bacula to access the server. Mine has the following since  it's on a secure
192    network:  
193
194 \footnotesize
195 \begin{verbatim}
196 local all all trust
197                 
198 host all all 127.0.0.1 255.255.255.255 trust
199                 
200 NOTE: you should restart your postgres server if you
201       made changes
202       
203 \end{verbatim}
204 \normalsize
205
206 \item Change into the /etc/bacula directory and prepare the database  and
207    tables with the following commands:  
208
209 \footnotesize
210 \begin{verbatim}
211 ./create_postgresql_database
212                                 
213 ./make_postgresql_tables
214                                 
215 ./grant_postgresql_privileges
216        
217 \end{verbatim}
218 \normalsize
219
220 \item Verify you have access to the database:  
221
222    \footnotesize
223 \begin{verbatim}
224   
225 psql -Ubacula bacula
226       
227 \end{verbatim}
228 \normalsize
229
230 You should not get any errors.  
231 \item Load your database from the Mysql database dump with:  
232
233    \footnotesize
234 \begin{verbatim}
235 psql -Ubacula bacula <bacula-backup.dmp>
236       
237 \end{verbatim}
238 \normalsize
239
240 \item Reseqence your tables with the following commands:  
241
242    \footnotesize
243 \begin{verbatim}
244 psql -Ubacula bacula
245                 
246 SELECT SETVAL('basefiles_baseid_seq', (SELECT
247 MAX(baseid) FROM basefiles));
248 SELECT SETVAL('client_clientid_seq', (SELECT
249 MAX(clientid) FROM client));
250 SELECT SETVAL('file_fileid_seq', (SELECT MAX(fileid)
251 FROM file));
252 SELECT SETVAL('filename_filenameid_seq', (SELECT
253 MAX(filenameid) FROM filename));
254                 
255 SELECT SETVAL('fileset_filesetid_seq', (SELECT
256 MAX(filesetid) FROM fileset));
257                 
258 SELECT SETVAL('job_jobid_seq', (SELECT MAX(jobid) FROM job));
259 SELECT SETVAL('jobmedia_jobmediaid_seq', (SELECT
260 MAX(jobmediaid) FROM jobmedia));
261 SELECT SETVAL('media_mediaid_seq', (SELECT MAX(mediaid) FROM media));
262 SELECT SETVAL('path_pathid_seq', (SELECT MAX(pathid) FROM path));
263                 
264 SELECT SETVAL('pool_poolid_seq', (SELECT MAX(poolid) FROM pool));
265        
266 \end{verbatim}
267 \normalsize
268
269 \item At this point, start up Bacula, verify your volume library and  perform
270    a test backup to make sure everything is working  properly. 
271    \end{enumerate}
272
273 \subsection*{Credits}
274 \index[general]{Credits }
275 \addcontentsline{toc}{subsection}{Credits}
276
277 Many thanks to Dan Langille for writing the PostgreSQL driver. This will
278 surely become the most popular database that Bacula supports.