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