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