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