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