]> git.sur5r.net Git - bacula/bacula/blob - gui/bweb/INSTALL
c7adb04d74453df3cb73e1c95956cef0215ca78b
[bacula/bacula] / gui / bweb / INSTALL
1 ################################################################
2 #               INSTALL NOTES                                  #
3 ################################################################
4
5 Bweb works well with 2.0 release or later.
6
7 1) install Perl lib
8 2) using lighttpd (quick install)
9 3) using apache 
10 4) initialize your configuration file
11 5) do some sql stuff (for postgresql or mysql 5 users)
12 6) use the -n option on bconsole so that it works with Expect
13 7) get bacula log more useful
14 8) bweb limitation
15 9) using sudo with autochanger
16 10) using bfileview.pl
17 11) accessing to bweb
18 12) setting mysql read-only account
19 13) get more statistics
20 14) use users and groups with bweb
21 15) setup restoration in bweb
22
23
24 ################ INSTALL PERL LIBRARY ##########################
25
26  - perl modules
27     - DBI (with mysql or postgresql support DBD::Pg and DBD::mysql)
28           (SQLite is not supported)
29     - GD::Graph
30     - GD
31     - HTML::Template
32     - CGI
33     - Expect
34     - Time::ParseDate
35     - Date::Calc
36
37  You can install perl modules with CPAN
38  perl -e shell -MCPAN
39   > install Expect
40
41  Or use your distribution
42  apt-get install libgd-graph-perl libhtml-template-perl libexpect-perl \
43                  libdbd-mysql-perl libdbd-pg-perl libdbi-perl \
44                  libdate-calc-perl libtime-modules-perl
45
46  Note: the best way to test if you have all the dependencies
47  fullfilled for Perl is to:
48   
49     cd bweb/lib
50     ../cgi/bweb.pl 
51
52  you might also want to try:
53
54     ../cgi/bgraph.pl 
55
56  To make sure the graphing modules are loaded.  However, running it
57  will spray binary graphics data on your terminal.  Otherwise, you will
58  get an error.
59
60  That should show you if any of the pre-requisites are missing.
61  On SuSE 10.2, I was able to load all the appropriate modules via rpms,
62  with the exception of Expect and Time::ParseDate, which I loaded manually
63  using perl.
64
65  If you experience problems, always consult the Apache error_log
66  file.
67
68
69 ################# USE LIGHTTPD WITH BWEB #######################
70
71 In this example, bweb files are in /home/bacula/bweb
72 You should have installed lighttpd.
73
74 bacula:~$ cd bweb
75
76 # configure the database
77 bacula:~/bweb$ mysql bacula < script/bweb-mysql.sql
78 # or
79 bacula:~/bweb$ psql bacula < script/bweb-postgresql.sql
80
81 # You can start the web server from the bweb directory
82 bacula@localhost:~/bweb$ ./script/starthttp
83  Making configuration template in /home/bacula/bweb/bweb.conf
84  Adjusting bweb.conf path
85  Using bweb on /home/bacula/bweb,  use firefox http://localhost:9180
86  2009-07-18 22:23:12: (log.c.75) server started
87
88
89 By default, only the loopback interface is binded, you can change that
90 in the bweb/script/httpd.conf file.
91
92 You will have to configure bweb with your database and bconsole info, it
93 can be done in the web interface.
94
95 I [Kern] used the following in the Configuration panel:
96 DBI:     DBI:mysql:database=bacula;host=roxie 
97 user:    bacula
98 Password:   (nothing -- I have none)
99 email_media:  my@email.com
100 bconsole:  /opt/bacula/bin/bconsole -n
101
102 Click: Save
103 Click: Main -- you should see the charts
104
105
106 ################ FILE COPY (Full Apache methode) ###############
107  # you must get bweb svn files
108  svn checkout https://bacula.svn.sourceforge.net/svnroot/bacula/trunk/gui/bweb bweb
109
110  # or get them from the released tar files or from the apt or rpms.
111
112  #
113  # Once you have the gui directory loaded, follow the instructions below
114  #  or edit the environment variables in the file install_bweb
115  #  then execute it. install_web does everything to the next
116  #  set of #######'s.
117  #
118
119  # first, copy the bweb Perl library into your PERL5 INC path
120  perl Makefile.PL
121  make install
122  # or
123  install -m 644 -o root -g root  bweb/lib/*.pm /usr/share/perl5
124
125
126
127  # copy the bweb perl program to your cgi location
128  mkdir -m 755 /usr/lib/cgi-bin/bweb
129  install -m 755 -o root -g root  bweb/cgi/*.pl /usr/lib/cgi-bin/bweb
130
131  # get a config file, if you want to use an other place edit lib/Bweb.pm
132  mkdir -m 755 /etc/bacula
133  chown root:bacula /etc/bacula
134  echo '$VAR1 = { template_dir => "/usr/share/bweb/tpl" };' > /etc/bacula/bweb.conf
135  chown www-data /etc/bacula/bweb.conf
136
137  # copy the bweb template file
138  mkdir -p /usr/share/bweb/tpl/en
139  install -m 644 -o root -g root  bweb/lang/en/tpl/*.tpl /usr/share/bweb/tpl/en
140
141  # copy the bweb graphics elements (bweb elements must reside in /bweb)
142  mkdir /var/www/bweb
143  install -m 644 -o root -g root  bweb/html/*.{js,png,css,gif,ico,html} /var/www/bweb
144
145  # done !
146
147  WARNING : Your www-data (or wwwrun on SuSE) user must be able to execute bconsole and able 
148            to read the bconsole.conf file!
149            You can create an bconsole group for that.
150
151 ################ USE FRENCH/SPANISH VERSION ####################
152
153 Simply copy lang/fr/tpl/*.tpl files to .../tpl/fr/*.tpl and choose
154 your language in the configuration panel.
155
156
157 ################ APACHE CONFIGURATION ##########################
158
159 It could be a good idea to protect your bweb installation (optional).
160
161 Put this in your httpd.conf, and add user with htpasswd
162
163 Alias /bweb /usr/share/bweb/html
164 <Directory /usr/share/bweb/html>
165         Options FollowSymLinks MultiViews
166         AllowOverride None
167         Order allow,deny
168         allow from all
169 </Directory>
170
171 ScriptAlias /cgi-bin/bweb /usr/lib/cgi-bin/bweb
172 <Directory /usr/lib/cgi-bin/bweb>
173         Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
174         AuthType Basic
175         AuthName MyPrivateFile
176         AuthUserFile /etc/apache/htpasswd
177         AllowOverride None
178         Require valid-user
179 </Directory>
180
181 On SuSE 10.2, the following in /etc/apache2/default-server.conf works. 
182 However, it is not secure:
183
184 Directory "/srv/www/cgi-bin/bweb">
185  AllowOverride None
186  Options +ExecCGI -Includes
187  Order allow,deny
188  Allow from all
189 </Directory>
190
191
192 ################ CONFIGURATION #################################
193
194 Note, this is automatically installed by the install_bweb script.
195
196 /etc/bacula/bweb.conf looks like : (you can edit it inside bweb)
197 $VAR1 = bless( {
198   'graph_font' => '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
199   'name' => undef,
200   'config_file' => '/etc/bacula/bweb.conf',
201   'bconsole' => '/usr/sbin/bconsole -n -c /etc/bacula/bconsole.conf',
202   'ach_list' => {
203      'S1_L80' => bless( {
204          'info' => {
205                      'drive' => 0,
206                      'io' => 0,
207                      'slot' => 0
208                    },
209          'name' => 'S1_L80',
210          'bweb' => undef,
211          'device' => '/dev/changer',
212          'drive' => [],
213          'debug' => 0,
214          'label' => {},
215          'precmd' => 'sudo',
216          'io' => [],
217          'mtxcmd' => '/usr/sbin/mtx',
218          'drive_name' => [
219                            'S1_L80_SDLT0',
220                            'S1_L80_SDLT1'
221                          ],
222          'slot' => []
223        }, 'Bweb::Autochanger' )
224    },
225   'password' => 'xxx',
226   'template_dir' => '/usr/share/bweb/tpl',
227   'lang' => 'en',
228   'dbi' => 'DBI:mysql:database=bacula',
229   'error' => '',
230   'debug' => 0,
231   'user' => 'bacula',
232   'email_media' => 'eric@localhost'
233 }, 'Bweb::Config' );
234
235
236 ################ BRESTORE ######################################
237
238 If you want to use brestore with bweb, you must associate a mime type
239 text/brestore with your brestore.pl, and you must install brestore.
240 See gui/brestore/README for instructions on installing brestore.pl.
241
242 ################ POSTGRESQL AND MYSQL5 NOTES ####################
243
244 If you want to use PostgreSQL instead of MySQL, you must add
245 a function to the PostgreSQL Bacula database to get Bweb to work.
246
247 psql -U bacula bacula < script/bweb-postgresql.sql
248
249 Tips: PL must be enabled in your cluster, you can do this with postgres user
250 postgres:~$ echo 'CREATE PROCEDURAL LANGUAGE plpgsql;' | psql bacula 
251
252
253 To get database size with mysql5, edit Bweb.pm and change the DB_SIZE macro
254
255  # with mysql < 5, you have to play with the ugly SHOW command
256  DB_SIZE => " SELECT 0 ",
257  # works only with mysql 5
258  # DB_SIZE => " SELECT sum(DATA_LENGTH) FROM INFORMATION_SCHEMA.TABLES ",
259
260 ################ BCONSOLE NOTES ################################
261
262 You must use bconsole without conio/readline support. For that, use
263 the bconsole -n option. This is done automatically with the standard
264 configuration file.  In addition, please ensure that the binary
265 bconsole file can be executed by your web server. It is normally
266 located in /usr/bin/bconsole (or some such file), and must have
267 modes 755 or it will not be executable by your web server.  The
268 normal Bacula installation usually sets mode 750.
269
270 ################ BACULA LOG ####################################
271
272 If you want Bweb to be able to show listings of the Job output,
273 you must add a "catalog = all, !skipped, !saved" to your
274 messages resource in bacula-dir.conf and restart your Bacula 
275 server.  This is shown below:
276
277 Messages {
278   Name = Standard
279
280   operator = root@localhost = mount
281   console = all, !skipped, !saved
282   append = "/tmp/bacula/var/bacula/working/log" = all, !skipped
283
284   catalog = all, !skipped, !saved
285 }
286
287
288 ################ BWEB LIMITATION ###############################
289
290 To get bweb working, you must follow these rules
291  - Media, Storage and Pool must have [A-Za-z_0-9\.-]+ (no space)
292  - AutoChanger name must be same as Device and Location name in bacula
293
294 ################ SUDO CONFIGURATION ############################
295
296 If you use sudo, put this on you /etc/sudoers
297
298 www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer transfer *
299 www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer status
300 www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer load *
301 www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer unload *
302
303 ################ BFILEVIEW AND BTIME SETUP ###############################
304
305 Alias /bweb/fv /var/spool/bweb
306 <Directory "/var/spool/bweb">
307     Options None
308     AllowOverride AuthConfig
309     Order allow,deny
310     Allow from all
311 </Directory>
312
313 mkdir /var/spool/bweb
314 chmod 700 /var/spool/bweb
315 chown www-data /var/spool/bweb
316
317 Add (or configure) a writable location to the parameters in bweb.conf 
318    'fv_write_path' => '/var/spool/bweb',
319
320 ###### BFILEVIEW only part
321
322 You have to remove "<!-- Remove this to activate bfileview" and "-->" from
323 tpl/en/display_job_zoom.tpl.
324
325 You MUST use brestore.pl -b or bresto.pl action=batch to initialize the database, and
326 you CAN use bfileview.pl mode=batch jobid=xxx where=/ to compute tree size.
327
328 At this time, it's a good idea to schedule brestore.pl -b after your 
329 BackupCatalog job.
330
331 Job {
332   Name = "BackupCatalog"
333   ...
334   # This creates an ASCII copy of the catalog
335   RunBeforeJob = "/opt/bacula/etc/make_catalog_backup bacula bacula Pei0ahm9"
336   # This deletes the copy of the catalog
337   RunAfterJob  = "/opt/bacula/etc/delete_catalog_backup"
338   RunAfterJob  = "/usr/lib/cgi-bin/bweb/bresto.pl action=batch"
339 }
340
341 To upgrade from an old installation, you can use :
342 ALTER TABLE brestore_pathvisibility ADD Size int8;
343 ALTER TABLE brestore_pathvisibility ADD Files int4;
344
345 ################ ACCESSING TO BWEB ############################
346
347 Now, you are able to launch firefox/mozilla and go on
348 http://your-server/bweb
349
350 ################ SETTING MYSQL ACCOUNT ########################
351
352 At this time, Bweb needs a write access to :
353 - Location 
354 - LocationLog
355 - Media::LocationId
356 - Media::Comment
357 - Media::RecyclePoolId (it will change soon)
358
359 If your doesn't use Location feature, you can use ReadOnly access
360 for all tables, or setup something like :
361
362 GRANT SELECT ON bacula.* TO 'bweb'@'%'  IDENTIFIED BY 'password';
363 GRANT INSERT,UPDATE,DELETE ON bacula.Location 
364   TO 'bweb'@'%' IDENTIFIED BY 'password';
365 GRANT INSERT,UPDATE,DELETE ON bacula.LocationLog 
366   TO 'bweb'@'%' IDENTIFIED BY 'password';
367
368 ################ GET MORE STATISTICS ###########################
369
370 You keep Jobs informations across retention into a JobHisto table.
371 You have to setup stat_job_table = JobHisto in bweb configuration.
372
373 CREATE TABLE JobHisto (LIKE Job);
374
375 And run this on crontab when you want :
376 INSERT INTO JobHisto 
377   (SELECT * FROM Job WHERE JobId NOT IN (SELECT JobId FROM JobHisto) );
378
379 ################ USE USERS AND GROUPS WITH BWEB ##########################
380
381 It works with postgresql and mysql5 (4 not tested).
382 With mysql, load bweb/script/bweb-mysql.sql into your catalog
383 For postgresql, it will be done with bweb/script/bweb-postgresql.sql (already done)
384
385 ################ MADE RESTORATION WITH BWEB ####################
386
387 It will do some basics things on a working bweb/brestore setup.
388
389 1) Go to http://extjs.com and download their toolkit (last 2.2 release)
390
391 2) Install files in /bweb/ext web root 
392  example on debian : 
393   root@localhost:~# mv ext-2.2 /usr/share/bweb/html/ext
394
395 3) Make sure that brestore cache tables are in your catalog (bweb-xxx.sql files)
396
397 4) Enable bresto.pl cgi. 
398   edit the bweb/cgi/bresto.pl script and change $bresto_enable=0; to $bresto_enable=1;
399   on the top of the file.
400
401 5) Use the last Bweb.pm
402   If you are trying bresto in a working bweb/brestore setup, you must make sure that you use 
403   the last Bweb.pm SVN version.
404
405 6) Go on http://you-director/bweb/bresto.html
406
407 ################################################################
408
409 Enjoy !