]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/console/baculum.tex
35f940cccb7ffe718f39d9beb3c36ee919fb48b2
[bacula/docs] / docs / manuals / en / console / baculum.tex
1 %%
2 %%
3
4 \chapter{Baculum API and Web GUI Tools}
5 \label{BaculumChapter}
6
7 This chapter presents the Bacula Web based interface that has been added to
8 the Bacula project for version 7.0 and later.
9
10 \section{Base Features}
11
12 Baculum provides the following base features:
13
14 \begin{itemize}
15 \item Running Bacula jobs (backup, restore, verify...).
16 \item Baculum API with OAuth2 authorization and HTTP Basic authentication
17 \item Baculum Web GUI interface
18 \item Configuring Bacula on local and remote hosts
19 \item Monitoring Bacula service status.
20 \item Bacula console available via a Web window.
21 \item Multi-user interface.
22 \item Support for customized and restricted consoles (Console ACL function).
23 \item Volume management.
24 \item User friendly graphs and metrics.
25 \item Basic storage daemon operations (mount, umount, release, ...).
26 \item Easy to use configuration and restore wizards.
27 \item Multiple Director support.
28 \item Live AJAX based statuses.
29 \end{itemize}
30
31 \section{General Requirements}
32
33 Environment for Baculum Web installation should have following components
34 installed:
35
36 \begin{itemize}
37 \item A Web Server - with mod\_rewrite module loaded.  Baculum Web has been
38 tested with Apache and Lighttpd web servers.
39 \item PHP 5.3.4 or higher with following modules installed:
40  \begin{itemize}
41  \item cURL PHP module.
42  \item MB String PHP module.
43  \item JSON PHP module.
44  \end{itemize}
45 \end{itemize}
46
47 Environment for Baculum API installation should have following components
48 installed:
49
50 \begin{itemize}
51 \item A Web Server - with mod\_rewrite module loaded.  Baculum has been
52 tested with Apache and Lighttpd web servers.
53 \item PHP 5.3.4 or higher with following modules installed:
54  \begin{itemize}
55  \item PDO PHP support - depending on your catalog database: PDO PostgreSQL
56 or PDO MySQL. Note, in case using MySQL database there is required to use MySQL
57 native driver. It is php-mysqlnd for PHP, not php-mysql.
58  \item BCMath PHP module.
59  \item JSON PHP module.
60  \end{itemize}
61 \item A working Bacula bconsole - configured Bacula text based console
62 \item Direct access to the Bacula Catalog database (local or remote)
63 \end{itemize}
64
65
66 With installation from binary packages (deb, rpm) all requirements 
67 will be automatically installed as packages dependencies.
68
69 \section{Installation Baculum API from rpm binary packages}
70
71 {\bf Note}
72 Before start using Baculum API and Baculum Web version 9.0.0 please backup
73 your Bacula configuration in safe place. It is specially important because
74 on first save config action the Bacula configuration is joined into one file
75 per Bacula component.\\
76
77 For rpm binary there are the following packages:
78
79 \begin{itemize}
80 \item baculum-api - main Baculum API package with application files
81 \item baculum-api-httpd - Apache web server configuration files for Baculum API
82 \item baculum-api-lighttpd - Lighttpd web server configuration files for Baculum API
83 \item baculum-common - Common files for Baculum API and Baculum Web
84 \item baculum-web - main Baculum Web package with application files
85 \item baculum-web-httpd - Apache web server configuration files for Baculum Web
86 \item baculum-web-lighttpd - Lighttpd web server configuration files for Baculum Web
87 \end{itemize}
88
89 \subsection{Add the Baculum rpm repository}
90
91 To add the Baculum repository, first you must import the Baculum public key:
92
93 \begin{verbatim}
94 rpm --import http://bacula.org/downloads/baculum/baculum.pub
95 \end{verbatim}
96
97 Once the key is imported, the next step is to add the repository
98 definition.  First you must create the following file:
99
100 \begin{verbatim}
101 /etc/yum.repos.d/baculum.repo
102 \end{verbatim}
103
104 The for CentOS 7, put the following in the file just created:
105
106 \begin{verbatim}
107 [baculumrepo]
108 name=Baculum CentOS repository
109 baseurl=http://bacula.org/downloads/baculum/stable/centos
110 gpgcheck=1
111 enabled=1
112 \end{verbatim}
113
114 For Fedora 25 the {\bf bacula.repo} file should have the following contents:
115
116 \begin{verbatim}
117 [baculumrepo]
118 name=Baculum Fedora repository
119 baseurl=http://bacula.org/downloads/baculum/stable/fedora
120 gpgcheck=1
121 enabled=1
122 \end{verbatim}
123
124 \subsection{Installation for the Apache}
125
126 Install the Baculum API for the Apache Web server as follows:
127
128 \begin{verbatim}
129 yum install baculum-common baculum-api baculum-api-httpd
130 \end{verbatim}
131
132 Restart your Apache Web server:
133
134 \begin{verbatim}
135 service httpd restart
136 \end{verbatim}
137
138
139 \subsection{Installation for Lighttpd}
140
141 Installation on system with access via Lighttpd is as follows
142
143 \begin{verbatim}
144 yum install baculum-common baculum-api baculum-api-lighttpd
145 \end{verbatim}
146
147 Please note that in case CentOS distribution the Lighttpd web server is
148 available in the distribution packages after enabling the EPEL repository.
149
150 Start Baculum as application using the Lighttpd Web server:
151
152 \begin{verbatim}
153 service baculum-api-lighttpd start
154 \end{verbatim}
155
156 \subsection{Access to bconsole via sudo for Apache and Lighttpd}
157
158 Baculum API requires access to Bconsole and to Bacula JSON programs.
159 To configure Bconsole sudo access and the Bacula JSON programs access 
160 there can use following entries in newly created Baculum sudoers.d file
161 (usually in path /etc/sudoers.d/baculum):\\
162
163 In case default Apache user, the file contents must be:
164
165 \begin{verbatim}
166 Defaults:apache !requiretty
167 apache  ALL=NOPASSWD:  /usr/sbin/bconsole
168 apache  ALL=NOPASSWD:  /usr/sbin/bdirjson
169 apache  ALL=NOPASSWD:  /usr/sbin/bsdjson
170 apache  ALL=NOPASSWD:  /usr/sbin/bfdjson
171 apache  ALL=NOPASSWD:  /usr/sbin/bbconsjson
172 \end{verbatim}
173
174 In case default Lighttpd user the file contents must be:
175
176 \begin{verbatim}
177 Defaults:lighttpd !requiretty
178 lighttpd  ALL=NOPASSWD:  /usr/sbin/bconsole
179 lighttpd  ALL=NOPASSWD:  /usr/sbin/bdirjson
180 lighttpd  ALL=NOPASSWD:  /usr/sbin/bsdjson
181 lighttpd  ALL=NOPASSWD:  /usr/sbin/bfdjson
182 lighttpd  ALL=NOPASSWD:  /usr/sbin/bbconsjson
183 \end{verbatim}
184
185 \section{Installation Baculum API from deb binary packages}
186
187 {\bf Note}
188 Before start using Baculum API and Baculum Web version 9.0.0 please backup
189 your Bacula configuration in safe place. It is specially important because
190 on first save config action the Bacula configuration is joined into one file
191 per Bacula component.\\
192
193 For deb binary there are the following packages:
194
195 \begin{itemize}
196 \item baculum-api - main Baculum API package with application files
197 \item baculum-api-apache2 - Apache web server configuration files for Baculum API
198 \item baculum-api-lighttpd - Lighttpd web server configuration files for Baculum API
199 \item baculum-common - Common files for Baculum API and Baculum Web
200 \item baculum-web - main Baculum Web package with application files
201 \item baculum-web-apache2 - Apache web server configuration files for Baculum Web
202 \item baculum-web-lighttpd - Lighttpd web server configuration files for Baculum Web
203 \end{itemize}
204
205 \subsection{Add the Baculum deb repository}
206
207 To add the Baculum repository, first import the Baculum public key:
208
209 \begin{verbatim}
210 wget -qO - http://bacula.org/downloads/baculum/baculum.pub | apt-key add -
211 \end{verbatim}
212
213 Once the key is imported, the next step is to create
214 a new baculum file:
215
216 \begin{verbatim}
217 /etc/apt/sources.list.d/baculum.list
218 \end{verbatim}
219
220 For Debian 8 Jessie the contents should be:
221
222 \begin{verbatim}
223 deb http://bacula.org/downloads/baculum/stable/debian jessie main
224 deb-src http://bacula.org/downloads/baculum/stable/debian jessie main
225 \end{verbatim}
226
227 For Debian 9 Stretch the contents should be:
228
229 \begin{verbatim}
230 deb http://bacula.org/downloads/baculum/stable/debian stretch main
231 deb-src http://bacula.org/downloads/baculum/stable/debian stretch main
232 \end{verbatim}
233
234 For Ubuntu 16.04 Xenial the contents should be:
235 \begin{verbatim}
236 deb [ arch=amd64 ] http://bacula.org/downloads/baculum/stable/ubuntu xenial main
237 deb-src http://bacula.org/downloads/baculum/stable/ubuntu xenial main
238 \end{verbatim}
239
240
241 After adding repository definition, please refresh repository indexes:
242 \begin{verbatim}
243 apt-get update
244 \end{verbatim}
245
246 \subsection{Installation for Apache}
247
248 To install Baculum API access via Apache Web server by using apt
249 packages manager use the command:
250
251 \begin{verbatim}
252 apt-get install baculum-common baculum-api baculum-api-apache2
253 \end{verbatim}
254
255 Next you must enable mod\_rewrite module for Apache, with the
256 following command:
257
258 \begin{verbatim}
259 a2enmod rewrite
260 \end{verbatim}
261
262 and include Baculum VirtualHost definition in the Apache configuration
263 with:
264
265 \begin{verbatim}
266 a2ensite baculum-api
267 \end{verbatim}
268
269 The restart your Apache server with:
270
271 \begin{verbatim}
272 service apache2 restart
273 \end{verbatim}
274
275 \subsection{Installation for Lighttpd}
276
277 Example installation with access via Lighttpd web server looks following:
278
279 \begin{verbatim}
280 apt-get install baculum-common baculum-api baculum-api-lighttpd
281 \end{verbatim}
282
283 Start Baculum API as application available through Lighttpd web server:
284
285 \begin{verbatim}
286 service baculum-api-lighttpd start
287 \end{verbatim}
288
289 \subsection{Access to bconsole via sudo for Apache and Lighttpd}
290
291 Baculum API requires access to Bconsole and to the Bacula JSON programs.
292 To configure Bconsole sudo access we strongly recommend that you create
293 a Baculum sudoers.d file, which should be in /etc/sudoers.d/baculum:
294
295 {\bf Note}, please define sudo for the Bacula JSON programs only when
296 you are going use Bacula configuration module in the Baculum.
297
298 Both for Apache and Lighttpd user the file contents can be:
299
300 \begin{verbatim}
301 Defaults:www-data !requiretty
302 www-data  ALL=NOPASSWD:  /usr/sbin/bconsole
303 www-data  ALL=NOPASSWD:  /usr/sbin/bdirjson
304 www-data  ALL=NOPASSWD:  /usr/sbin/bsdjson
305 www-data  ALL=NOPASSWD:  /usr/sbin/bfdjson
306 www-data  ALL=NOPASSWD:  /usr/sbin/bbconsjson
307 \end{verbatim}
308
309 \section{Debugging your First Baculum API Login}
310 At each step of the initial login to Baculum, the
311 screen will have a test button that will allow you
312 to check to see if your parameters were correctly
313 entered.  If not, you will see error message on the
314 wizard page. You can also get additional detail by
315 examining the Apache error log, that is usually 
316 found at:
317
318 \begin{verbatim}
319 /var/log/httpd/baculum-api-error.log
320 \end{verbatim}
321
322 If you use Lighttpd thento get additional detail you can check:
323
324 \begin{verbatim}
325 /var/log/lighttpd/baculum-api-error.log
326 \end{verbatim}
327
328 In addition, special debug output is placed by Baculum in
329 the file:
330
331 \begin{verbatim}
332 /usr/share/baculum/htdocs/protected/API/Logs/baculum-api.log
333 \end{verbatim}
334
335 The debug you can enable in file:
336 \begin{verbatim}
337 /usr/share/baculum/htdocs/protected/API/Config/api.conf
338 \end{verbatim}
339
340 by switching in [api] section option debug to "1".
341
342 With the information in those two files, you can usually quickly
343 find and correct most problems.
344
345
346
347 \section{Installation Baculum Web from rpm binary packages}
348
349 \subsection{Installation for the Apache}
350
351 Install the Baculum Web for the Apache Web server as follows:
352
353 \begin{verbatim}
354 yum install baculum-common baculum-web baculum-web-httpd
355 \end{verbatim}
356
357 Restart your Apache Web server:
358
359 \begin{verbatim}
360 service httpd restart
361 \end{verbatim}
362
363 \subsection{Installation for Lighttpd}
364
365 Installation on system with access via Lighttpd is as follows
366
367 \begin{verbatim}
368 yum install baculum-common baculum-web baculum-web-lighttpd
369 \end{verbatim}
370
371 Please note that in case CentOS distribution the Lighttpd web server is
372 available in the distribution packages after enabling the EPEL repository.
373
374 Start Baculum as application using the Lighttpd Web server:
375
376 \begin{verbatim}
377 service baculum-web-lighttpd start
378 \end{verbatim}
379
380 \section{Installation Baculum Web from deb binary packages}
381
382 \subsection{Installation for Apache}
383
384 To install Baculum Web access via Apache Web server by using apt
385 packages manager use the command:
386
387 \begin{verbatim}
388 apt-get install baculum-common baculum-web baculum-web-apache2
389 \end{verbatim}
390
391 Next you must enable mod\_rewrite module for Apache, with the
392 following command:
393
394 \begin{verbatim}
395 a2enmod rewrite
396 \end{verbatim}
397
398 and include Baculum VirtualHost definition in the Apache configuration
399 with:
400
401 \begin{verbatim}
402 a2ensite baculum-web
403 \end{verbatim}
404
405 The restart your Apache server with:
406
407 \begin{verbatim}
408 service apache2 restart
409 \end{verbatim}
410
411 \subsection{Installation for Lighttpd}
412
413 Example installation with access via Lighttpd web server looks following:
414
415 \begin{verbatim}
416 apt-get install baculum-common baculum-web baculum-web-lighttpd
417 \end{verbatim}
418
419 Start Baculum Web as application available through Lighttpd web server:
420
421 \begin{verbatim}
422 service baculum-web-lighttpd start
423 \end{verbatim}
424
425 \section{Running Baculum API and Web for the First Time}
426
427 \subsection{Running Baculum API}
428
429 Access to Baculum API from web browser: \textbf{http://localhost:9096}
430
431 First time login: \textbf{admin}
432
433 First time password: \textbf{admin}
434
435
436 \subsection{Running Baculum Web}
437
438 Access to Baculum Web from web browser: \textbf{http://localhost:9095}
439
440 First time login: \textbf{admin}
441
442 First time password: \textbf{admin}
443
444 \section{Installation wizards}
445
446 \textbf{Installation with HTTP Basic authentication}
447
448 \includegraphics[width=\linewidth]{baculum_install_basic.png}
449
450 \smallskip
451
452 \textbf{Installation with OAuth2 authorization}
453
454 \includegraphics[width=\linewidth]{baculum_install_oauth2.png}
455
456 \smallskip
457
458 \section{Baculum API endpoints}
459
460 \subsection{Clients}
461
462 GET /api/clients - get records all clients
463
464 GET /api/clients/limit/4 - get records first 4 clients
465
466 GET /api/clients/2 - get records only for client with clientid equal 2
467
468 GET /api/clients/show  - get 'show clients' bconsole command
469
470 GET /api/clients/show/2 - get 'show client=xxx' bconsole command for client with clientid equal 2
471
472 GET /api/clients/status/2 - get 'status client=xxx' bconsole command for client with clientid equal 2
473
474 GET /api/clients/jobs/2 - get all jobs done by client with clientid equal 2\\
475
476
477 Errors:
478
479 0 - No errors.
480
481 1 - Invalid command.
482
483 2 - Problem with connection to database.
484
485 3 - Database access is not supported by this API instance.
486
487 4 - Problem with connection to bconsole.
488
489 5 - Invalid director.
490
491 6 - Problem with authorization to Baculum API.
492
493 7 - Access attempt to not allowed resource. Permission denied.
494
495 10 - Client with inputted clientid does not exists.
496
497 1000 - Internal error.
498
499 \subsection{Storages}
500
501 GET /api/storages/ - get records all storages.
502
503 GET /api/storages/limit/25 - get records first 25 storages.
504
505 GET /api/storages/3 - get records only for storage with storageid equal 3.
506
507 GET /api/storages/show - get 'show storages' bconsole command.
508
509 GET /api/storages/show/3 - get 'show storage=xxx' bconsole command for storage with storageid equal 3.
510
511 GET /api/storages/status/3 - get 'status storage=xxx' bconsole command for storage with storageid equal 3.
512
513 GET /api/storages/mount/3/2/17 - mount storage with storageid equal 3, drive number 2 and volume in slot number 17.
514
515 GET /api/storages/umount/3/1 - umount storage with storageid equal 3 and drive number 1.
516
517 GET /api/storages/release/3 - release storage with storageid equal 3.\\
518
519
520 Errors:
521
522 0 - No errors.
523
524 1 - Invalid command.
525
526 2 - Problem with connection to database.
527
528 3 - Database access is not supported by this API instance.
529
530 4 - Problem with connection to bconsole.
531
532 5 - Invalid director.
533
534 6 - Problem with authorization to Baculum API.
535
536 7 - Access attempt to not allowed resource. Permission denied.
537
538 20 - Storage with inputted storageid does not exists.
539
540 1000 - Internal error.
541
542 \subsection{Volumes}
543
544 GET /api/volumes/ - get records all volumes.
545
546 GET /api/volumes/limit/50 - get records first 50 volumes.
547
548 GET /api/volumes/5 - get records only for volume with mediaid equal 5.
549
550 GET /api/volumes/prune/5 - call prune action on volume with mediaid equal 5.
551
552 GET /api/volumes/purge/5 - call purge action on volume with mediaid equal 5.
553
554 GET /api/volumes/jobs/5 - get all jobs done on volume with mediaid equal 5.\\
555
556
557 Errors:
558
559 0 - No errors.
560
561 1 - Invalid command.
562
563 2 - Problem with connection to database.
564
565 3 - Database access is not supported by this API instance.
566
567 4 - Problem with connection to bconsole.
568
569 5 - Invalid director.
570
571 6 - Problem with authorization to Baculum API.
572
573 7 - Access attempt to not allowed resource. Permission denied.
574
575 30 - Volume with inputted mediaid does not exists.
576
577 1000 - Internal error.
578
579 \subsection{Pools}
580
581 GET /api/pools/ - get records all pools.
582
583 GET /api/pools/limit/15 - get records first 15 pools.
584
585 GET /api/pools/7 - get records only for pool with poolid equal 7.
586
587 GET /api/pools/show - get 'show pools' bconsole command.
588
589 GET /api/pools/show/7 - get 'show pool=xxx' bconsole command for pool with poolid equal 7.
590
591 PUT /api/pools/update/7 - call 'update pool=xxx' bconsole command for pool with poolid equal 7.\\
592
593
594 Errors:
595
596 0 - No errors.
597
598 1 - Invalid command.
599
600 2 - Problem with connection to database.
601
602 3 - Database access is not supported by this API instance.
603
604 4 - Problem with connection to bconsole.
605
606 5 - Invalid director.
607
608 6 - Problem with authorization to Baculum API.
609
610 7 - Access attempt to not allowed resource. Permission denied.
611
612 40 - Pool with inputted poolid does not exists.
613
614 1000 - internal error.\\
615
616 \subsection{Jobs}
617
618 GET /api/jobs/ - get records all jobs.
619
620 GET /api/jobs/limit/20 - get records first 20 jobs.
621
622 GET /api/jobs/8 - get records only for job with jobid equal 8.
623
624 GET /api/jobs/tasks/ - get job names for all directors
625
626 GET /api/jobs/tasks/type/B - get backup job names
627
628 GET /api/jobs/tasks/type/R/limit/5 - get first 5 restore job names
629
630 GET /api/jobs/recent/myjob/client/myclient-fd/filesetid/62/ - get most
631 recent job identifiers for job "myjob", client "myclient-fd" and fileset
632 with filesetid 62
633
634 GET /api/jobs/recent/myjob/clientid/31/filesetid/62/ - get most
635 recent job identifiers for job "myjob", client with clientid 21 and fileset
636 with filesetid 62
637
638 POST /jobs/estimate/ - call estimate action on a job.
639
640 \begin{verbatim}
641 +-----------------------------------------------------------------------------+
642 |                      /api/jobs/estimate/ POST request                       |
643 +-------------------+---------+-----------------------------------------------+
644 | Name              |  Type   |    Description                                |
645 +-------------------+---------+-----------------------------------------------+
646 | create[id] *      | integer | job id to get job name for estimate purpose   |
647 |                   |         | (used instead job name)                       |
648 +-------------------+---------+-----------------------------------------------+
649 | create[name] *    | string  | job name to estimate (used instead of jobid)  |
650 |                   |         |                                               |
651 +-------------------+---------+-----------------------------------------------+
652 | create[fileset] * | string  | FileSet resource name                         |
653 |                   |         |                                               |
654 +-------------------+---------+-----------------------------------------------+
655 | create[level] *   | string  | Job level in short form.                      |
656 |                   |         | One case sensitive letter:                    |
657 |                   |         |    F => Full                                  |
658 |                   |         |    I => Incremental                           |
659 |                   |         |    D => Differential                          |
660 |                   |         |    B => Base                                  |
661 |                   |         |    f => VirtualFull                           |
662 |                   |         |    V => InitCatalog                           |
663 |                   |         |    C => Catalog                               |
664 |                   |         |    O => VolumeToCatalog                       |
665 |                   |         |    d => DiskToCatalog                         |
666 +-------------------+---------+-----------------------------------------------+
667 | create[clientid] *| integer | Client identifier                             |
668 |                   |         | (used instead of client name)                 |
669 +-------------------+---------+-----------------------------------------------+
670 | create[client] *  | string  | Client name (used instead of client id)       |
671 |                   |         |                                               |
672 +-------------------+---------+-----------------------------------------------+
673 | create[accurate] *| integer | Enable accurate mode: 0 - no, 1 - yes         |
674 |                   |         |                                               |
675 +-------------------+---------+-----------------------------------------------+
676
677 * - required field
678 \end{verbatim}
679
680 POST /api/jobs/run/ - call run action on job (run job).
681
682 \begin{verbatim}
683 +-----------------------------------------------------------------------------+
684 |                      /api/jobs/run/ POST request                            |
685 +-------------------+---------+-----------------------------------------------+
686 | Name              |  Type   |    Description                                |
687 +-------------------+---------+-----------------------------------------------+
688 | create[id] *      | integer | job id to get job name to run                 |
689 |                   |         | (used instead job name)                       |
690 +-------------------+---------+-----------------------------------------------+
691 | create[name] *    | string  | job name to run (used instead of jobid)       |
692 |                   |         |                                               |
693 +-------------------+---------+-----------------------------------------------+
694 | create[level] *   | string  | Job level in short form.                      |
695 |                   |         | One case sensitive letter:                    |
696 |                   |         |    F => Full                                  |
697 |                   |         |    I => Incremental                           |
698 |                   |         |    D => Differential                          |
699 |                   |         |    B => Base                                  |
700 |                   |         |    f => VirtualFull                           |
701 |                   |         |    V => InitCatalog                           |
702 |                   |         |    C => Catalog                               |
703 |                   |         |    O => VolumeToCatalog                       |
704 |                   |         |    d => DiskToCatalog                         |
705 +-------------------+---------+-----------------------------------------------+
706 | create[fileset] * | string  | FileSet resource name                         |
707 |                   |         |                                               |
708 +-------------------+---------+-----------------------------------------------+
709 | create[clientid] *| integer | Client identifier                             |
710 |                   |         | (used instead of client name)                 |
711 +-------------------+---------+-----------------------------------------------+
712 | create[client] *  | string  | Client name (used instead of client id)       |
713 |                   |         |                                               |
714 +-------------------+---------+-----------------------------------------------+
715 | create[storageid]*| integer | Storage identifier                            |
716 |                   |         | (used instead of storage name)                |
717 +-------------------+---------+-----------------------------------------------+
718 | create[storage] * | string  | Storage name (used instead of storage id)     |
719 |                   |         |                                               |
720 +-------------------+---------+-----------------------------------------------+
721 | create[poolid] *  | integer | Pool identifier (used instead of pool name)   |
722 |                   |         |                                               |
723 +-------------------+---------+-----------------------------------------------+
724 | create[pool] *    | string  | Pool name (used instead of pool id)           |
725 |                   |         |                                               |
726 +-------------------+---------+-----------------------------------------------+
727 | create[priority]  | integer | Job priority to run                           |
728 |                   |         |                                               |
729 +-------------------+---------+-----------------------------------------------+
730 | create[jobid]     | integer | Job identifier for verify job                 |
731 |                   |         |                                               |
732 +-------------------+---------+-----------------------------------------------+
733 | create[verifyjob] | string  | Verify job name                               |
734 |                   |         |                                               |
735 +-------------------+---------+-----------------------------------------------+
736
737 * - required field
738 \end{verbatim}
739
740 POST /api/jobs/restore/ - call restore action.
741
742 \begin{verbatim}
743 +-----------------------------------------------------------------------------+
744 |                      /api/jobs/restore/ POST request                        |
745 +-------------------+---------+-----------------------------------------------+
746 | Name              |  Type   |    Description                                |
747 +-------------------+---------+-----------------------------------------------+
748 | create[rpath] *   | string  | Bvfs temporary table name for restore purpose |
749 |                   |         | in form: b2[0-9]+                             |
750 +-------------------+---------+-----------------------------------------------+
751 | create[clientid] *| integer | Client identifier                             |
752 |                   |         | (used instead of client name)                 |
753 +-------------------+---------+-----------------------------------------------+
754 | create[client] *  | string  | Client name (used instead of client id)       |
755 |                   |         |                                               |
756 +-------------------+---------+-----------------------------------------------+
757 | create[priority]  | integer | Job priority to run                           |
758 |                   |         |                                               |
759 +-------------------+---------+-----------------------------------------------+
760 | create[where] *   | string  | Destination directory for restored files      |
761 |                   |         |                                               |
762 +-------------------+---------+-----------------------------------------------+
763 | create[replace] * | string  | Replace files in destination directory for    |
764 |                   |         | restored files. Available options:            |
765 |                   |         | - never                                       |
766 |                   |         | - ifolder                                     |
767 |                   |         | - ifnewer                                     |
768 |                   |         | - always                                      |
769 +-------------------+---------+-----------------------------------------------+
770 | create[restorejob]| string  | Restore job name                              |
771 | *                 |         |                                               |
772 +-------------------+---------+-----------------------------------------------+
773
774 * - required field
775 \end{verbatim}
776
777 DELETE /api/jobs/8 - delete by bconsole job with jobid equal 8.\\
778
779 Errors:
780
781 0 - No errors.
782
783 1 - Invalid command.
784
785 2 - Problem with connection to database.
786
787 3 - Database access is not supported by this API instance.
788
789 4 - Problem with connection to bconsole.
790
791 5 - Invalid director.
792
793 6 - Problem with authorization to Baculum API.
794
795 7 - Access attempt to not allowed resource. Permission denied.
796
797 50 - Job with inputted jobid does not exist.
798
799 51 - Inputed job level is invalid.
800
801 52 - Fileset resource does not exist.
802
803 53 - Client does not exist.
804
805 54 - Storage does not exist.
806
807 55 - Pool does not exist.
808
809 56 - [restore only] inputted rpath for restore is invalid. Proper format
810 is b2[0-9]+.
811
812 57 - [restore only] inputted "where" option is invalid.
813
814 58 - [restore only] inputted "replace" option is invalid.
815
816 1000 - internal error.\\
817
818 \subsection{Bvfs}
819
820 PUT /api/bvfs/lsdirs/ - listing from Bvfs cache directories
821
822 PUT /api/bvfs/lsdirs/limit/250 - listing from Bvfs cache directories
823  limited to 250 elements.
824
825 PUT /api/bvfs/lsdirs/limit/250/100/ - listing from Bvfs cache directories
826  limited to 250 elements with offset equal 100.
827
828 \begin{verbatim}
829 +-----------------------------------------------------------------------------+
830 |                      /api/bvfs/lsdirs/ PUT request                          |
831 +-------------------+---------+-----------------------------------------------+
832 | Name              |  Type   |    Description                                |
833 +-------------------+---------+-----------------------------------------------+
834 | update[jobids] *  | string  | Job identifiers separated by comma character  |
835 |                   |         |                                               |
836 +-------------------+---------+-----------------------------------------------+
837 | update[path] *    | string  | Path to list directories in Bvfs job cache    |
838 |                   |         |                                               |
839 +-------------------+---------+-----------------------------------------------+
840 \end{verbatim}
841
842 PUT /api/bvfs/lsfiles/ - listing from Bvfs cache files.
843
844 PUT /api/bvfs/lsfiles/limit/60/ - listing from Bvfs cache files limited
845  to 60 elements.
846
847 PUT /api/bvfs/lsfiles/limit/120/60/ - listing from Bvfs cache files limited
848  to 120 elements with offset equal 60
849
850 \begin{verbatim}
851 +-----------------------------------------------------------------------------+
852 |                      /api/bvfs/lsfiles/ PUT request                         |
853 +-------------------+---------+-----------------------------------------------+
854 | Name              |  Type   |    Description                                |
855 +-------------------+---------+-----------------------------------------------+
856 | update[jobids] *  | string  | Job identifiers separated by comma character  |
857 |                   |         |                                               |
858 +-------------------+---------+-----------------------------------------------+
859 | update[path] *    | string  | Path to list directories in Bvfs job cache    |
860 |                   |         |                                               |
861 +-------------------+---------+-----------------------------------------------+
862 \end{verbatim}
863
864 GET /api/bvfs/versions/abc-fd/123/456/789/ - listing from Bvfs cache all
865  files versions for client named abc-fd, for jobid equal 123, for pathid
866 equal 456 and for filenameid equal 789. URL-encoded client name is necessary.
867
868 GET /api/bvfs/getjobids/9/ - listing from Bvfs cache all elementary jobids which
869  are necessary for restore all files from job with jobid equal 9 (eg. if jobid 9
870   is job type incremental or differential).
871
872 PUT /api/bvfs/update/ - updating Bvfs cache for specific job.
873
874 \begin{verbatim}
875 +-----------------------------------------------------------------------------+
876 |                      /api/bvfs/update/ PUT request                          |
877 +-------------------+---------+-----------------------------------------------+
878 | Name              |  Type   |    Description                                |
879 +-------------------+---------+-----------------------------------------------+
880 | update[jobids] *  | string  | Job identifiers separated by comma character  |
881 |                   |         |                                               |
882 +-------------------+---------+-----------------------------------------------+
883 \end{verbatim}
884
885 POST /api/bvfs/restore/ - preparing Bvfs paths for restore command.
886
887 \begin{verbatim}
888 +-----------------------------------------------------------------------------+
889 |                      /api/bvfs/restore/ POST request                        |
890 +-------------------+---------+-----------------------------------------------+
891 | Name              |  Type   |    Description                                |
892 +-------------------+---------+-----------------------------------------------+
893 | create[jobids] *  | string  | job identifiers comma separated               |
894 |                   |         |                                               |
895 +-------------------+---------+-----------------------------------------------+
896 | create[dirid]     | string  | directory identifiers comma separated         |
897 |                   |         |                                               |
898 +-------------------+---------+-----------------------------------------------+
899 | create[fileid]    | string  | file identifiers comma separated              |
900 |                   |         |                                               |
901 +-------------------+---------+-----------------------------------------------+
902 | create[path] *    | string  | temporary Bvfs table table name               |
903 |                   |         | in form b2[0-9]+                              |
904 +-------------------+---------+-----------------------------------------------+
905
906 * - required field
907 \end{verbatim}
908
909 PUT /api/bvfs/clear/ - call '.bvfs\_clear\_cache yes' bconsole command.\\
910
911
912 Errors:
913
914 0 - No errors.
915
916 1 - Invalid command.
917
918 2 - Problem with connection to database.
919
920 3 - Database access is not supported by this API instance.
921
922 4 - Problem with connection to bconsole.
923
924 5 - Invalid director.
925
926 6 - Problem with authorization to Baculum API.
927
928 7 - Access attempt to not allowed resource. Permission denied.
929
930 70 - Job with inputted jobid does not exist.
931
932 71 - Inputted path for restore is invalid. Proper format is b2[0-9]+.
933
934 1000 - Internal error.
935
936 \subsection{Config}
937
938 To configure the Bacula resources is used request in the following URL form:\\
939
940 PUT /api/config/COMPONENT\_TYPE/RESOURCE\_TYPE/RESOURCE\_NAME
941
942 \begin{itemize}
943 \item COMPONENT\_TYPE: dir for Director, sd for Storage Daemon, fd for
944  File Daemon and bcons for Consoles
945 \item RESOURCE\_TYPE: Job, Client, Pool, Messages, Schedule, Storage...etc.
946 \item RESOURCE\_NAME: Resource name from 'Name' resource directive like
947  'My Client 123', 'Device-01', 'Pool-Incremental-2' ...etc.
948 \end{itemize}
949
950 Example config URLs:\\
951
952 PUT /api/config/dir/Client/myclient-fd - editing client 'myclient-fd'. If
953  the Client doesn't exist, it is created in config.
954
955 PUT /api/config/sd/Device/Drive-01 - editing device 'Drive-01'. If
956  the Device doesn't exist, it is created in config.
957
958 \begin{verbatim}
959 +-----------------------------------------------------------------------------+
960 |    /api/config/component_type/resource_type/resource_name/ PUT request      |
961 +-------------------+---------+-----------------------------------------------+
962 | Name              |  Type   |    Description                                |
963 +-------------------+---------+-----------------------------------------------+
964 | update[config] *  | string  | Bacula config in JSON format.                 |
965 |                   | (JSON)  |                                               |
966 |                   |         | In versions lower than 9.0.6 instead of JSON  |
967 |                   |         | string there was used serialized associative  |
968 |                   |         | PHP array                                     |
969 +-------------------+---------+-----------------------------------------------+
970
971 * - required field
972 \end{verbatim}
973
974 Errors:
975
976 0 - No errors.
977
978 6 - Problem with authorization to Baculum API.
979
980 7 - Access attempt to not allowed resource. Permission denied.
981
982 80 - JSON tools support is disabled.
983
984 81 - Problem with connection to a JSON tool.
985
986 82 - JSON tool returned wrong exitcode.
987
988 83 - JSON tool output was unable to parse.
989
990 84 - JSON tool not configured.
991
992 93 - Write to config file error.
993
994 94 - Config validation error.
995
996 1000 - Internal error.\\
997
998
999 Example cURL commands to test:
1000
1001 \begin{verbatim}
1002 curl -X PUT -d update["config"]='{"AutoPrune":false,"Catalog":"MyCatalog",
1003 "FdPort":9102,"MaximumConcurrentJobs":5,"Name":"easystar-fd","Address":
1004 "172.16.10.12","Password":"mypass"}'
1005  http://user:pass@apihost:9096/api/config/dir/Client/easystar-fd
1006
1007 curl -X PUT -d update["config"]='{"RemovableMedia":true,"RandomAccess":false,
1008 "AutomaticMount":true,"AlwaysOpen":true,"OfflineOnUnmount":true,"DeviceType":
1009 "Tape","Name":"TapeDrive","MediaType":"LTO5","ArchiveDevice":"/dev/nst0",
1010 "SpoolDirectory":"/mnt/backup","MaximumOpenWait":300}'
1011  http://user:pass@apihost:9096/api/config/sd/Device/TapeDrive
1012 \end{verbatim}
1013
1014 \section{Installation from the Source Tar File}
1015
1016 You may also install Baculum from the source bacula-gui tar archive.
1017
1018 To prepare Baculum runtime files one uses the Makefile file.
1019 To do this, after unpacking bacula-gui archive please go to Baculum main
1020 directory:
1021
1022 \begin{verbatim}
1023 cd ./web/baculum/
1024 \end{verbatim}
1025
1026 Then please run (depending on used distribution):
1027
1028 For rpm-based distributions (example with /tmp/baculum-runtime destination
1029 directory):
1030
1031 \begin{verbatim}
1032 make build DESTDIR=/tmp/baculum-runtime
1033 \end{verbatim}
1034
1035 For deb-based distributions (example with /tmp/baculum-runtime destination
1036 directory):
1037
1038 \begin{verbatim}
1039 make build DESTDIR=/tmp/baculum-release SAMPLETYPE=deb-template \
1040 HTTPDNAME=apache2 HTTPDSITECONF=sites-available
1041 \end{verbatim}
1042
1043 After execution above command, in path /tmp/baculum-runtime should
1044 contain all required runtime files.
1045
1046 The Base Baculum source files will be located in:
1047
1048 \begin{verbatim}
1049 /tmp/baculum-runtime/usr/share/baculum/htdocs/
1050 \end{verbatim}
1051
1052 These are the files that should be placed in web server's document root (or
1053 Virtual Host document root) directory.
1054
1055 Please note that for language files (including English)
1056 symbolic links must be created as shown below:
1057
1058 \begin{verbatim}
1059 /usr/share/locale/en/LC_MESSAGES/baculum.mo
1060  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/en/baculum.mo
1061
1062 /usr/share/locale/pl/LC_MESSAGES/baculum.mo
1063  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/pl/baculum.mo
1064
1065 /usr/share/locale/pt/LC_MESSAGES/baculum.mo
1066  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/pt/baculum.mo
1067
1068 /usr/share/locale/ja/LC_MESSAGES/baculum.mo
1069  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/ja/baculum.mo
1070 \end{verbatim}
1071
1072 Please also update the symbolic link to the Baculum settings directory in
1073 the following paths:
1074
1075 \begin{verbatim}
1076 /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/API/Config
1077 /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Web/Config
1078 \end{verbatim}
1079
1080 Other files are: web servers configuration files, systemd units, SELinux
1081 policy module and others. Please select and copy appropriate files to your
1082 system environment and edit their content if needed.
1083
1084 You must set read/write privileges for the Web server user
1085 to the files and directories listed below:
1086
1087 \begin{verbatim}
1088 ./baculum/assets/
1089 ./baculum/protected/Web/Config
1090 ./baculum/protected/API/Config
1091 ./baculum/protected/Web/baculum.users
1092 ./baculum/protected/API/baculum.users
1093 ./baculum/protected/runtime/
1094 \end{verbatim}
1095
1096 \section{OAuth2 authorization}
1097
1098 Baculum API can use OAuth2 for authorization and authentication.
1099
1100 To obtain tokens there is used {\bf Authorization Code Grant} flow.
1101 Authorization and access token URLs are as follows:
1102
1103 \begin{verbatim}
1104 Authorization URL: /api/auth/
1105 Access Token URL: /api/token/
1106 \end{verbatim}
1107
1108 Baculum API doesn't use refresh tokens. After expiration token the client
1109 application has to re-authorize again.
1110
1111 Default expiration time for authorization code is 7 seconds, for access
1112 token 60 seconds. These values are changed in:
1113
1114 \begin{verbatim}
1115 /usr/share/baculum/htdocs/protected/Common/Class/OAuth2.php
1116 \end{verbatim}
1117
1118 in constants AUTHORIZATION\_ID\_EXPIRES\_TIME and ACCESS\_TOKEN\_EXPIRES\_TIME.
1119
1120 Default OAuth2 callback URL in Baculum Web is following:
1121
1122 \begin{verbatim}
1123 https://baculumgui:9095/web/redirect
1124 \end{verbatim}
1125
1126 \subsection{Before running OAuth2}
1127
1128 {\bf Important note before using OAuth2}
1129
1130 When you decide to use OAuth2, you must change default HTTP Basic authorization
1131 setting. Otherwise OAuth2 will not work. It is for enabling OAuth2 acces for
1132 /api/ endpoints but still keep HTTP Basic protection for the Baculum API panel
1133 pages.
1134
1135 For Apache the change is about switching in Baculum API Apache config
1136 the Location tag from / to /api/page.
1137
1138 \begin{verbatim}
1139 # NOTE: When you use OAuth2 then change this location section
1140 # From: <Location />
1141 # To:   <Location /api/page>
1142 #
1143 <Location />
1144         AuthType Basic
1145         AuthName "Baculum Auth"
1146         AuthUserFile /usr/share/baculum/htdocs/protected/API/Config/baculum.users
1147         Require valid-user
1148 </Location>
1149 \end{verbatim}
1150
1151
1152 For Lighttpd the change is about uncommenting in API Lighttpd config lines as
1153 described in comment below.
1154
1155 \begin{verbatim}
1156 #
1157 # Uncomment this line and closing braces below when you use OAuth2
1158 #
1159 # $HTTP["url"] =~ "^/web/page/.*$" {
1160         auth.backend = "htpasswd"
1161         auth.backend.htpasswd.userfile = "/usr/share/baculum/htdocs/protected/API/Config/baculum.users"
1162         auth.require = ( "/" => (
1163                 "method" => "basic",
1164                 "realm" => "Baculum Auth",
1165                 "require" => "valid-user"
1166                 )
1167         )
1168 # }
1169 \end{verbatim}
1170
1171
1172 \section{Screenshots}
1173
1174 \includegraphics[width=\linewidth]{baculum01.png}
1175
1176 \smallskip
1177
1178 \includegraphics[width=\linewidth]{baculum02.png}
1179
1180 \smallskip
1181
1182 \includegraphics[width=\linewidth]{baculum03.png}
1183
1184 \smallskip
1185
1186 \includegraphics[width=\linewidth]{baculum04.png}
1187
1188 \smallskip
1189
1190 \includegraphics[width=\linewidth]{baculum05.png}
1191
1192 \smallskip
1193
1194 \includegraphics[width=\linewidth]{baculum06.png}
1195
1196 \smallskip
1197
1198 \includegraphics[width=\linewidth]{baculum07.png}