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