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