]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/console/baculum.tex
baculum: Update api endpoints documentation
[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 11 - Bconsole support is disabled.
498
499 1000 - Internal error.
500
501 \subsection{Storages}
502
503 GET /api/storages/ - get records all storages.
504
505 GET /api/storages/limit/25 - get records first 25 storages.
506
507 GET /api/storages/3 - get records only for storage with storageid equal 3.
508
509 GET /api/storages/show - get 'show storages' bconsole command.
510
511 GET /api/storages/show/3 - get 'show storage=xxx' bconsole command for storage with storageid equal 3.
512
513 GET /api/storages/status/3 - get 'status storage=xxx' bconsole command for storage with storageid equal 3.
514
515 GET /api/storages/mount/3/2/17 - mount storage with storageid equal 3, drive number 2 and volume in slot number 17.
516
517 GET /api/storages/umount/3/1 - umount storage with storageid equal 3 and drive number 1.
518
519 GET /api/storages/release/3 - release storage with storageid equal 3.\\
520
521
522 Errors:
523
524 0 - No errors.
525
526 1 - Invalid command.
527
528 2 - Problem with connection to database.
529
530 3 - Database access is not supported by this API instance.
531
532 4 - Problem with connection to bconsole.
533
534 5 - Invalid director.
535
536 6 - Problem with authorization to Baculum API.
537
538 7 - Access attempt to not allowed resource. Permission denied.
539
540 11 - Bconsole support is disabled.
541
542 20 - Storage with inputted storageid does not exists.
543
544 1000 - Internal error.
545
546 \subsection{Volumes}
547
548 GET /api/volumes/ - get records all volumes.
549
550 GET /api/volumes/limit/50 - get records first 50 volumes.
551
552 GET /api/volumes/5 - get records only for volume with mediaid equal 5.
553
554 GET /api/volumes/prune/5 - call prune action on volume with mediaid equal 5.
555
556 GET /api/volumes/purge/5 - call purge action on volume with mediaid equal 5.
557
558 GET /api/volumes/jobs/5 - get all jobs done on volume with mediaid equal 5.\\
559
560 GET /api/volumes/required/7/1234/ - get all volumes required to restore file
561  with fileid equal 1234 and jobid equal 7.
562
563
564 Errors:
565
566 0 - No errors.
567
568 1 - Invalid command.
569
570 2 - Problem with connection to database.
571
572 3 - Database access is not supported by this API instance.
573
574 4 - Problem with connection to bconsole.
575
576 5 - Invalid director.
577
578 6 - Problem with authorization to Baculum API.
579
580 7 - Access attempt to not allowed resource. Permission denied.
581
582 11 - Bconsole support is disabled.
583
584 30 - Volume with inputted mediaid does not exists.
585
586 1000 - Internal error.
587
588 \subsection{Pools}
589
590 GET /api/pools/ - get records all pools.
591
592 GET /api/pools/limit/15 - get records first 15 pools.
593
594 GET /api/pools/7 - get records only for pool with poolid equal 7.
595
596 GET /api/pools/show - get 'show pools' bconsole command.
597
598 GET /api/pools/show/7 - get 'show pool=xxx' bconsole command for pool with poolid equal 7.
599
600 PUT /api/pools/update/7 - call 'update pool=xxx' bconsole command for pool with poolid equal 7.\\
601
602
603 Errors:
604
605 0 - No errors.
606
607 1 - Invalid command.
608
609 2 - Problem with connection to database.
610
611 3 - Database access is not supported by this API instance.
612
613 4 - Problem with connection to bconsole.
614
615 5 - Invalid director.
616
617 6 - Problem with authorization to Baculum API.
618
619 7 - Access attempt to not allowed resource. Permission denied.
620
621 11 - Bconsole support is disabled.
622
623 40 - Pool with inputted poolid does not exists.
624
625 1000 - internal error.\\
626
627 \subsection{Jobs}
628
629 GET /api/jobs/ - get records all jobs.
630
631 GET /api/jobs/limit/20 - get records first 20 jobs.
632
633 GET /api/jobs/8 - get records only for job with jobid equal 8.
634
635 GET /api/jobs/tasks/ - get job names for all directors
636
637 GET /api/jobs/tasks/type/B - get backup job names
638
639 GET /api/jobs/tasks/type/R/limit/5 - get first 5 restore job names
640
641 GET /api/jobs/recent/myjob/client/myclient-fd/filesetid/62/ - get most
642 recent job identifiers for job "myjob", client "myclient-fd" and fileset
643 with filesetid 62
644
645 GET /api/jobs/recent/myjob/clientid/31/filesetid/62/ - get most
646 recent job identifiers for job "myjob", client with clientid 21 and fileset
647 with filesetid 62
648
649 POST /jobs/estimate/ - call estimate action on a job.
650
651 \begin{verbatim}
652 +-----------------------------------------------------------------------------+
653 |                      /api/jobs/estimate/ POST request                       |
654 +-------------------+---------+-----------------------------------------------+
655 | Name              |  Type   |    Description                                |
656 +-------------------+---------+-----------------------------------------------+
657 | create[id] *      | integer | job id to get job name for estimate purpose   |
658 |                   |         | (used instead job name)                       |
659 +-------------------+---------+-----------------------------------------------+
660 | create[name] *    | string  | job name to estimate (used instead of jobid)  |
661 |                   |         |                                               |
662 +-------------------+---------+-----------------------------------------------+
663 | create[fileset] * | string  | FileSet resource name                         |
664 |                   |         |                                               |
665 +-------------------+---------+-----------------------------------------------+
666 | create[level] *   | string  | Job level in short form.                      |
667 |                   |         | One case sensitive letter:                    |
668 |                   |         |    F => Full                                  |
669 |                   |         |    I => Incremental                           |
670 |                   |         |    D => Differential                          |
671 |                   |         |    B => Base                                  |
672 |                   |         |    f => VirtualFull                           |
673 |                   |         |    V => InitCatalog                           |
674 |                   |         |    C => Catalog                               |
675 |                   |         |    O => VolumeToCatalog                       |
676 |                   |         |    d => DiskToCatalog                         |
677 +-------------------+---------+-----------------------------------------------+
678 | create[clientid] *| integer | Client identifier                             |
679 |                   |         | (used instead of client name)                 |
680 +-------------------+---------+-----------------------------------------------+
681 | create[client] *  | string  | Client name (used instead of client id)       |
682 |                   |         |                                               |
683 +-------------------+---------+-----------------------------------------------+
684 | create[accurate] *| integer | Enable accurate mode: 0 - no, 1 - yes         |
685 |                   |         |                                               |
686 +-------------------+---------+-----------------------------------------------+
687
688 * - required field
689 \end{verbatim}
690
691 POST /api/jobs/run/ - call run action on job (run job).
692
693 \begin{verbatim}
694 +-----------------------------------------------------------------------------+
695 |                      /api/jobs/run/ POST request                            |
696 +-------------------+---------+-----------------------------------------------+
697 | Name              |  Type   |    Description                                |
698 +-------------------+---------+-----------------------------------------------+
699 | create[id] *      | integer | job id to get job name to run                 |
700 |                   |         | (used instead job name)                       |
701 +-------------------+---------+-----------------------------------------------+
702 | create[name] *    | string  | job name to run (used instead of jobid)       |
703 |                   |         |                                               |
704 +-------------------+---------+-----------------------------------------------+
705 | create[level] *   | string  | Job level in short form.                      |
706 |                   |         | One case sensitive letter:                    |
707 |                   |         |    F => Full                                  |
708 |                   |         |    I => Incremental                           |
709 |                   |         |    D => Differential                          |
710 |                   |         |    B => Base                                  |
711 |                   |         |    f => VirtualFull                           |
712 |                   |         |    V => InitCatalog                           |
713 |                   |         |    C => Catalog                               |
714 |                   |         |    O => VolumeToCatalog                       |
715 |                   |         |    d => DiskToCatalog                         |
716 +-------------------+---------+-----------------------------------------------+
717 | create[fileset] * | string  | FileSet resource name                         |
718 |                   |         |                                               |
719 +-------------------+---------+-----------------------------------------------+
720 | create[clientid] *| integer | Client identifier                             |
721 |                   |         | (used instead of client name)                 |
722 +-------------------+---------+-----------------------------------------------+
723 | create[client] *  | string  | Client name (used instead of client id)       |
724 |                   |         |                                               |
725 +-------------------+---------+-----------------------------------------------+
726 | create[storageid]*| integer | Storage identifier                            |
727 |                   |         | (used instead of storage name)                |
728 +-------------------+---------+-----------------------------------------------+
729 | create[storage] * | string  | Storage name (used instead of storage id)     |
730 |                   |         |                                               |
731 +-------------------+---------+-----------------------------------------------+
732 | create[poolid] *  | integer | Pool identifier (used instead of pool name)   |
733 |                   |         |                                               |
734 +-------------------+---------+-----------------------------------------------+
735 | create[pool] *    | string  | Pool name (used instead of pool id)           |
736 |                   |         |                                               |
737 +-------------------+---------+-----------------------------------------------+
738 | create[priority]  | integer | Job priority to run                           |
739 |                   |         |                                               |
740 +-------------------+---------+-----------------------------------------------+
741 | create[jobid]     | integer | Job identifier for verify job                 |
742 |                   |         |                                               |
743 +-------------------+---------+-----------------------------------------------+
744 | create[verifyjob] | string  | Verify job name                               |
745 |                   |         |                                               |
746 +-------------------+---------+-----------------------------------------------+
747
748 * - required field
749 \end{verbatim}
750
751 POST /api/jobs/restore/ - call restore action.
752
753 \begin{verbatim}
754 +-------------------------------------------------------------------------------+
755 |                       /api/jobs/restore/ POST request                         |
756 +---------------------+---------+-----------------------------------------------+
757 | Name                |  Type   |    Description                                |
758 +---------------------+---------+-----------------------------------------------+
759 | create[rpath] *     | string  | Bvfs temporary table name for restore purpose |
760 |                     |         | in form: b2[0-9]+                             |
761 +---------------------+---------+-----------------------------------------------+
762 | create[clientid] *  | integer | Client identifier                             |
763 |                     |         | (used instead of client name)                 |
764 +---------------------+---------+-----------------------------------------------+
765 | create[client] *    | string  | Client name (used instead of client id)       |
766 |                     |         |                                               |
767 +---------------------+---------+-----------------------------------------------+
768 | create[priority]    | integer | Job priority to run                           |
769 |                     |         |                                               |
770 +---------------------+---------+-----------------------------------------------+
771 | create[where] *     | string  | Destination directory for restored files      |
772 |                     |         |                                               |
773 +---------------------+---------+-----------------------------------------------+
774 | create[replace] *   | string  | Replace files in destination directory for    |
775 |                     |         | restored files. Available options:            |
776 |                     |         | - never                                       |
777 |                     |         | - ifolder                                     |
778 |                     |         | - ifnewer                                     |
779 |                     |         | - always                                      |
780 +---------------------+---------+-----------------------------------------------+
781 | create[restorejob]  | string  | Restore job name                              |
782 |                     |         |                                               |
783 +---------------------+---------+-----------------------------------------------+
784 | create[strip_prefix]| string  | Strip prefix from restored paths /etc         |
785 |                     |         |                                               |
786 +---------------------+---------+-----------------------------------------------+
787 | create[add_prefix]  | string  | Add prefix to restored paths /tmp/myetc       |
788 |                     |         | It can't be used with 'where' parameter       |
789 +---------------------+---------+-----------------------------------------------+
790 | create[add_suffix]  | string  | Add suffix to restored path e.g. .old         |
791 |                     |         |                                               |
792 +---------------------+---------+-----------------------------------------------+
793 | create[regex_where] | string  | Pattern matched for each restored path        |
794 |                     |         | e.g. !a.pdf!a.bkp.pdf!                        |
795 +---------------------+---------+-----------------------------------------------+
796
797 * - required field
798 \end{verbatim}
799
800 DELETE /api/jobs/8 - delete by bconsole job with jobid equal 8.\\
801
802 Errors:
803
804 0 - No errors.
805
806 1 - Invalid command.
807
808 2 - Problem with connection to database.
809
810 3 - Database access is not supported by this API instance.
811
812 4 - Problem with connection to bconsole.
813
814 5 - Invalid director.
815
816 6 - Problem with authorization to Baculum API.
817
818 7 - Access attempt to not allowed resource. Permission denied.
819
820 11 - Bconsole support is disabled.
821
822 50 - Job with inputted jobid does not exist.
823
824 51 - Inputed job level is invalid.
825
826 52 - Fileset resource does not exist.
827
828 53 - Client does not exist.
829
830 54 - Storage does not exist.
831
832 55 - Pool does not exist.
833
834 56 - [restore only] inputted rpath for restore is invalid. Proper format
835 is b2[0-9]+.
836
837 57 - [restore only] inputted "where" option is invalid.
838
839 58 - [restore only] inputted "replace" option is invalid.
840
841 1000 - internal error.\\
842
843 \subsection{Bvfs}
844
845 PUT /api/bvfs/lsdirs/ - listing from Bvfs cache directories
846
847 PUT /api/bvfs/lsdirs/limit/250 - listing from Bvfs cache directories
848  limited to 250 elements.
849
850 PUT /api/bvfs/lsdirs/limit/250/100/ - listing from Bvfs cache directories
851  limited to 250 elements with offset equal 100.
852
853 \begin{verbatim}
854 +-----------------------------------------------------------------------------+
855 |                      /api/bvfs/lsdirs/ PUT request                          |
856 +-------------------+---------+-----------------------------------------------+
857 | Name              |  Type   |    Description                                |
858 +-------------------+---------+-----------------------------------------------+
859 | update[jobids] *  | string  | Job identifiers separated by comma character  |
860 |                   |         |                                               |
861 +-------------------+---------+-----------------------------------------------+
862 | update[path] *    | string  | Path to list directories in Bvfs job cache    |
863 |                   |         |                                               |
864 +-------------------+---------+-----------------------------------------------+
865 \end{verbatim}
866
867 PUT /api/bvfs/lsfiles/ - listing from Bvfs cache files.
868
869 PUT /api/bvfs/lsfiles/limit/60/ - listing from Bvfs cache files limited
870  to 60 elements.
871
872 PUT /api/bvfs/lsfiles/limit/120/60/ - listing from Bvfs cache files limited
873  to 120 elements with offset equal 60
874
875 \begin{verbatim}
876 +-----------------------------------------------------------------------------+
877 |                      /api/bvfs/lsfiles/ PUT request                         |
878 +-------------------+---------+-----------------------------------------------+
879 | Name              |  Type   |    Description                                |
880 +-------------------+---------+-----------------------------------------------+
881 | update[jobids] *  | string  | Job identifiers separated by comma character  |
882 |                   |         |                                               |
883 +-------------------+---------+-----------------------------------------------+
884 | update[path] *    | string  | Path to list directories in Bvfs job cache    |
885 |                   |         |                                               |
886 +-------------------+---------+-----------------------------------------------+
887 \end{verbatim}
888
889 GET /api/bvfs/versions/abc-fd/123/456/789/ - listing from Bvfs cache all
890  files versions for client named abc-fd, for jobid equal 123, for pathid
891 equal 456 and for filenameid equal 789. URL-encoded client name is necessary.
892
893 GET /api/bvfs/getjobids/9/ - listing from Bvfs cache all elementary jobids which
894  are necessary for restore all files from job with jobid equal 9 (eg. if jobid 9
895   is job type incremental or differential).
896
897 PUT /api/bvfs/update/ - updating Bvfs cache for specific job.
898
899 \begin{verbatim}
900 +-----------------------------------------------------------------------------+
901 |                      /api/bvfs/update/ PUT request                          |
902 +-------------------+---------+-----------------------------------------------+
903 | Name              |  Type   |    Description                                |
904 +-------------------+---------+-----------------------------------------------+
905 | update[jobids] *  | string  | Job identifiers separated by comma character  |
906 |                   |         |                                               |
907 +-------------------+---------+-----------------------------------------------+
908 \end{verbatim}
909
910 POST /api/bvfs/restore/ - preparing Bvfs paths for restore command.
911
912 \begin{verbatim}
913 +-----------------------------------------------------------------------------+
914 |                      /api/bvfs/restore/ POST request                        |
915 +-------------------+---------+-----------------------------------------------+
916 | Name              |  Type   |    Description                                |
917 +-------------------+---------+-----------------------------------------------+
918 | create[jobids] *  | string  | job identifiers comma separated               |
919 |                   |         |                                               |
920 +-------------------+---------+-----------------------------------------------+
921 | create[dirid]     | string  | directory identifiers comma separated         |
922 |                   |         |                                               |
923 +-------------------+---------+-----------------------------------------------+
924 | create[fileid]    | string  | file identifiers comma separated              |
925 |                   |         |                                               |
926 +-------------------+---------+-----------------------------------------------+
927 | create[findex]    | string  | comma separated pairs jobid and fileindex e.g.|
928 |                   |         | jobid1,findex1,jobid2,findex2                 |
929 |                   |         | Used to restore hardlinks                     |
930 +-------------------+---------+-----------------------------------------------+
931 | create[path] *    | string  | temporary Bvfs table table name               |
932 |                   |         | in form b2[0-9]+                              |
933 +-------------------+---------+-----------------------------------------------+
934
935 * - required field
936 \end{verbatim}
937
938 PUT /api/bvfs/clear/ - call '.bvfs\_clear\_cache yes' bconsole command.\\
939
940
941 Errors:
942
943 0 - No errors.
944
945 1 - Invalid command.
946
947 2 - Problem with connection to database.
948
949 3 - Database access is not supported by this API instance.
950
951 4 - Problem with connection to bconsole.
952
953 5 - Invalid director.
954
955 6 - Problem with authorization to Baculum API.
956
957 7 - Access attempt to not allowed resource. Permission denied.
958
959 11 - Bconsole support is disabled.
960
961 71 - Inputted path for restore is invalid. Proper format is b2[0-9]+.
962
963 72 - Inputted BVFS path param is invalid.
964
965 73 - Invalid jobid list.
966
967 74 - Invalid fileid list.
968
969 75 - Invalid file index list.
970
971 76 - Invalid dirid list.
972
973 77 - Invalid client name.
974
975 1000 - Internal error.
976
977 \subsection{Config}
978
979 To configure the Bacula resources is used request in the following URL form:\\
980
981 PUT /api/config/COMPONENT\_TYPE/RESOURCE\_TYPE/RESOURCE\_NAME
982
983 \begin{itemize}
984 \item COMPONENT\_TYPE: dir for Director, sd for Storage Daemon, fd for
985  File Daemon and bcons for Consoles
986 \item RESOURCE\_TYPE: Job, Client, Pool, Messages, Schedule, Storage...etc.
987 \item RESOURCE\_NAME: Resource name from 'Name' resource directive like
988  'My Client 123', 'Device-01', 'Pool-Incremental-2' ...etc.
989 \end{itemize}
990
991 Example config URLs:\\
992
993 PUT /api/config/dir/Client/myclient-fd - editing client 'myclient-fd'. If
994  the Client doesn't exist, it is created in config.
995
996 PUT /api/config/sd/Device/Drive-01 - editing device 'Drive-01'. If
997  the Device doesn't exist, it is created in config.
998
999 \begin{verbatim}
1000 +-----------------------------------------------------------------------------+
1001 |    /api/config/component_type/resource_type/resource_name/ PUT request      |
1002 +-------------------+---------+-----------------------------------------------+
1003 | Name              |  Type   |    Description                                |
1004 +-------------------+---------+-----------------------------------------------+
1005 | update[config] *  | string  | Bacula config in JSON format.                 |
1006 |                   | (JSON)  |                                               |
1007 |                   |         | In versions lower than 9.0.6 instead of JSON  |
1008 |                   |         | string there was used serialized associative  |
1009 |                   |         | PHP array                                     |
1010 +-------------------+---------+-----------------------------------------------+
1011
1012 * - required field
1013 \end{verbatim}
1014
1015 Errors:
1016
1017 0 - No errors.
1018
1019 6 - Problem with authorization to Baculum API.
1020
1021 7 - Access attempt to not allowed resource. Permission denied.
1022
1023 80 - JSON tools support is disabled.
1024
1025 81 - Problem with connection to a JSON tool.
1026
1027 82 - JSON tool returned wrong exitcode.
1028
1029 83 - JSON tool output was unable to parse.
1030
1031 84 - JSON tool not configured.
1032
1033 93 - Write to config file error.
1034
1035 94 - Config validation error.
1036
1037 1000 - Internal error.\\
1038
1039
1040 Example cURL commands to test:
1041
1042 \begin{verbatim}
1043 curl -X PUT -d update["config"]='{"AutoPrune":false,"Catalog":"MyCatalog",
1044 "FdPort":9102,"MaximumConcurrentJobs":5,"Name":"easystar-fd","Address":
1045 "172.16.10.12","Password":"mypass"}'
1046  http://user:pass@apihost:9096/api/config/dir/Client/easystar-fd
1047
1048 curl -X PUT -d update["config"]='{"RemovableMedia":true,"RandomAccess":false,
1049 "AutomaticMount":true,"AlwaysOpen":true,"OfflineOnUnmount":true,"DeviceType":
1050 "Tape","Name":"TapeDrive","MediaType":"LTO5","ArchiveDevice":"/dev/nst0",
1051 "SpoolDirectory":"/mnt/backup","MaximumOpenWait":300}'
1052  http://user:pass@apihost:9096/api/config/sd/Device/TapeDrive
1053 \end{verbatim}
1054
1055 \section{Installation from the Source Tar File}
1056
1057 You may also install Baculum from the source bacula-gui tar archive.
1058
1059 To prepare Baculum runtime files one uses the Makefile file.
1060 To do this, after unpacking bacula-gui archive please go to Baculum main
1061 directory:
1062
1063 \begin{verbatim}
1064 cd ./web/baculum/
1065 \end{verbatim}
1066
1067 Then please run (depending on used distribution):
1068
1069 For rpm-based distributions (example with /tmp/baculum-runtime destination
1070 directory):
1071
1072 \begin{verbatim}
1073 make build DESTDIR=/tmp/baculum-runtime
1074 \end{verbatim}
1075
1076 For deb-based distributions (example with /tmp/baculum-runtime destination
1077 directory):
1078
1079 \begin{verbatim}
1080 make build DESTDIR=/tmp/baculum-release SAMPLETYPE=deb-template \
1081 HTTPDNAME=apache2 HTTPDSITECONF=sites-available
1082 \end{verbatim}
1083
1084 After execution above command, in path /tmp/baculum-runtime should
1085 contain all required runtime files.
1086
1087 The Base Baculum source files will be located in:
1088
1089 \begin{verbatim}
1090 /tmp/baculum-runtime/usr/share/baculum/htdocs/
1091 \end{verbatim}
1092
1093 These are the files that should be placed in web server's document root (or
1094 Virtual Host document root) directory.
1095
1096 Please note that for language files (including English)
1097 symbolic links must be created as shown below:
1098
1099 \begin{verbatim}
1100 /usr/share/locale/en/LC_MESSAGES/baculum.mo
1101  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/en/baculum.mo
1102
1103 /usr/share/locale/pl/LC_MESSAGES/baculum.mo
1104  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/pl/baculum.mo
1105
1106 /usr/share/locale/pt/LC_MESSAGES/baculum.mo
1107  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/pt/baculum.mo
1108
1109 /usr/share/locale/ja/LC_MESSAGES/baculum.mo
1110  => /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Lang/ja/baculum.mo
1111 \end{verbatim}
1112
1113 Please also update the symbolic link to the Baculum settings directory in
1114 the following paths:
1115
1116 \begin{verbatim}
1117 /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/API/Config
1118 /tmp/baculum-runtime/usr/share/baculum/htdocs/protected/Web/Config
1119 \end{verbatim}
1120
1121 Other files are: web servers configuration files, systemd units, SELinux
1122 policy module and others. Please select and copy appropriate files to your
1123 system environment and edit their content if needed.
1124
1125 You must set read/write privileges for the Web server user
1126 to the files and directories listed below:
1127
1128 \begin{verbatim}
1129 ./baculum/assets/
1130 ./baculum/protected/Web/Config
1131 ./baculum/protected/API/Config
1132 ./baculum/protected/Web/baculum.users
1133 ./baculum/protected/API/baculum.users
1134 ./baculum/protected/runtime/
1135 \end{verbatim}
1136
1137 \section{OAuth2 authorization}
1138
1139 Baculum API can use OAuth2 for authorization and authentication.
1140
1141 To obtain tokens there is used {\bf Authorization Code Grant} flow.
1142 Authorization and access token URLs are as follows:
1143
1144 \begin{verbatim}
1145 Authorization URL: /api/auth/
1146 Access Token URL: /api/token/
1147 \end{verbatim}
1148
1149 Baculum API doesn't use refresh tokens. After expiration token the client
1150 application has to re-authorize again.
1151
1152 Default expiration time for authorization code is 7 seconds, for access
1153 token 60 seconds. These values are changed in:
1154
1155 \begin{verbatim}
1156 /usr/share/baculum/htdocs/protected/Common/Class/OAuth2.php
1157 \end{verbatim}
1158
1159 in constants AUTHORIZATION\_ID\_EXPIRES\_TIME and ACCESS\_TOKEN\_EXPIRES\_TIME.
1160
1161 Default OAuth2 callback URL in Baculum Web is following:
1162
1163 \begin{verbatim}
1164 https://baculumgui:9095/web/redirect
1165 \end{verbatim}
1166
1167 \subsection{Before running OAuth2}
1168
1169 {\bf Important note before using OAuth2}
1170
1171 When you decide to use OAuth2, you must change default HTTP Basic authorization
1172 setting. Otherwise OAuth2 will not work. It is for enabling OAuth2 acces for
1173 /api/ endpoints but still keep HTTP Basic protection for the Baculum API panel
1174 pages.
1175
1176 For Apache the change is about switching in Baculum API Apache config
1177 the Location tag from / to /api/page.
1178
1179 \begin{verbatim}
1180 # NOTE: When you use OAuth2 then change this location section
1181 # From: <Location />
1182 # To:   <Location /api/page>
1183 #
1184 <Location />
1185         AuthType Basic
1186         AuthName "Baculum Auth"
1187         AuthUserFile /usr/share/baculum/htdocs/protected/API/Config/baculum.users
1188         Require valid-user
1189 </Location>
1190 \end{verbatim}
1191
1192
1193 For Lighttpd the change is about uncommenting in API Lighttpd config lines as
1194 described in comment below.
1195
1196 \begin{verbatim}
1197 #
1198 # Uncomment this line and closing braces below when you use OAuth2
1199 #
1200 # $HTTP["url"] =~ "^/web/page/.*$" {
1201         auth.backend = "htpasswd"
1202         auth.backend.htpasswd.userfile = "/usr/share/baculum/htdocs/protected/API/Config/baculum.users"
1203         auth.require = ( "/" => (
1204                 "method" => "basic",
1205                 "realm" => "Baculum Auth",
1206                 "require" => "valid-user"
1207                 )
1208         )
1209 # }
1210 \end{verbatim}
1211
1212
1213 \section{Screenshots}
1214
1215 \includegraphics[width=\linewidth]{baculum01.png}
1216
1217 \smallskip
1218
1219 \includegraphics[width=\linewidth]{baculum02.png}
1220
1221 \smallskip
1222
1223 \includegraphics[width=\linewidth]{baculum03.png}
1224
1225 \smallskip
1226
1227 \includegraphics[width=\linewidth]{baculum04.png}
1228
1229 \smallskip
1230
1231 \includegraphics[width=\linewidth]{baculum05.png}
1232
1233 \smallskip
1234
1235 \includegraphics[width=\linewidth]{baculum06.png}
1236
1237 \smallskip
1238
1239 \includegraphics[width=\linewidth]{baculum07.png}