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