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