]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/console/bconsole.tex
429c744f113388d462c8d3d1aa349b4054015e54
[bacula/docs] / docs / manuals / en / console / bconsole.tex
1 %%
2 %%
3
4 \chapter{Bacula Enterprise Console}
5 \label{_ConsoleChapter}
6 \index[general]{Console!Bacula}
7 \index[general]{Bacula Console}
8
9 The {\bf \mbacula{} Console} (sometimes called the User Agent) is a program
10 that allows the user or the System Administrator, to interact with the
11  \mbacula{} \director{} daemon while the daemon is running.
12
13 The current \mbacula{} Console comes in two versions: a shell interface (TTY
14 style), and a QT GUI interface (\bat{}). Both permit the administrator or
15 authorized users to interact with \mbacula{}. You can determine the status of a
16 particular job, examine the contents of the Catalog as well as perform certain
17 tape manipulations with the Console program.
18
19 Since the Console program interacts with the \director{} through the network,
20  your Console and \director{} programs do not necessarily need to run on the
21  same machine.
22
23 In fact, a certain minimal knowledge of the Console program is needed in order
24 for \mbacula{} to be able to write on more than one tape, because when \mbacula{}
25 requests a new tape, it waits until the user, via the Console program,
26 indicates that the new tape is mounted.
27
28 \section{Console Configuration}
29 \index[general]{Console Configuration}
30 \index[general]{Configuration!Console}
31
32 When the Console starts, it reads a standard \mbacula{} configuration file
33 named {\bf bconsole.conf} or {\bf bat.conf} in the case of the Bat
34 QT Console version from the current directory unless you specify the {\bf {-}c}
35 command line option (see below). This file allows default configuration
36 of the Console, and at the current time, the only Resource Record defined
37 is the Director resource, which gives the Console the name and address of
38 the Director.  For more information on configuration of the Console
39 program, please see the \bsysxrlink{Console Configuration}{ConsoleConfChapter}
40 {main}{chapter} of the \mainman{}.
41
42 \section{Running the Console Program}
43 \index[general]{Running the Console Program}
44 \index[general]{Program!Running the Console}
45
46 The console program can be run with the following options:
47 %%%\footnotesize
48 \begin{lstlisting}
49 Usage: bconsole [-s] [-c config_file] [-d debug_level]
50        -c <file>   set configuration file to file
51        -dnn        set debug level to nn
52        -n          no conio
53        -s          no signals
54        -u <nn>     set command execution timeout to <nn> seconds
55        -t          test - read configuration and exit
56        -?          print this message.
57 \end{lstlisting}
58 \normalsize
59
60
61 After launching the Console program (bconsole), it will prompt you for the next
62 command with an asterisk (*).  Generally, for all commands, you can simply
63 enter the command name and the Console program will prompt you for the
64 necessary arguments. Alternatively, in most cases, you may enter the command
65 followed by arguments. The general format is:
66
67 %%%\footnotesize
68 \begin{lstlisting}
69  <command> <keyword1>[=<argument1>] <keyword2>[=<argument2>] ...
70 \end{lstlisting}
71 \normalsize
72
73 where {\bf command} is one of the commands listed below; {\bf keyword} is one
74 of the keywords listed below (usually followed by an argument); and {\bf
75 argument} is the value. The command may be abbreviated to the shortest unique
76 form. If two commands have the same starting letters, the one that will be
77 selected is the one that appears first in the {\bf help} listing. If you want
78 the second command, simply spell out the full command. None of the keywords
79 following the command may be abbreviated.
80
81 For example:
82
83 %%%\footnotesize
84 \begin{lstlisting}
85 list files jobid=23
86 \end{lstlisting}
87 \normalsize
88
89 will list all files saved for JobId 23. Or:
90
91 %%%\footnotesize
92 \begin{lstlisting}
93 show pools
94 \end{lstlisting}
95 \normalsize
96
97 will display all the Pool resource records.
98
99 The maximum command line length is limited to 511 characters, so if you
100 are scripting the console, you may need to take some care to limit the
101 line length.
102
103 \section{Stopping the Console Program}
104 \index[general]{Program!Stopping the Console}
105 \index[general]{Stopping the Console Program}
106
107 Normally, you simply enter {\bf quit} or {\bf exit} and the Console program
108 will terminate. However, it waits until the Director acknowledges the command.
109 If the Director is already doing a lengthy command (e.g. prune), it may take
110 some time. If you want to immediately terminate the Console program, enter the
111 {\bf .quit} command.
112
113 There is currently no way to interrupt a Console command once issued (i.e.
114 Ctrl-C does not work). However, if you are at a prompt that is asking you to
115 select one of several possibilities and you would like to abort the command,
116 you can enter a period ({\bf .}), and in most cases, you will either be
117 returned to the main command prompt or if appropriate the previous prompt (in
118 the case of nested prompts). In a few places such as where it is asking for a
119 Volume name, the period will be taken to be the Volume name. In that case, you
120 will most likely be able to cancel at the next prompt.
121
122 \label{keywords}
123 \section{Alphabetic List of Console Keywords}
124 \index[general]{Keywords!Alphabetic List of Console}
125 \index[general]{Alphabetic List of Console Keywords}
126 Unless otherwise specified, each of the following keywords
127 takes an argument, which is specified after the keyword following
128 an equal sign. For example:
129
130 \begin{lstlisting}
131 jobid=536
132 \end{lstlisting}
133
134 Please note, this list is incomplete as it is currently in
135 the process of being created and is not currently totally in
136 alphabetic
137 order ...
138
139 \begin{description}
140 \item [restart]
141   Permitted on the python command, and causes the Python
142   interpreter to be restarted. Takes no argument.
143 \item [all]
144   Permitted on the status and show commands to specify all components or
145   resources respectively.
146 \item [allfrompool]
147   Permitted on the update command to specify that all Volumes in the
148   pool (specified on the command line) should be updated.
149 \item [allfrompools]
150   Permitted on the update command to specify that all Volumes in all
151   pools should be updated.
152 \item [before]
153   Used in the restore command.
154 \item [bootstrap]
155   Used in the restore command.
156 \item [catalog]
157   Allowed in the use command to specify the catalog name
158   to be used.
159 \item [catalogs]
160   Used in the show command. Takes no arguments.
161 \item [client | fd]
162 \item [clients]
163   Used in the show, list, and llist commands. Takes no arguments.
164 \item [counters]
165   Used in the show command. Takes no arguments.
166 \item [current]
167   Used in the restore command. Takes no argument.
168 \item [days]
169   Used to define the number of days the "list nextvol" command
170   should consider when looking for jobs to be run.  The days keyword
171   can also be used on the "status dir" command so that it will display
172   jobs scheduled for the number of days you want.
173 \item [devices]
174   Used in the show command. Takes no arguments.
175 \item [dir | director]
176 \item [directors]
177   Used in the show command. Takes no arguments.
178 \item [directory]
179   Used in the restore command. Its argument specifies the directory
180   to be restored.
181 \item [enabled]
182   This keyword can appear on the {\bf update volume} as well
183   as the {\bf update slots} commands, and can
184   allows one of the following arguments: yes, true, no, false, archived,
185   0, 1, 2.  Where 0 corresponds to no or false, 1 corresponds to yes or true, and
186   2 corresponds to archived.  Archived volumes will not be used, nor will
187   the Media record in the catalog be pruned. Volumes that are not enabled,
188   will not be used for backup or restore.
189 \item [done]
190   Used in the restore command. Takes no argument.
191 \item [file]
192   Used in the restore command.
193 \item [files]
194   Used in the list and llist commands. Takes no arguments.
195 \item [fileset]
196 \item [filesets]
197   Used in the show command. Takes no arguments.
198 \item [help]
199   Used in the show command. Takes no arguments.
200 \item [jobs]
201   Used in the show, list and llist commands. Takes no arguments.
202 \item [jobmedia]
203   Used in the list and llist commands. Takes no arguments.
204 \item [jobtotals]
205   Used in the list and llist commands. Takes no arguments.
206 \item [jobid]
207   The JobId is the numeric jobid that is printed in the Job
208   Report output. It is the index of the database record for the
209   given job. While it is unique for all the existing Job records
210   in the catalog database, the same JobId can be reused once a
211   Job is removed from the catalog. Probably you will refer
212   specific Jobs that ran using their numeric JobId.
213 \item [job | jobname]
214   The Job or Jobname keyword refers to the name you specified
215   in the Job resource, and hence it refers to any number of
216   Jobs that ran.  It is typically useful if you want to list
217   all jobs of a particular name.
218 \item [level]
219 \item [listing]
220   Permitted on the estimate command. Takes no argument.
221 \item [limit]
222 \item [messages]
223   Used in the show command. Takes no arguments.
224 \item [media]
225   Used in the list and llist commands. Takes no arguments.
226 \item [nextvol | nextvolume]
227   Used in the list and llist commands. Takes no arguments.
228 \item [on]
229   Takes no keyword.
230 \item [off]
231   Takes no keyword.
232 \item [pool]
233 \item [pools]
234   Used in the show, list, and llist commands. Takes no arguments.
235 \item [select]
236   Used in the restore command. Takes no argument.
237 \item[limit]
238   Used in the setbandwidth command. Takes integer in KB/s unit.
239 \item [storages]
240   Used in the show command. Takes no arguments.
241 \item [schedules]
242   Used in the show command. Takes no arguments.
243 \item [sd | store | storage]
244 \item [ujobid]
245   The ujobid is a unique job identification that is printed
246   in the Job Report output. At the current time, it consists
247   of the Job name (from the Name directive for the job) appended
248   with the date and time the job was run. This keyword is useful
249   if you want to completely identify the Job instance run.
250 \item [volume]
251 \item [volumes]
252   Used in the list and llist commands. Takes no arguments.
253 \item [where]
254   Used in the restore command.
255 \item [yes]
256   Used in the restore command. Takes no argument.
257 \end{description}
258
259 \label{list}
260 \section{Alphabetic List of Console Commands}
261 \index[general]{Commands!Alphabetic List of Console}
262 \index[general]{Alphabetic List of Console Commands}
263 \index[general]{Commands!Alphabetic List of Console}
264 \index[general]{Alphabetic List of Console Commands}
265
266 The following commands are currently implemented:
267
268 \begin{description}
269 \item [{add [pool=\lt{}pool-name\gt{} storage=\lt{}storage\gt{}
270    jobid=\lt{}JobId\gt{}]} ]
271    \index[general]{add}
272    This command is used to add Volumes to an existing Pool.  That is,
273    it creates the Volume name in the catalog and inserts into the Pool
274    in the catalog, but does not attempt to access the physical Volume.
275    Once
276    added, \mbacula{} expects that Volume to exist and to be labeled.
277    This command is not normally used since \mbacula{} will
278    automatically do the equivalent when Volumes are labeled. However,
279    there may be times when you have removed a Volume from the catalog
280    and want to later add it back.
281
282    Normally, the {\bf label} command is used rather than this command
283    because the {\bf label} command labels the physical media (tape, disk,
284    DVD, ...) and does the equivalent of the {\bf add} command.  The {\bf
285    add} command affects only the Catalog and not the physical media (data
286    on Volumes).  The physical media must exist and be labeled before use
287    (usually with the {\bf label} command).  This command can, however, be
288    useful if you wish to add a number of Volumes to the Pool that will be
289    physically labeled at a later time.  It can also be useful if you are
290    importing a tape from another site.  Please see the {\bf label} command
291    below for the list of legal characters in a Volume name.
292
293 \item [autodisplay on/off]
294    \index[general]{autodisplay on/off}
295    This command accepts {\bf on} or {\bf off} as an argument, and turns
296    auto-display of messages on or off respectively.  The default for the
297    console program is {\bf off}, which means that you will be notified when
298    there are console messages pending, but they will not automatically be
299    displayed.
300
301    When autodisplay is turned off, you must explicitly retrieve the
302    messages with the {\bf messages} command.  When autodisplay is turned
303    on, the messages will be displayed on the console as they are received.
304
305 \item [automount on/off]
306    \index[general]{automount on/off}
307    This command accepts {\bf on} or {\bf off} as the argument, and turns
308    auto-mounting of the Volume after a {\bf label} command on or off
309    respectively.  The default is {\bf on}.  If {\bf automount} is turned
310    off, you must explicitly {\bf mount} tape Volumes after a label command to
311    use it.
312
313 \item [{cancel [jobid=\lt{}number\gt{} job=\lt{}job-name\gt{} ujobid=\lt{}unique-jobid\gt{}]}]
314    \index[general]{cancel jobid}
315    This command is used to cancel a job and accepts {\bf jobid=nnn} or {\bf
316    job=xxx} as an argument where nnn is replaced by the JobId and xxx is
317    replaced by the job name.  If you do not specify a keyword, the Console
318    program will prompt you with the names of all the active jobs allowing
319    you to choose one.
320
321    Once a Job is marked to be canceled, it may take a bit of time
322    (generally within a minute but up to two hours) before the Job actually
323    terminates, depending on what operations it is doing.
324    Don't be surprised that you receive a Job not found message. That just
325    means that one of the three daemons had already canceled the job.
326    Messages numbered in the 1000's are from the Director, 2000's are from
327    the File daemon and 3000's from the Storage daemon.
328
329
330 \item [{create [pool=\lt{}pool-name\gt{}]}]
331    \index[general]{create pool}
332    This command is not normally used as the Pool records are automatically
333    created by the Director when it starts based on what it finds in
334    the conf file.  If needed, this command can be
335    to create a Pool record in the database using the
336    Pool resource record defined in the Director's configuration file.  So
337    in a sense, this command simply transfers the information from the Pool
338    resource in the configuration file into the Catalog.  Normally this
339    command is done automatically for you when the Director starts providing
340    the Pool is referenced within a Job resource.  If you use this command
341    on an existing Pool, it will automatically update the Catalog to have
342    the same information as the Pool resource.  After creating a Pool, you
343    will most likely use the {\bf label} command to label one or more
344    volumes and add their names to the Media database.
345
346    When starting a Job, if \mbacula{} determines that there is no Pool record
347    in the database, but there is a Pool resource of the appropriate name,
348    it will create it for you.  If you want the Pool record to appear in the
349    database immediately, simply use this command to force it to be created.
350
351 \item [{delete [volume=\lt{}vol-name\gt{} pool=\lt{}pool-name\gt{}  job
352    jobid=\lt{}id\gt{}]}]
353    \index[general]{delete}
354    The delete command is used to delete a Volume, Pool or Job record from
355    the Catalog as well as all associated catalog Volume records that were
356    created.  This command operates only on the Catalog database and has no
357    effect on the actual data written to a Volume.  This command can be
358    dangerous and we strongly recommend that you do not use it unless you
359    know what you are doing.
360
361    If the keyword {\bf Volume} appears on the command line, the named
362    Volume will be deleted from the catalog, if the keyword {\bf Pool}
363    appears on the command line, a Pool will be deleted, and if the keyword
364    {\bf Job} appears on the command line, a Job and all its associated
365    records (File and JobMedia) will be deleted from the catalog.  The full
366    form of this command is:
367
368 \begin{lstlisting}
369 delete pool=<pool-name>
370 \end{lstlisting}
371
372    or
373
374 \begin{lstlisting}
375 delete volume=<volume-name> pool=<pool-name>  or
376 \end{lstlisting}
377
378 \begin{lstlisting}
379 delete JobId=<job-id> JobId=<job-id2> ...  or
380 \end{lstlisting}
381
382 \begin{lstlisting}
383 delete Job JobId=n,m,o-r,t ...
384 \end{lstlisting}
385
386    The first form deletes a Pool record from the catalog database.  The
387    second form deletes a Volume record from the specified pool in the
388    catalog database.  The third form deletes the specified Job record from
389    the catalog database.  The last form deletes JobId records for JobIds
390    n, m, o, p, q, r, and t.  Where each one of the n,m,...  is, of course, a
391    number. That is a "delete jobid" accepts lists and ranges of
392    jobids.
393
394 \item [disable job\lt{}job-name\gt{}]
395   \index[general]{disable}
396   This command permits you to disable a Job for automatic scheduling.
397   The job may have been previously enabled with the Job resource
398   {\bf Enabled} directive or using the console {\bf enable} command.
399   The next time the Director is restarted or the conf file is reloaded,
400   the Enable/Disable state will be set to the value in the Job resource
401   (default enabled) as defined in the bacula-dir.conf file.
402
403 \item [enable job\lt{}job-name\gt{}]
404   \index[general]{enable}
405   This command permits you to enable a Job for automatic scheduling.
406   The job may have been previously disabled with the Job resource
407   {\bf Enabled} directive or using the console {\bf disable} command.
408   The next time the Director is restarted or the conf file is reloaded,
409   the Enable/Disable state will be set to the value in the Job resource
410   (default enabled) as defined in the bacula-dir.conf file.
411
412 \label{estimate}
413 \item [estimate]
414    \index[general]{estimate}
415    Using this command, you can get an idea how many files will be backed
416    up, or if you are unsure about your Include statements in your FileSet,
417    you can test them without doing an actual backup.  The default is to
418    assume a Full backup.  However, you can override this by specifying a
419    {\bf level=Incremental} or {\bf level=Differential} on the command line.
420    A Job name must be specified or you will be prompted for one, and
421    optionally a Client and FileSet may be specified on the command line.
422    It then contacts the client which computes the number of files and bytes
423    that would be backed up.  Please note that this is an estimate
424    calculated from the number of blocks in the file rather than by reading
425    the actual bytes.  As such, the estimated backup size will generally be
426    larger than an actual backup.
427
428    The \texttt{estimate} command can use the accurate code to detect changes
429    and give a better estimation. You can set the accurate behavior on command
430    line using \texttt{accurate=yes/no} or use the Job setting as default value.
431
432    Optionally you may specify the keyword {\bf listing} in  which case, all the
433    files to be backed up will be listed.  Note, it could take quite some time to
434    display them if the  backup is large. The full form is:
435
436 \begin{lstlisting}
437 estimate job=<job-name> listing client=<client-name> accurate=<yes/no>
438        fileset=<fileset-name> level=<level-name>
439 \end{lstlisting}
440
441    Specification of the {\bf job} is sufficient, but you can also override the
442    client, fileset, accurate and/or level by specifying them on the estimate
443    command line.
444
445
446 As an example, you might do:
447
448 %%%\footnotesize
449 \begin{lstlisting}
450      @output /tmp/listing
451      estimate job=NightlySave listing level=Incremental
452      @output
453 \end{lstlisting}
454 \normalsize
455
456    which will do a full listing of all files to be backed up for the  Job {\bf
457    NightlySave} during an Incremental save and put it in the  file {\bf
458    /tmp/listing}.  Note, the byte estimate provided by this command is
459    based on the file size contained in the directory item. This can give
460    wildly incorrect estimates of the actual storage used if there are
461    sparse files on your systems. Sparse files are often found on 64 bit
462    systems for certain system files. The size that is returned is the size
463    \mbacula{} will backup if the sparse option is not specified in the FileSet.
464    There is currently no way to get an estimate of the real file size that
465    would be found should the sparse option be enabled.
466
467 \item [exit]
468    \index[general]{exit}
469    This command terminates the console program.
470
471 \item [gui]
472    \index[general]{gui}
473    Invoke the non-interactive gui mode.
474 \begin{lstlisting}
475 gui [on|off]
476 \end{lstlisting}
477
478 \item [help]
479    \index[general]{help}
480    This command displays the list of commands available.
481
482 \item [label]
483    \index[general]{label}
484    \index[general]{relabel}
485    This command is used to label physical volumes.  The full form of this command
486    is:
487
488 \begin{lstlisting}
489 label storage=<storage-name> volume=<volume-name>
490       slot=<slot>
491 \end{lstlisting}
492
493    If you leave out any part, you will be prompted for it.  The media type
494    is automatically taken from the Storage resource definition that you
495    supply.  Once the necessary information is obtained, the Console program
496    contacts the specified Storage daemon and requests that the Volume be
497    labeled.  If the Volume labeling is successful, the Console program will
498    create a Volume record in the appropriate Pool.
499
500    The Volume name is restricted to letters, numbers, and the special
501    characters hyphen ({\bf -}), underscore ({\bf \_}), colon ({\bf :}), and
502    period ({\bf .}).  All other characters including a space are invalid.
503    This restriction is to ensure good readability of Volume names to reduce
504    operator errors.
505
506    Please note, when labeling a blank tape, \mbacula{} will get {\bf read I/O
507    error} when it attempts to ensure that the tape is not already labeled.  If
508    you wish to avoid getting these messages, please write an EOF mark on
509    your tape before attempting to label it:
510
511 %%%\footnotesize
512 \begin{lstlisting}
513        mt rewind
514        mt weof
515
516 \end{lstlisting}
517 \normalsize
518
519 The label command can fail for a number of reasons:
520
521 \begin{enumerate}
522 \item The Volume name you specify is already in the  Volume database.
523
524 \item The Storage daemon has a tape or other Volume already mounted on the
525    device, in which case you must {\bf unmount} the device, insert a blank
526    tape, then do the {\bf label} command.
527
528 \item The Volume in the device is already a \mbacula{} labeled Volume.  (\mbacula{} will
529    never relabel a \mbacula{} labeled Volume unless it is recycled and you use the
530    {\bf relabel} command).
531
532 \item There is no Volume in the drive.
533 \end{enumerate}
534
535 There are two ways to relabel a volume that already has a \mbacula{} label. The
536 brute  force method is to write an end of file mark on the tape  using the
537 system {\bf mt} program, something like the  following:
538
539 %%%\footnotesize
540 \begin{lstlisting}
541        mt -f /dev/st0 rewind
542        mt -f /dev/st0 weof
543 \end{lstlisting}
544 \normalsize
545
546 For a disk volume, you would manually delete the Volume.
547
548 Then you use the {\bf label} command to add a new label.  However, this could
549 leave traces of the old volume in the  catalog.
550
551 The preferable method to relabel a Volume is to first {\bf purge}  the volume,
552 either automatically, or explicitly with the  {\bf purge} command, then use
553 the {\bf relabel} command described  below.
554
555 If your autochanger has barcode labels, you can label all the Volumes in
556 your autochanger one after another by using the {\bf label barcodes}
557 command.  For each tape in the changer containing a barcode, \mbacula{} will
558 mount the tape and then label it with the same name as the barcode.  An
559 appropriate Media record will also be created in the catalog.  Any barcode
560 that begins with the same characters as specified on the
561 "CleaningPrefix=xxx" directive in the Director's Pool resource, will be
562 treated as a cleaning tape, and will not be labeled.  However, an entry for
563 the cleaning tape will be created in the catalog.  For example with:
564
565 %%%\footnotesize
566 \begin{lstlisting}
567         Pool {
568           Name ...
569           Cleaning Prefix = "CLN"
570        }
571
572 \end{lstlisting}
573 \normalsize
574
575 Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
576 and will not be mounted.  Note, the full form of the command is:
577
578 %%%\footnotesize
579 \begin{lstlisting}
580 label storage=xxx pool=yyy slots=1-5,10 barcodes
581 \end{lstlisting}
582 \normalsize
583
584 \item [list]
585    \index[general]{list}
586    The list command lists the requested contents of the Catalog.  The
587    various fields of each record are listed on a single line.  The various
588    forms of the list command are:
589 %%%\footnotesize
590 \begin{lstlisting}
591    list jobs
592
593    list jobid=<id>           (list jobid id)
594
595    list ujobid=<unique job name> (list job with unique name)
596
597    list job=<job-name>   (list all jobs with "job-name")
598
599    list jobname=<job-name>  (same as above)
600
601        In the above, you can add "limit=nn" to limit the output to
602        nn jobs.
603
604    list joblog jobid=<id> (list job output if recorded in the catalog)
605
606    list jobmedia
607
608    list jobmedia jobid=<id>
609
610    list jobmedia job=<job-name>
611
612    list files jobid=<id>
613
614    list files job=<job-name>
615
616    list pools
617
618    list clients
619
620    list jobtotals
621
622    list volumes
623
624    list volumes jobid=<id>
625
626    list volumes pool=<pool-name>
627
628    list volumes job=<job-name>
629
630    list volume=<volume-name>
631
632    list nextvolume job=<job-name>
633
634    list nextvol job=<job-name>
635
636    list nextvol job=<job-name> days=nnn
637
638 \end{lstlisting}
639 \normalsize
640
641    What most of the above commands do should be more or less obvious.  In
642    general if you do not specify all the command line arguments, the
643    command will prompt you for what is needed.
644
645    The {\bf list nextvol} command will print the Volume name to be used by
646    the specified job.  You should be aware that exactly what Volume will be
647    used depends on a lot of factors including the time and what a prior job
648    will do.  It may fill a tape that is not full when you issue this
649    command.  As a consequence, this command will give you a good estimate
650    of what Volume will be used but not a definitive answer.  In addition,
651    this command may have certain side effect because it runs through the
652    same algorithm as a job, which means it may automatically purge or
653    recycle a Volume. By default, the job specified must run within the
654    next two days or no volume will be found. You can, however, use the
655    {\bf days=nnn} specification to specify up to 50 days. For example,
656    if on Friday, you want to see what Volume will be needed on Monday,
657    for job MyJob, you would use {\bf list nextvol job=MyJob days=3}.
658
659    If you wish to add specialized commands that list the contents of the
660    catalog, you can do so by adding them to the {\bf query.sql} file.
661    However, this takes some knowledge of programming SQL. Please see the
662    {\bf query} command below for additional information.  See below for
663    listing the full contents of a catalog record with the {\bf llist}
664    command.
665
666    As an example, the command {\bf list pools} might produce  the following
667    output:
668
669 %%%\footnotesize
670 \begin{lstlisting}
671 +------+---------+---------+---------+----------+-------------+
672 | PoId | Name    | NumVols | MaxVols | PoolType | LabelFormat |
673 +------+---------+---------+---------+----------+-------------+
674 |    1 | Default |       0 |       0 | Backup   | *           |
675 |    2 | Recycle |       0 |       8 | Backup   | File        |
676 +------+---------+---------+---------+----------+-------------+
677 \end{lstlisting}
678 \normalsize
679
680    As mentioned above, the {\bf list} command lists what is in the
681    database.  Some things are put into the database immediately when \mbacula{}
682    starts up, but in general, most things are put in only when they are
683    first used, which is the case for a Client as with Job records, etc.
684
685    \mbacula{} should create a client record in the database the first time you
686    run a job for that client.  Doing a {\bf status} will not cause a
687    database record to be created.  The client database record will be
688    created whether or not the job fails, but it must at least start.  When
689    the Client is actually contacted, additional info from the client will
690    be added to the client record (a "uname -a" output).
691
692    If you want to see what Client resources you have available in your conf
693    file, you use the Console command {\bf show clients}.
694
695 \item [llist]
696    \index[general]{llist}
697    The llist or "long list" command takes all the same arguments that the
698    list command described above does.  The difference is that the llist
699    command list the full contents of each database record selected.  It
700    does so by listing the various fields of the record vertically, with one
701    field per line.  It is possible to produce a very large number of output
702    lines with this command.
703
704    If instead of the {\bf list pools} as in the example above, you enter
705    {\bf llist pools} you might get the following output:
706
707 %%%\footnotesize
708 \begin{lstlisting}
709           PoolId: 1
710             Name: Default
711          NumVols: 0
712          MaxVols: 0
713          UseOnce: 0
714       UseCatalog: 1
715  AcceptAnyVolume: 1
716     VolRetention: 1,296,000
717   VolUseDuration: 86,400
718       MaxVolJobs: 0
719      MaxVolBytes: 0
720        AutoPrune: 0
721          Recycle: 1
722         PoolType: Backup
723      LabelFormat: *
724
725           PoolId: 2
726             Name: Recycle
727          NumVols: 0
728          MaxVols: 8
729          UseOnce: 0
730       UseCatalog: 1
731  AcceptAnyVolume: 1
732     VolRetention: 3,600
733   VolUseDuration: 3,600
734       MaxVolJobs: 1
735      MaxVolBytes: 0
736        AutoPrune: 0
737          Recycle: 1
738         PoolType: Backup
739      LabelFormat: File
740
741 \end{lstlisting}
742 \normalsize
743
744 \item [messages]
745    \index[general]{messages}
746    This command causes any pending  console messages to be immediately displayed.
747
748 \item [memory]
749    \index[general]{memory}
750    Print current memory usage.
751
752
753 \item [mount]
754    \index[general]{mount}
755    The mount command is used to get \mbacula{} to read a volume on a physical
756    device.  It is a way to tell \mbacula{} that you have mounted a tape and
757    that \mbacula{} should examine the tape.  This command is normally
758    used only after there was no Volume in a drive and \mbacula{} requests you to mount a new
759    Volume or when you have specifically unmounted a Volume with the {\bf
760    unmount} console command, which causes \mbacula{} to close the drive.  If
761    you have an autoloader, the mount command will not cause \mbacula{} to
762    operate the autoloader unless you specify a {\bf slot} and possibly a
763    {\bf drive}. The various forms of the mount command are:
764 \begin{lstlisting}
765 mount  storage=<storage-name> [ slot=<num> ] [
766        drive=<num> ]
767 \end{lstlisting}
768
769
770 \begin{lstlisting}
771 mount [ jobid=<id> |  job=<job-name> ]
772 \end{lstlisting}
773    If you have specified {\bf Automatic  Mount = yes} in the Storage daemon's
774    Device resource,  under most circumstances, \mbacula{} will automatically access
775    the Volume unless you have explicitly {\bf unmount}ed it in  the Console
776    program.
777
778 \label{ManualPruning}
779 \item [prune]
780    \index[general]{prune}
781    The Prune command allows you to safely remove expired database records from
782    Jobs, Volumes and Statistics.  This command works only on the Catalog
783    database and does not affect data written to Volumes.  In all cases, the
784    Prune command applies a retention period to the specified records.  You can
785    Prune expired File entries from Job records; you can Prune expired Job
786    records from the database, and you can Prune both expired Job and File
787    records from specified Volumes.
788 \begin{lstlisting}
789 prune files|jobs|volume|stats client=<client-name>
790 volume=<volume-name>
791 \end{lstlisting}
792    For a Volume to be pruned, the {\bf VolStatus} must be Full, Used, or
793    Append, otherwise the pruning will not take place.
794
795 \item [purge]
796    \index[general]{purge}
797    The Purge command will delete associated Catalog database records from
798    Jobs and Volumes without considering the retention period.  {\bf Purge}
799    works only on the Catalog database and does not affect data written to
800    Volumes.  This command can be dangerous because you can delete catalog
801    records associated with current backups of files, and we recommend that
802    you do not use it unless you know what you are doing.  The permitted
803    forms of {\bf purge} are:
804 \begin{lstlisting}
805 purge files jobid=<jobid>|job=<job-name>|client=<client-name>
806 \end{lstlisting}
807 \begin{lstlisting}
808 purge jobs client=<client-name> (of all jobs)
809 \end{lstlisting}
810 \begin{lstlisting}
811 purge volume|volume=<vol-name> (of all jobs)
812 \end{lstlisting}
813 For the {\bf purge} command to work on Volume Catalog database  records the
814 {\bf VolStatus}  must be Append, Full, Used, or Error.
815
816 The actual data written to the Volume will be unaffected by this command unless
817 you are using the \texttt{ActionOnPurge=Truncate} option on those Media.
818
819 To ask \mbacula{} to truncate your \texttt{Purged} volumes, you need to use the
820 following command in interactive mode or in a RunScript:
821 \begin{lstlisting}
822 *purge volume action=truncate storage=File allpools
823 # or by default, action=all
824 *purge volume action storage=File pool=Default
825 \end{lstlisting}
826
827 This is possible to specify the volume name, the media type, the pool, the
828 storage, etc\dots (see \texttt{help purge}) Be sure that your storage device is
829 idle when you decide to run this command.
830
831 \item[python]
832    \index[general]{python}
833   The python command takes a single argument {\bf restart}:
834
835 python restart
836
837    This causes the Python interpreter in the Director to be reinitialized.
838    This can be helpful for testing because once the Director starts and the
839    Python interpreter is initialized, there is no other way to make it
840    accept any changes to the startup script {\bf DirStartUp.py}.  For more
841    details on Python scripting, please see the \bsysxrlink{Python Scripting}
842    {PythonChapter}{misc}{chapter} of the \miscman{}.
843
844 \item [query]
845    \index[general]{query}
846    This command reads a predefined SQL query from  the query file (the name and
847    location of the  query file is defined with the QueryFile resource record in
848    the Director's configuration file). You are prompted to select  a query from
849    the file, and possibly enter one or more parameters,  then the command is
850    submitted to the Catalog database SQL engine.
851
852 The following queries are currently available (version 2.2.7):
853
854 %%%\footnotesize
855 \begin{lstlisting}
856 Available queries:
857 1: List up to 20 places where a File is saved regardless of the directory
858 2: List where the most recent copies of a file are saved
859 3: List last 20 Full Backups for a Client
860 4: List all backups for a Client after a specified time
861 5: List all backups for a Client
862 6: List Volume Attributes for a selected Volume
863 7: List Volumes used by selected JobId
864 8: List Volumes to Restore All Files
865 9: List Pool Attributes for a selected Pool
866 10: List total files/bytes by Job
867 11: List total files/bytes by Volume
868 12: List Files for a selected JobId
869 13: List Jobs stored on a selected MediaId
870 14: List Jobs stored for a given Volume name
871 15: List Volumes Bacula thinks are in changer
872 16: List Volumes likely to need replacement from age or errors
873 Choose a query (1-16):
874 \end{lstlisting}
875 \normalsize
876
877 \item [quit]
878    \index[general]{quit}
879    This command terminates the console program. The  console program sends the
880    {\bf quit} request to the Director  and waits for acknowledgment. If the
881    Director is busy doing  a previous command for you that has not terminated, it
882    may  take some time. You may quit immediately by issuing the  {\bf .quit}
883    command (i.e. quit preceded by a period).
884
885 \item [relabel]
886    \index[general]{relabel}
887    This command is used to label physical volumes.  The full form of this
888    command is:
889 \begin{lstlisting}
890 relabel storage=<storage-name> oldvolume=<old-volume-name>
891     volume=<newvolume-name>
892 \end{lstlisting}
893    If you leave out any part, you will be prompted for it.  In order for
894    the Volume (old-volume-name) to be relabeled, it must be in the catalog,
895    and the volume status must be marked {\bf Purged} or {\bf Recycle}.
896    This happens automatically as a result of applying retention periods, or
897    you may explicitly purge the volume using the {\bf purge} command.
898
899    Once the volume is physically relabeled, the old data previously written
900    on the Volume is lost and cannot be recovered.
901
902 \item [release]
903    \index[general]{release}
904    This command is used to cause the Storage daemon to rewind (release) the
905    current tape in the drive, and to re-read the Volume label the next time
906    the tape is used.
907 \begin{lstlisting}
908 release storage=<storage-name>
909 \end{lstlisting}
910    After a release command, the device is still kept open by \mbacula{} (unless
911    Always Open is set to No in the Storage Daemon's configuration) so it
912    cannot be used by another program.  However, with some tape drives, the
913    operator can remove the current tape and to insert a different one, and
914    when the next Job starts, \mbacula{} will know to re-read the tape label to
915    find out what tape is mounted.  If you want to be able to use the drive
916    with another program (e.g.  {\bf mt}), you must use the {\bf unmount}
917    command to cause \mbacula{} to completely release (close) the device.
918
919 \item [reload]
920   \index[general]{reload}
921   The reload command causes the Director to re-read its configuration
922   file and apply the new values. The new values will take effect
923   immediately for all new jobs.  However, if you change schedules,
924   be aware that the scheduler pre-schedules jobs up to two hours in
925   advance, so any changes that are to take place during the next two
926   hours may be delayed.  Jobs that have already been scheduled to run
927   (i.e. surpassed their requested start time) will continue with the
928   old values.  New jobs will use the new values. Each time you issue
929   a reload command while jobs are running, the prior config values
930   will queued until all jobs that were running before issuing
931   the reload terminate, at which time the old config values will
932   be released from memory. The Directory permits keeping up to
933   ten prior set of configurations before it will refuse a reload
934   command. Once at least one old set of config values has been
935   released it will again accept new reload commands.
936
937    While it is possible to reload the Director's configuration on the fly,
938    even while jobs are executing, this is a complex operation and not
939    without side effects.  Accordingly, if you have to reload the Director's
940    configuration while \mbacula{} is running, it is advisable to restart the
941    Director at the next convenient opportunity.
942
943 \label{restore_command}
944 \item [restore]
945    \index[general]{restore}
946    The restore command allows you to select one or more Jobs (JobIds) to be
947    restored using various methods.  Once the JobIds are selected, the File
948    records for those Jobs are placed in an internal \mbacula{} directory tree,
949    and the restore enters a file selection mode that allows you to
950    interactively walk up and down the file tree selecting individual files
951    to be restored.  This mode is somewhat similar to the standard Unix {\bf
952    restore} program's interactive file selection mode.
953 \begin{lstlisting}
954 restore storage=<storage-name> client=<backup-client-name> where=<path> pool=<pool-name> fileset=<fileset-name> restoreclient=<restore-client-name> restorejob=<job-name> select current all done
955 \end{lstlisting}
956    Where {\bf current}, if specified, tells the restore command to
957    automatically select a restore to the most current backup.  If not
958    specified, you will be prompted.  The {\bf all} specification tells the
959    restore command to restore all files.  If it is not specified, you will
960    be prompted for the files to restore.  For details of the {\bf restore}
961    command, please see the \bsysxrlink{Restore}{RestoreChapter}{main}{chapter}
962    of the \mainman{}.
963
964    The client keyword initially specifies the client from which the backup
965    was made and the client to which the restore will be make.  However,
966    if the restoreclient keyword is specified, then the restore is written
967    to that client.
968
969    The restore job rarely needs to be specified, as bacula installations
970    commonly only have a single restore job configured. However, for certain
971    cases, such as a varying list of RunScript specifications, multiple
972    restore jobs may be configured. The restorejob argument allows the
973    selection of one of these jobs.
974
975 \item [run]
976    \index[general]{run}
977    This command allows you to schedule jobs  to be run immediately. The full form
978    of the command is:
979 \begin{lstlisting}
980 run job=<job-name> client=<client-name>
981   fileset=<FileSet-name>  level=<level-keyword>
982   storage=<storage-name>  where=<directory-prefix>
983   when=<universal-time-specification> spooldata=yes|no yes
984 \end{lstlisting}
985    Any information that is needed but not specified will be listed for
986    selection, and before starting the job, you will be prompted to accept,
987    reject, or modify the parameters of the job to be run, unless you have
988    specified {\bf yes}, in which case the job will be immediately sent to
989    the scheduler.
990
991    On my system, when I enter a run command, I get the following  prompt:
992
993 %%%\footnotesize
994 \begin{lstlisting}
995 A job name must be specified.
996 The defined Job resources are:
997      1: Matou
998      2: Polymatou
999      3: Rufus
1000      4: Minimatou
1001      5: Minou
1002      6: PmatouVerify
1003      7: MatouVerify
1004      8: RufusVerify
1005      9: Watchdog
1006 Select Job resource (1-9):
1007
1008 \end{lstlisting}
1009 \normalsize
1010
1011 If I then select number 5, I am prompted with:
1012
1013 %%%\footnotesize
1014 \begin{lstlisting}
1015 Run Backup job
1016 JobName:  Minou
1017 FileSet:  Minou Full Set
1018 Level:    Incremental
1019 Client:   Minou
1020 Storage:  DLTDrive
1021 Pool:     Default
1022 When:     2003-04-23 17:08:18
1023 OK to run? (yes/mod/no):
1024
1025 \end{lstlisting}
1026 \normalsize
1027
1028 If I now enter {\bf yes}, the Job will be run. If I enter {\bf mod},  I will
1029 be presented with the following prompt.
1030
1031 %%%\footnotesize
1032 \begin{lstlisting}
1033 Parameters to modify:
1034      1: Level
1035      2: Storage
1036      3: Job
1037      4: FileSet
1038      5: Client
1039      6: When
1040      7: Pool
1041 Select parameter to modify (1-7):
1042
1043 \end{lstlisting}
1044 \normalsize
1045
1046 If you wish to start a job at a later time, you can do so by setting  the When
1047 time. Use the {\bf mod} option and select {\bf When} (no. 6).  Then enter the
1048 desired start time in \texttt{YYYY-MM-DD HH:MM:SS} format.
1049
1050 The spooldata argument of the run command cannot be modified through the menu
1051 and is only accessible by setting its value on the intial command line. If
1052 no spooldata flag is set, the job, storage or schedule flag is used.
1053
1054 \item[setbandwidth]
1055   \index[general]{setbandwidth}
1056   This command is used to limit the bandwidth of a running job or a client.
1057 \begin{lstlisting}
1058 setbandwidth limit=<nb> [ jobid=<id> | client=<cli> ]
1059 \end{lstlisting}
1060 \item [setdebug]
1061    \index[general]{setdebug}
1062    \index[general]{Debugging}
1063    \index[general]{Debugging Win32}
1064    \index[general]{Windows!debugging}
1065    This command is used to set the debug level in each  daemon. The form of this
1066    command is:
1067 \begin{lstlisting}
1068 setdebug level=nn [trace=0/1 client=<client-name> | dir | director | storage=<storage-name> | all | options=0cidtTlp | tags=<tags>]
1069 \end{lstlisting}
1070    If \texttt{trace=1} is set, then tracing will be enabled, and the daemon will be
1071    placed in trace mode, which means that all debug output as set by the
1072    debug level will be directed to the file {\bf bacula.trace} in the
1073    current directory of the daemon.  Normally, tracing is needed only for
1074    Win32 clients where the debug output cannot be written to a terminal or
1075    redirected to a file.  When tracing, each debug output message is
1076    appended to the trace file.  You must explicitly delete the file when
1077    you are done.
1078
1079 \smallskip{}
1080
1081    If \texttt{options} parameter is set, the following arguments can be used
1082    to control debug functions.
1083    \begin{itemize}
1084    \item [0] clear debug flags
1085    \item [i] Turn off, ignore bwrite() errors on restore on File Daemon
1086    \item [d] Turn off decomp of BackupRead() streams on File Daemon
1087    \item [t] Turn on timestamp in traces
1088    \item [T] Turn off timestamp in traces
1089    \item [c] Truncate trace file if trace file is activated
1090    \item [l] Turn on recoding events on P() and V()
1091    \item [p] Turn on the display of the event ring when doing a bactrace
1092    \end{itemize}
1093
1094 \smallskip{}
1095
1096    It is now possible to use \textsl{class} of debug messages called \texttt{tags}
1097    to control the debug output of Bacula daemons.
1098
1099    \begin{itemize}
1100    \item [all] Display all debug messages
1101    \item [bvfs] Display BVFS debug messages
1102    \item [sql] Display SQL related debug messages
1103    \item [memory] Display memory and poolmem allocation messages
1104    \item [scheduler] Display scheduler related debug messages
1105    \end{itemize}
1106
1107    \begin{lstlisting}
1108    * setdebug level=10 tags=bvfs,sql,memory
1109    * setdebug level=10 tags=!bvfs
1110    \end{lstlisting}
1111
1112    The \texttt{tags} option is composed of a list of tags, tags are separated by
1113    ``,'' or ``+'' or ``-'' or ``!''. To disable a specific tag, use ``-'' or ``!''
1114    in front of the tag.
1115
1116 \item [setip]
1117    \index[general]{setip}
1118    Sets new client address -- if authorized.
1119
1120    A console is authorized to use the {\bf SetIP} command only if it has a
1121    Console resource definition in both the Director and the Console.  In
1122    addition, if the console name, provided on the {\bf Name =} directive,
1123    must be the same as a Client name, the user of that console is permitted
1124    to use the {\bf SetIP} command to change the Address directive in the
1125    Director's client resource to the IP address of the Console.  This
1126    permits portables or other machines using DHCP (non-fixed IP addresses)
1127    to "notify" the Director of their current IP address.
1128
1129
1130
1131 \item [show]
1132    \index[general]{show}
1133    The show command will list the Director's resource records as defined in
1134    the Director's configuration file (normally {\bf bacula-dir.conf}).
1135    This command is used mainly for debugging purposes by developers.
1136    The following keywords are accepted on the
1137    show command line: catalogs, clients, counters, devices, directors,
1138    filesets, jobs, messages, pools, schedules, storages, all, help.
1139    Please don't confuse this command
1140    with the {\bf list}, which displays the contents of the catalog.
1141
1142 \item [sqlquery]
1143    \index[general]{sqlquery}
1144    The sqlquery command puts the Console program into SQL query mode where
1145    each line you enter is concatenated to the previous line until a
1146    semicolon (;) is seen.  The semicolon terminates the command, which is
1147    then passed directly to the SQL database engine.  When the output from
1148    the SQL engine is displayed, the formation of a new SQL command begins.
1149    To terminate SQL query mode and return to the Console command prompt,
1150    you enter a period (.) in column 1.
1151
1152    Using this command, you can query the SQL catalog database directly.
1153    Note you should really know what you are doing otherwise you could
1154    damage the catalog database.  See the {\bf query} command below for
1155    simpler and safer way of entering SQL queries.
1156
1157    Depending on what database engine you are using (MySQL, PostgreSQL or
1158    SQLite), you will have somewhat different SQL commands available.  For
1159    more detailed information, please refer to the MySQL, PostgreSQL or
1160    SQLite documentation.
1161
1162 \item [status]
1163    \index[general]{status}
1164
1165    This command will display the status of all components. For the director, it
1166    will display the next jobs that are scheduled during the next 24 hours as
1167    well as the status of currently running jobs. For the Storage Daemon, you
1168    will have drive status or autochanger content. The File Daemon will give you
1169    information about current jobs like average speed or file accounting. The
1170    full form of this command is:
1171 \begin{lstlisting}
1172 status [all | dir=<dir-name> | director [days=nnn] |
1173   client=<client-name> | [slots] storage=<storage-name>]
1174 \end{lstlisting}
1175    If you do a {\bf status dir}, the console will list any currently
1176    running jobs, a summary of all jobs scheduled to be run in the next 24
1177    hours, and a listing of the last ten terminated jobs with their statuses.
1178    The scheduled jobs summary will include the Volume name to be used.  You
1179    should be aware of two things: 1. to obtain the volume name, the code
1180    goes through the same code that will be used when the job runs, but it
1181    does not do pruning nor recycling of Volumes; 2.  The Volume listed is
1182    at best a guess.  The Volume actually used may be different because of
1183    the time difference (more durations may expire when the job runs) and
1184    another job could completely fill the Volume requiring a new one.
1185
1186    In the Running Jobs listing, you may find the following types of
1187    information:
1188
1189
1190 %%%\footnotesize
1191 \begin{lstlisting}
1192 2507 Catalog MatouVerify.2004-03-13_05.05.02 is waiting execution
1193 5349 Full    CatalogBackup.2004-03-13_01.10.00 is waiting for higher
1194              priority jobs to finish
1195 5348 Differe Minou.2004-03-13_01.05.09 is waiting on max Storage jobs
1196 5343 Full    Rufus.2004-03-13_01.05.04 is running
1197 \end{lstlisting}
1198 \normalsize
1199
1200    Looking at the above listing from bottom to top, obviously JobId 5343
1201    (Rufus) is running.  JobId 5348 (Minou) is waiting for JobId 5343 to
1202    finish because it is using the Storage resource, hence the "waiting on
1203    max Storage jobs".  JobId 5349 has a lower priority than all the other
1204    jobs so it is waiting for higher priority jobs to finish, and finally,
1205    JobId 2507 (MatouVerify) is waiting because only one job can run at a
1206    time, hence it is simply "waiting execution"
1207
1208    If you do a {\bf status dir}, it will by default list the first
1209    occurrence of all jobs that are scheduled today and tomorrow.  If you
1210    wish to see the jobs that are scheduled in the next three days (e.g.  on
1211    Friday you want to see the first occurrence of what tapes are scheduled
1212    to be used on Friday, the weekend, and Monday), you can add the {\bf
1213    days=3} option.  Note, a {\bf days=0} shows the first occurrence of jobs
1214    scheduled today only.  If you have multiple run statements, the first
1215    occurrence of each run statement for the job will be displayed for the
1216    period specified.
1217
1218    If your job seems to be blocked, you can get a general idea of the
1219    problem by doing a {\bf status dir}, but you can most often get a
1220    much more specific indication of the problem by doing a
1221    {\bf \texttt{status storage=xxx}}.  For example, on an idle test system, when
1222    I do {\bf \texttt{status storage=File}}, I get:
1223 %%%\footnotesize
1224 \begin{lstlisting}
1225 status storage=File
1226 Connecting to Storage daemon File at 192.168.68.112:8103
1227
1228 rufus-sd Version: 1.39.6 (24 March 2006) i686-pc-linux-gnu redhat (Stentz)
1229 Daemon started 26-Mar-06 11:06, 0 Jobs run since started.
1230
1231 Running Jobs:
1232 No Jobs running.
1233 ====
1234
1235 Jobs waiting to reserve a drive:
1236 ====
1237
1238 Terminated Jobs:
1239  JobId  Level   Files          Bytes Status   Finished        Name
1240 ======================================================================
1241     59  Full        234      4,417,599 OK       15-Jan-06 11:54 kernsave
1242 ====
1243
1244 Device status:
1245 Autochanger "DDS-4-changer" with devices:
1246    "DDS-4" (/dev/nst0)
1247 Device "DDS-4" (/dev/nst0) is mounted with Volume="TestVolume002"
1248 Pool="*unknown*"
1249     Slot 2 is loaded in drive 0.
1250     Total Bytes Read=0 Blocks Read=0 Bytes/block=0
1251     Positioned at File=0 Block=0
1252
1253 Device "DVD-Writer" (/dev/hdc) is not open.
1254 Device "File" (/tmp) is not open.
1255 ====
1256
1257 In Use Volume status:
1258 ====
1259 \end{lstlisting}
1260 \normalsize
1261
1262 Now, what this tells me is that no jobs are running and that none of
1263 the devices are in use.  Now, if I {\bf unmount} the autochanger, which
1264 will not be used in this example, and then start a Job that uses the
1265 File device, the job will block.  When I re-issue the status storage
1266 command, I get for the Device status:
1267
1268 %%%\footnotesize
1269 \begin{lstlisting}
1270 status storage=File
1271 ...
1272 Device status:
1273 Autochanger "DDS-4-changer" with devices:
1274    "DDS-4" (/dev/nst0)
1275 Device "DDS-4" (/dev/nst0) is not open.
1276     Device is BLOCKED. User unmounted.
1277     Drive 0 is not loaded.
1278
1279 Device "DVD-Writer" (/dev/hdc) is not open.
1280 Device "File" (/tmp) is not open.
1281     Device is BLOCKED waiting for media.
1282 ====
1283 ...
1284 \end{lstlisting}
1285 \normalsize
1286
1287 Now, here it should be clear that if a job were running that wanted
1288 to use the Autochanger (with two devices), it would block because
1289 the user unmounted the device. The real problem for the Job I started
1290 using the "File" device is that the device is blocked waiting for
1291 media -- that is \mbacula{} needs you to label a Volume.
1292
1293 \item [time]
1294    \index[general]{time}
1295    Prints the current time.
1296
1297 \item [trace]
1298    \index[general]{trace}
1299    Turn on/off trace to file.
1300
1301 \item [umount]
1302    \index[general]{umount|see{unmount}}
1303    For old-time Unix guys.  See the unmount command for full details.
1304
1305 \item [unmount]
1306    \index[general]{unmount}
1307    This command causes the indicated \mbacula{} Storage  daemon to unmount the
1308    specified device. The forms of the command  are the same as the mount command:
1309 %%%\footnotesize
1310 \begin{lstlisting}
1311 unmount storage=<storage-name> [ drive=<num> ]
1312
1313 unmount [ jobid=<id> | job=<job-name> ]
1314 \end{lstlisting}
1315 \normalsize
1316
1317    Once you unmount a storage device, \mbacula{} will no longer be able to use
1318    it until you issue a mount command for that device. If \mbacula{} needs to
1319    access that device, it will block and issue mount requests periodically
1320    to the operator.
1321
1322    If the device you are unmounting is an autochanger, it will unload
1323    the drive you have specified on the command line. If no drive is
1324    specified, it will assume drive 1.
1325
1326 \label{UpdateCommand}
1327 \item [update]
1328    \index[general]{update}
1329    This command will update the catalog for either a specific Pool record, a Volume
1330    record, or the Slots in an  autochanger with barcode capability. In the case
1331    of updating a  Pool record, the new information will be automatically taken
1332    from  the corresponding Director's configuration resource record. It  can be
1333    used to increase the maximum number of volumes permitted or  to set a maximum
1334    number of volumes. The following main  keywords may be specified:
1335 %%%\footnotesize
1336 \begin{lstlisting}
1337    media, volume, pool, slots, stats
1338 \end{lstlisting}
1339 \normalsize
1340
1341 In the case of updating a  Volume, you will be prompted for which value you
1342 wish to change.  The following Volume parameters may be changed:
1343
1344 %%%\footnotesize
1345 \begin{lstlisting}
1346
1347    Volume Status
1348    Volume Retention Period
1349    Volume Use Duration
1350    Maximum Volume Jobs
1351    Maximum Volume Files
1352    Maximum Volume Bytes
1353    Recycle Flag
1354    Recycle Pool
1355    Slot
1356    InChanger Flag
1357    Pool
1358    Volume Files
1359    Volume from Pool
1360    All Volumes from Pool
1361    All Volumes from all Pools
1362
1363 \end{lstlisting}
1364 \normalsize
1365
1366    For slots {\bf update slots}, \mbacula{} will obtain a list of slots and
1367    their barcodes from the Storage daemon, and for each barcode found, it
1368    will automatically update the slot in the catalog Media record to
1369    correspond to the new value.  This is very useful if you have moved
1370    cassettes in the magazine, or if you have removed the magazine and
1371    inserted a different one.  As the slot of each Volume is updated, the
1372    InChanger flag for that Volume will also be set, and any other Volumes
1373    in the Pool that were last mounted on the same Storage device
1374    will have their InChanger flag turned off.  This permits
1375    \mbacula{} to know what magazine (tape holder) is currently in the
1376    autochanger.
1377
1378    If you do not have barcodes, you can accomplish the same thing in
1379    version 1.33 and later by using the {\bf update slots scan} command.
1380    The {\bf scan} keyword tells \mbacula{} to physically mount each tape and to
1381    read its VolumeName.
1382
1383    For Pool {\bf update pool}, \mbacula{} will move the Volume record from its
1384    existing pool to the pool specified.
1385
1386    For {\bf Volume from Pool}, {\bf All Volumes from Pool} and {\bf All Volumes
1387      from all Pools}, the following values are updated from the Pool record:
1388    Recycle, RecyclePool, VolRetention, VolUseDuration, MaxVolJobs, MaxVolFiles,
1389    and MaxVolBytes.  (RecyclePool feature is available with \mbacula{} 2.1.4 or
1390    higher.)
1391
1392    The full form of the update command with all command line arguments is:
1393
1394 %%%\footnotesize
1395 \begin{lstlisting}
1396        update volume=xxx pool=yyy slots volstatus=xxx VolRetention=ddd
1397          VolUse=ddd MaxVolJobs=nnn MaxVolBytes=nnn Recycle=yes|no
1398          slot=nnn enabled=n recyclepool=zzz
1399
1400 \end{lstlisting}
1401 \normalsize
1402
1403 \item [use]
1404    \index[general]{use}
1405    This command allows you to specify which Catalog  database to use. Normally,
1406 you will be using only one database so  this will be done automatically. In
1407 the case that you are using  more than one database, you can use this command
1408 to switch from  one to another.
1409
1410 %%%\footnotesize
1411 \begin{lstlisting}
1412        use [catalog=name-of-catalog]
1413 \end{lstlisting}
1414 \normalsize
1415
1416
1417 \item [var]
1418    \label{var}
1419    \index[general]{var name}
1420    This command takes a string or quoted string and  does variable expansion on
1421    it the same way variable expansion  is done on the {\bf LabelFormat} string.
1422    Thus, for the  most part, you can test your LabelFormat strings. The
1423    difference  between the {\bf var} command and the actual LabelFormat process
1424    is that during the var command, no job is running so "dummy"  values are
1425    used in place of Job specific variables. Generally,  however, you will get a
1426    good idea of what is going to happen  in the real case.
1427
1428 \item [version]
1429    \index[general]{version}
1430    The command prints the Director's version.
1431
1432 \item [wait]
1433    \index[general]{wait}
1434    The wait command causes the Director to pause  until there are no jobs
1435    running. This command is useful in  a batch situation such as regression
1436    testing where you  wish to start a job and wait until that job completes
1437    before continuing. This command now has the following options:
1438 %%%\footnotesize
1439 \begin{lstlisting}
1440    wait [jobid=nn] [jobuid=unique id] [job=job name]
1441 \end{lstlisting}
1442 \normalsize
1443    If specified with a specific JobId, ... the wait command will wait
1444    for that particular job to terminate before continuing.
1445
1446 \end{description}
1447
1448 \label{dotcommands}
1449 \section{Special dot Commands}
1450 \index[general]{Commands!Special dot (.)}
1451 \index[general]{Special dot (.) Commands}
1452 \index[general]{. commands}
1453
1454 There is a list of commands that are prefixed with a period (.). These
1455 commands are intended to be used either by batch programs or graphical user
1456 interface front-ends. They are not normally used by interactive users. Once
1457 GUI development begins, this list will be considerably expanded. The following
1458 is the list of dot commands:
1459
1460 %%%\footnotesize
1461 \begin{lstlisting}
1462 .backups job=xxx      list backups for specified job
1463 .clients              list all client names
1464 .defaults client=xxx fileset=yyy  list defaults for specified client
1465 .die                  cause the Director to segment fault (for debugging)
1466 .dir                  when in tree mode prints the equivalent to the dir command,
1467                         but with fields separated by commas rather than spaces.
1468 .exit                 quit
1469 .filesets             list all fileset names
1470 .help                 help command output
1471 .jobs                 list all job names
1472 .levels               list all levels
1473 .messages             get quick messages
1474 .msgs                 return any queued messages
1475 .pools                list all pool names
1476 .quit                 quit
1477 .status               get status output
1478 .storage              return storage resource names
1479 .types                list job types
1480 \end{lstlisting}
1481 \normalsize
1482
1483 \label{atcommands}
1484
1485 \section{Special At (@) Commands}
1486 \index[general]{Commands!Special At (\symbol{64})}
1487 \index[general]{Special At (\symbol{64}) Commands}
1488 \index[general]{\symbol{64} commands}
1489
1490 Normally, all commands entered to the Console program are immediately
1491 forwarded to the Director, which may be on another machine, to be executed.
1492 However, there is a small list of {\bf at} commands, all beginning with an at
1493 character (@), that will not be sent to the Director, but rather interpreted
1494 by the Console program directly. Note, these commands are implemented only in
1495 the tty console program and not in the Bat Console. These commands are:
1496
1497 \begin{description}
1498
1499 \item [@input \lt{}filename\gt{}]
1500    \index[general]{\symbol{64}input \lt{}filename\gt{}}
1501    Read and execute the commands  contained in the file specified.
1502
1503 \item [@output \lt{}filename\gt{} w/a]
1504    \index[general]{\symbol{64}output \lt{}filename\gt{} w/a}
1505    Send all following output to the  filename specified either overwriting the
1506 file (w) or appending to  the file (a). To redirect the output to the
1507 terminal, simply enter  {\bf @output} without a filename specification.
1508 WARNING: be careful  not to overwrite a valid file. A typical example during a
1509 regression  test might be:
1510
1511 %%%\footnotesize
1512 \begin{lstlisting}
1513     @output /dev/null
1514     commands ...
1515     @output
1516
1517 \end{lstlisting}
1518 \normalsize
1519
1520 \item [@tee \lt{}filename\gt{} w/a]
1521    \index[general]{\symbol{64}tee \lt{}filename\gt{} w/a}
1522    Send all subsequent output to  both the specified file and the terminal. It is
1523    turned off by  specifying {\bf @tee} or {\bf @output} without a filename.
1524
1525 \item [@sleep \lt{}seconds\gt{}]
1526    \index[general]{\symbol{64}sleep \lt{}seconds\gt{}}
1527    Sleep the specified number of seconds.
1528
1529 \item [@time]
1530    \index[general]{\symbol{64}time}
1531    Print the current time and date.
1532
1533 \item [@version]
1534    \index[general]{\symbol{64}version}
1535    Print the console's version.
1536
1537 \item [@quit]
1538    \index[general]{\symbol{64}quit}
1539    quit
1540
1541 \item [@exit]
1542    \index[general]{\symbol{64}exit}
1543    quite
1544
1545 \item [@\# anything]
1546    \index[general]{anything}
1547    Comment
1548
1549 \item [@help]
1550    \index[general]{\symbol{64}help}
1551    Get the list of every special @ commands.
1552
1553 \item [@separator \lt{}char\gt{}]
1554 \index[general]{\symbol{64}separator}
1555   When using bconsole with readline, you can set the command separator to one
1556   of those characters to write commands who require multiple input on one line,
1557   or to put multiple commands on a single line.
1558 \begin{lstlisting}
1559   !$%&'()*+,-/:;<>?[]^`{|}~
1560 \end{lstlisting}
1561
1562   Note, if you use a semicolon (;) as a separator character, which is
1563   common, you will not be able to use the {\bf sql} command, which
1564   requires each command to be terminated by a semicolon.
1565
1566 \end{description}
1567
1568 \label{scripting}
1569 \section{Running the Console from a Shell Script}
1570 \index[general]{Script!Running the Console Program from a Shell}
1571 \index[general]{Running the Console Program from a Shell Script}
1572
1573 You can automate many Console tasks by running the console program from a
1574 shell script. For example, if you have created a file containing the following
1575 commands:
1576
1577 %%%\footnotesize
1578 \begin{lstlisting}
1579  ./bconsole -c ./bconsole.conf <<END_OF_DATA
1580  unmount storage=DDS-4
1581  quit
1582  END_OF_DATA
1583 \end{lstlisting}
1584 \normalsize
1585
1586 when that file is executed, it will unmount the current DDS-4 storage device.
1587 You might want to run this command during a Job by using the {\bf
1588 RunBeforeJob} or {\bf RunAfterJob} records.
1589
1590 It is also possible to run the Console program from file input where the file
1591 contains the commands as follows:
1592
1593 %%%\footnotesize
1594 \begin{lstlisting}
1595 ./bconsole -c ./bconsole.conf <filename
1596 \end{lstlisting}
1597 \normalsize
1598
1599 where the file named {\bf filename} contains any set of console commands.
1600
1601 As a real example, the following script is part of the \mbacula{} regression
1602 tests. It labels a volume (a disk volume), runs a backup, then does a restore
1603 of the files saved.
1604
1605 %%%\footnotesize
1606 \begin{lstlisting}
1607 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
1608 @output /dev/null
1609 messages
1610 @output /tmp/log1.out
1611 label volume=TestVolume001
1612 run job=Client1 yes
1613 wait
1614 messages
1615 @#
1616 @# now do a restore
1617 @#
1618 @output /tmp/log2.out
1619 restore current all
1620 yes
1621 wait
1622 messages
1623 @output
1624 quit
1625 END_OF_DATA
1626 \end{lstlisting}
1627 \normalsize
1628
1629 The output from the backup is directed to /tmp/log1.out and the output from
1630 the restore is directed to /tmp/log2.out. To ensure that the backup and
1631 restore ran correctly, the output files are checked with:
1632
1633 %%%\footnotesize
1634 \begin{lstlisting}
1635 grep "^ *Termination: *Backup OK" /tmp/log1.out
1636 backupstat=$?
1637 grep "^ *Termination: *Restore OK" /tmp/log2.out
1638 restorestat=$?
1639 \end{lstlisting}
1640 \normalsize
1641
1642 \section{Adding Volumes to a Pool}
1643 \index[general]{Adding Volumes to a Pool}
1644 \index[general]{Pool!Adding Volumes to a}
1645
1646 If you have used the {\bf label} command to label a Volume, it will be
1647 automatically added to the Pool, and you will not need to add any media to the
1648 pool.
1649
1650 Alternatively, you may choose to add a number of Volumes to the pool without
1651 labeling them. At a later time when the Volume is requested by {\bf \mbacula{}}
1652 you will need to label it.
1653
1654 Before adding a volume, you must know the following information:
1655
1656 \begin{enumerate}
1657 \item The name of the Pool (normally "Default")
1658 \item The Media Type as specified in the Storage Resource  in the Director's
1659    configuration file (e.g. "DLT8000")
1660 \item The number and names of the Volumes you wish to create.
1661 \end{enumerate}
1662
1663 For example, to add media to a Pool, you would issue the following commands to
1664 the console program:
1665
1666 %%%\footnotesize
1667 \begin{lstlisting}
1668 *add
1669 Enter name of Pool to add Volumes to: Default
1670 Enter the Media Type: DLT8000
1671 Enter number of Media volumes to create. Max=1000: 10
1672 Enter base volume name: Save
1673 Enter the starting number: 1
1674 10 Volumes created in pool Default
1675 *
1676 \end{lstlisting}
1677 \normalsize
1678
1679 To see what you have added, enter:
1680
1681 %%%%\footnotesize
1682 \begin{lstlisting}
1683 *list media pool=Default
1684 +-------+----------+---------+---------+-------+------------------+
1685 | MedId | VolumeNa | MediaTyp| VolStat | Bytes | LastWritten      |
1686 +-------+----------+---------+---------+-------+------------------+
1687 |    11 | Save0001 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1688 |    12 | Save0002 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1689 |    13 | Save0003 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1690 |    14 | Save0004 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1691 |    15 | Save0005 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1692 |    16 | Save0006 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1693 |    17 | Save0007 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1694 |    18 | Save0008 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1695 |    19 | Save0009 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1696 |    20 | Save0010 | DLT8000 | Append  |     0 | 0000-00-00 00:00 |
1697 +-------+----------+---------+---------+-------+------------------+
1698 *
1699 \end{lstlisting}
1700 %\normalsize
1701
1702 Notice that the console program automatically appended a number to the base
1703 Volume name that you specify (Save in this case). If you don't want it to
1704 append a number, you can simply answer 0 (zero) to the question "Enter number
1705 of Media volumes to create. Max=1000:", and in this case, it will create a
1706 single Volume with the exact name you specify.