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