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