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