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