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