4 \chapter{Bacula Console}
5 \label{_ConsoleChapter}
6 \index[general]{Console!Bacula}
7 \index[general]{Bacula Console}
8 \index[console]{Console!Bacula}
9 \index[console]{Bacula Console}
11 The {\bf Bacula Console} (sometimes called the User Agent) is a program that
12 allows the user or the System Administrator, to interact with the Bacula
13 Director daemon while the daemon is running.
15 The current Bacula Console comes in two versions: a shell interface (TTY
16 style), and a GNOME GUI interface. Both permit the administrator or authorized
17 users to interact with Bacula. You can determine the status of a particular
18 job, examine the contents of the Catalog as well as perform certain tape
19 manipulations with the Console program.
21 In addition, there is a bwx-console built with wxWidgets that allows a graphic
22 restore of files. As of version 1.34.1 it is in an early stage of development,
23 but it already is quite useful. Unfortunately, it has not been enhanced for
26 Since the Console program interacts with the Director through the network, your
27 Console and Director programs do not necessarily need to run on the same
30 In fact, a certain minimal knowledge of the Console program is needed in order
31 for Bacula to be able to write on more than one tape, because when Bacula
32 requests a new tape, it waits until the user, via the Console program,
33 indicates that the new tape is mounted.
35 \section{Console Configuration}
36 \index[general]{Console Configuration}
37 \index[general]{Configuration!Console}
38 \index[console]{Console Configuration}
39 \index[console]{Configuration!Console}
41 When the Console starts, it reads a standard Bacula configuration file named
42 {\bf bconsole.conf} or {\bf bgnome-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}{ConsoleConfChapter} Chapter of
50 \section{Running the Console Program}
51 \index[general]{Running the Console Program}
52 \index[general]{Program!Running the Console}
53 \index[console]{Running the Console Program}
54 \index[console]{Program!Running the Console}
56 The console program can be run with the following options:
59 Usage: bconsole [-s] [-c config_file] [-d debug_level]
60 -c <file> set configuration file to file
61 -dnn set debug level to nn
64 -t test - read configuration and exit
65 -? print this message.
70 After launching the Console program (bconsole), it will prompt you for the
71 next command with an asterisk (*). (Note, in the GNOME version, the prompt is
72 not present; you simply enter the commands you want in the command text box at
73 the bottom of the screen.) Generally, for all commands, you can simply enter
74 the command name and the Console program will prompt you for the necessary
75 arguments. Alternatively, in most cases, you may enter the command followed by
76 arguments. The general format is:
80 <command> <keyword1>[=<argument1>] <keyword2>[=<argument2>] ...
84 where {\bf command} is one of the commands listed below; {\bf keyword} is one
85 of the keywords listed below (usually followed by an argument); and {\bf
86 argument} is the value. The command may be abbreviated to the shortest unique
87 form. If two commands have the same starting letters, the one that will be
88 selected is the one that appears first in the {\bf help} listing. If you want
89 the second command, simply spell out the full command. None of the keywords
90 following the command may be abbreviated.
100 will list all files saved for JobId 23. Or:
108 will display all the Pool resource records.
110 The maximum command line length is limited to 511 characters, so if you
111 are scripting the console, you may need to take some care to limit the
114 \section{Stopping the Console Program}
115 \index[general]{Program!Stopping the Console}
116 \index[general]{Stopping the Console Program}
117 \index[console]{Program!Stopping the Console}
118 \index[console]{Stopping the Console Program}
120 Normally, you simply enter {\bf quit} or {\bf exit} and the Console program
121 will terminate. However, it waits until the Director acknowledges the command.
122 If the Director is already doing a lengthy command (e.g. prune), it may take
123 some time. If you want to immediately terminate the Console program, enter the
126 There is currently no way to interrupt a Console command once issued (i.e.
127 Ctrl-C does not work). However, if you are at a prompt that is asking you to
128 select one of several possibilities and you would like to abort the command,
129 you can enter a period ({\bf .}), and in most cases, you will either be
130 returned to the main command prompt or if appropriate the previous prompt (in
131 the case of nested prompts). In a few places such as where it is asking for a
132 Volume name, the period will be taken to be the Volume name. In that case, you
133 will most likely be able to cancel at the next prompt.
136 \section{Alphabetic List of Console Keywords}
137 \index[general]{Keywords!Alphabetic List of Console}
138 \index[general]{Alphabetic List of Console Keywords}
139 \index[console]{Keywords!Alphabetic List of Console}
140 \index[console]{Alphabetic List of Console Keywords}
141 Unless otherwise specified, each of the following keywords
142 takes an argument, which is specified after the keyword following
143 an equal sign. For example:
149 Please note, this list is incomplete as it is currently in
150 the process of being created and is not currently totally in
156 Permitted on the python command, and causes the Python
157 interpreter to be restarted. Takes no argument.
159 Permitted on the status and show commands to specify all components or
160 resources respectively.
162 Permitted on the update command to specify that all Volumes in the
163 pool (specified on the command line) should be updated.
165 Permitted on the update command to specify that all Volumes in all
166 pools should be updated.
168 Used in the restore command.
170 Used in the restore command.
172 Allowed in the use command to specify the catalog name
175 Used in the show command. Takes no arguments.
178 Used in the show, list, and llist commands. Takes no arguments.
180 Used in the show command. Takes no arguments.
182 Used in the restore command. Takes no argument.
184 Used to define the number of days the "list nextvol" command
185 should consider when looking for jobs to be run. The days keyword
186 can also be used on the "status dir" command so that it will display
187 jobs scheduled for the number of days you want.
189 Used in the show command. Takes no arguments.
190 \item [dir | director]
192 Used in the show command. Takes no arguments.
194 Used in the restore command. Its argument specifies the directory
197 This keyword can appear on the {\bf update volume} as well
198 as the {\bf update slots} commands, and can
199 allows one of the following arguments: yes, true, no, false, archived,
200 0, 1, 2. Where 0 corresponds to no or false, 1 corresponds to yes or true, and
201 2 corresponds to archived. Archived volumes will not be used, nor will
202 the Media record in the catalog be pruned. Volumes that are not enabled,
203 will not be used for backup or restore.
205 Used in the restore command. Takes no argument.
207 Used in the restore command.
209 Used in the list and llist commands. Takes no arguments.
212 Used in the show command. Takes no arguments.
214 Used in the show command. Takes no arguments.
216 Used in the show, list and llist commands. Takes no arguments.
218 Used in the list and llist commands. Takes no arguments.
220 Used in the list and llist commands. Takes no arguments.
222 The JobId is the numeric jobid that is printed in the Job
223 Report output. It is the index of the database record for the
224 given job. While it is unique for all the existing Job records
225 in the catalog database, the same JobId can be reused once a
226 Job is removed from the catalog. Probably you will refer
227 specific Jobs that ran using their numeric JobId.
228 \item [job | jobname]
229 The Job or Jobname keyword refers to the name you specified
230 in the Job resource, and hence it refers to any number of
231 Jobs that ran. It is typically useful if you want to list
232 all jobs of a particular name.
235 Permitted on the estimate command. Takes no argument.
238 Used in the show command. Takes no arguments.
240 Used in the list and llist commands. Takes no arguments.
241 \item [nextvol | nextvolume]
242 Used in the list and llist commands. Takes no arguments.
249 Used in the show, list, and llist commands. Takes no arguments.
251 Used in the restore command. Takes no argument.
253 Used in the show command. Takes no arguments.
255 Used in the show command. Takes no arguments.
256 \item [sd | store | storage]
258 The ujobid is a unique job identification that is printed
259 in the Job Report output. At the current time, it consists
260 of the Job name (from the Name directive for the job) appended
261 with the date and time the job was run. This keyword is useful
262 if you want to completely identify the Job instance run.
265 Used in the list and llist commands. Takes no arguments.
267 Used in the restore command.
269 Used in the restore command. Takes no argument.
273 \section{Alphabetic List of Console Commands}
274 \index[general]{Commands!Alphabetic List of Console}
275 \index[general]{Alphabetic List of Console Commands}
276 \index[console]{Commands!Alphabetic List of Console}
277 \index[console]{Alphabetic List of Console Commands}
279 The following commands are currently implemented:
282 \item [{add [pool=\lt{}pool-name\gt{} storage=\lt{}storage\gt{}
283 jobid=\lt{}JobId\gt{}]} ]
285 This command is used to add Volumes to an existing Pool. That is,
286 it creates the Volume name in the catalog and inserts into the Pool
287 in the catalog, but does not attempt to access the physical Volume.
289 added, Bacula expects that Volume to exist and to be labeled.
290 This command is not normally used since Bacula will
291 automatically do the equivalent when Volumes are labeled. However,
292 there may be times when you have removed a Volume from the catalog
293 and want to later add it back.
295 Normally, the {\bf label} command is used rather than this command
296 because the {\bf label} command labels the physical media (tape, disk,
297 DVD, ...) and does the equivalent of the {\bf add} command. The {\bf
298 add} command affects only the Catalog and not the physical media (data
299 on Volumes). The physical media must exist and be labeled before use
300 (usually with the {\bf label} command). This command can, however, be
301 useful if you wish to add a number of Volumes to the Pool that will be
302 physically labeled at a later time. It can also be useful if you are
303 importing a tape from another site. Please see the {\bf label} command
304 below for the list of legal characters in a Volume name.
306 \item [autodisplay on/off]
307 \index[console]{autodisplay on/off}
308 This command accepts {\bf on} or {\bf off} as an argument, and turns
309 auto-display of messages on or off respectively. The default for the
310 console program is {\bf off}, which means that you will be notified when
311 there are console messages pending, but they will not automatically be
312 displayed. The default for the bgnome-console program is {\bf on}, which
313 means that messages will be displayed when they are received (usually
314 within five seconds of them being generated).
316 When autodisplay is turned off, you must explicitly retrieve the
317 messages with the {\bf messages} command. When autodisplay is turned
318 on, the messages will be displayed on the console as they are received.
320 \item [automount on/off]
321 \index[console]{automount on/off}
322 This command accepts {\bf on} or {\bf off} as the argument, and turns
323 auto-mounting of the Volume after a {\bf label} command on or off
324 respectively. The default is {\bf on}. If {\bf automount} is turned
325 off, you must explicitly {\bf mount} tape Volumes after a label command to
328 \item [{cancel [jobid=\lt{}number\gt{} job=\lt{}job-name\gt{} ujobid=\lt{}unique-jobid\gt{}]}]
329 \index[console]{cancel jobid}
330 This command is used to cancel a job and accepts {\bf jobid=nnn} or {\bf
331 job=xxx} as an argument where nnn is replaced by the JobId and xxx is
332 replaced by the job name. If you do not specify a keyword, the Console
333 program will prompt you with the names of all the active jobs allowing
336 Once a Job is marked to be canceled, it may take a bit of time
337 (generally within a minute) before it actually terminates, depending on
338 what operations it is doing.
340 \item [{create [pool=\lt{}pool-name\gt{}]}]
341 \index[console]{create pool}
342 This command is not normally used as the Pool records are automatically
343 created by the Director when it starts based on what it finds in
344 the conf file. If needed, this command can be
345 to create a Pool record in the database using the
346 Pool resource record defined in the Director's configuration file. So
347 in a sense, this command simply transfers the information from the Pool
348 resource in the configuration file into the Catalog. Normally this
349 command is done automatically for you when the Director starts providing
350 the Pool is referenced within a Job resource. If you use this command
351 on an existing Pool, it will automatically update the Catalog to have
352 the same information as the Pool resource. After creating a Pool, you
353 will most likely use the {\bf label} command to label one or more
354 volumes and add their names to the Media database.
356 When starting a Job, if Bacula determines that there is no Pool record
357 in the database, but there is a Pool resource of the appropriate name,
358 it will create it for you. If you want the Pool record to appear in the
359 database immediately, simply use this command to force it to be created.
361 \item [{delete [volume=\lt{}vol-name\gt{} pool=\lt{}pool-name\gt{} job
362 jobid=\lt{}id\gt{}]}]
363 \index[console]{delete}
364 The delete command is used to delete a Volume, Pool or Job record from
365 the Catalog as well as all associated catalog Volume records that were
366 created. This command operates only on the Catalog database and has no
367 effect on the actual data written to a Volume. This command can be
368 dangerous and we strongly recommend that you do not use it unless you
369 know what you are doing.
371 If the keyword {\bf Volume} appears on the command line, the named
372 Volume will be deleted from the catalog, if the keyword {\bf Pool}
373 appears on the command line, a Pool will be deleted, and if the keyword
374 {\bf Job} appears on the command line, a Job and all its associated
375 records (File and JobMedia) will be deleted from the catalog. The full
376 form of this command is:
379 delete pool=<pool-name>
385 delete volume=>volume-name> pool=>pool-name> or
389 delete JobId=>job-id> JobId=>job-id2> ... or
393 delete Job JobId=n,m,o-r,t ...
396 The first form deletes a Pool record from the catalog database. The
397 second form deletes a Volume record from the specified pool in the
398 catalog database. The third form deletes the specified Job record from
399 the catalog database. The last form deletes JobId records for JobIds
400 n, m, o, p, q, r, and t. Where each one of the n,m,... is, of course, a
401 number. That is a "delete jobid" accepts lists and ranges of
404 \item [disable job\lt{}job-name\gt{}]
405 \index[console]{enable}
406 This command permits you to disable a Job for automatic scheduling.
407 The job may have been previously enabled with the Job resource
408 {\bf Enabled} directive or using the console {\bf enable} command.
409 The next time the Director is restarted or the conf file is reloaded,
410 the Enable/Disable state will be set to the value in the Job resource
411 (default enabled) as defined in the bacula-dir.conf file.
413 \item [enable job\lt{}job-name\gt{}]
414 \index[console]{enable}
415 This command permits you to enable a Job for automatic scheduling.
416 The job may have been previously disabled with the Job resource
417 {\bf Enabled} directive or using the console {\bf disable} command.
418 The next time the Director is restarted or the conf file is reloaded,
419 the Enable/Disable state will be set to the value in the Job resource
420 (default enabled) as defined in the bacula-dir.conf file.
424 \index[console]{estimate}
425 Using this command, you can get an idea how many files will be backed
426 up, or if you are unsure about your Include statements in your FileSet,
427 you can test them without doing an actual backup. The default is to
428 assume a Full backup. However, you can override this by specifying a
429 {\bf level=Incremental} or {\bf level=Differential} on the command line.
430 A Job name must be specified or you will be prompted for one, and
431 optionally a Client and FileSet may be specified on the command line.
432 It then contacts the client which computes the number of files and bytes
433 that would be backed up. Please note that this is an estimate
434 calculated from the number of blocks in the file rather than by reading
435 the actual bytes. As such, the estimated backup size will generally be
436 larger than an actual backup.
438 Optionally you may specify the keyword {\bf listing} in which case, all the
439 files to be backed up will be listed. Note, it could take quite some time to
440 display them if the backup is large. The full form is:
444 estimate job=<job-name> listing client=<client-name>
445 fileset=<fileset-name> level=<level-name>
448 Specification of the {\bf job} is sufficient, but you can also override
449 the client, fileset and/or level by specifying them on the estimate
453 As an example, you might do:
458 estimate job=NightlySave listing level=Incremental
463 which will do a full listing of all files to be backed up for the Job {\bf
464 NightlySave} during an Incremental save and put it in the file {\bf
465 /tmp/listing}. Note, the byte estimate provided by this command is
466 based on the file size contained in the directory item. This can give
467 wildly incorrect estimates of the actual storage used if there are
468 sparse files on your systems. Sparse files are often found on 64 bit
469 systems for certain system files. The size that is returned is the size
470 Bacula will backup if the sparse option is not specified in the FileSet.
471 There is currently no way to get an estimate of the real file size that
472 would be found should the sparse option be enabled.
476 \index[console]{help}
477 This command displays the list of commands available.
480 \index[console]{label}
481 \index[console]{relabel}
482 \index[general]{label}
483 \index[general]{relabel}
484 This command is used to label physical volumes. The full form of this command
488 label storage=>storage-name> volume=>volume-name>
492 If you leave out any part, you will be prompted for it. The media type
493 is automatically taken from the Storage resource definition that you
494 supply. Once the necessary information is obtained, the Console program
495 contacts the specified Storage daemon and requests that the Volume be
496 labeled. If the Volume labeling is successful, the Console program will
497 create a Volume record in the appropriate Pool.
499 The Volume name is restricted to letters, numbers, and the special
500 characters hyphen ({\bf -}), underscore ({\bf \_}), colon ({\bf :}), and
501 period ({\bf .}). All other characters including a space are invalid.
502 This restriction is to ensure good readability of Volume names to reduce
505 Please note, when labeling a blank tape, Bacula will get {\bf read I/O
506 error} when it attempts to ensure that the tape is not already labeled. If
507 you wish to avoid getting these messages, please write an EOF mark on
508 your tape before attempting to label it:
518 The label command can fail for a number of reasons:
521 \item The Volume name you specify is already in the Volume database.
523 \item The Storage daemon has a tape or other Volume already mounted on the
524 device, in which case you must {\bf unmount} the device, insert a blank
525 tape, then do the {\bf label} command.
527 \item The Volume in the device is already a Bacula labeled Volume. (Bacula will
528 never relabel a Bacula labeled Volume unless it is recycled and you use the
529 {\bf relabel} command).
531 \item There is no Volume in the drive.
534 There are two ways to relabel a volume that already has a Bacula label. The
535 brute force method is to write an end of file mark on the tape using the
536 system {\bf mt} program, something like the following:
540 mt -f /dev/st0 rewind
545 For a disk volume, you would manually delete the Volume.
547 Then you use the {\bf label} command to add a new label. However, this could
548 leave traces of the old volume in the catalog.
550 The preferable method to relabel a Volume is to first {\bf purge} the volume,
551 either automatically, or explicitly with the {\bf purge} command, then use
552 the {\bf relabel} command described below.
554 If your autochanger has barcode labels, you can label all the Volumes in
555 your autochanger one after another by using the {\bf label barcodes}
556 command. For each tape in the changer containing a barcode, Bacula will
557 mount the tape and then label it with the same name as the barcode. An
558 appropriate Media record will also be created in the catalog. Any barcode
559 that begins with the same characters as specified on the
560 "CleaningPrefix=xxx" directive in the Director's Pool resource, will be
561 treated as a cleaning tape, and will not be labeled. However, an entry for
562 the cleaning tape will be created in the catalog. For example with:
568 Cleaning Prefix = "CLN"
574 Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
575 and will not be mounted. Note, the full form of the command is:
579 update storage=xxx pool=yyy slots=1-5,10 barcodes
584 \index[console]{list}
585 The list command lists the requested contents of the Catalog. The
586 various fields of each record are listed on a single line. The various
587 forms of the list command are:
592 list jobid=<id> (list jobid id)
594 list ujobid<unique job name> (list job with unique name)
596 list job=<job-name> (list all jobs with "job-name")
598 list jobname=<job-name> (same as above)
600 In the above, you can add "limit=nn" to limit the output to
605 list jobmedia jobid=<id>
607 list jobmedia job=<job-name>
609 list files jobid=<id>
611 list files job=<job-name>
621 list volumes jobid=<id>
623 list volumes pool=<pool-name>
625 list volumes job=<job-name>
627 list volume=<volume-name>
629 list nextvolume job=<job-name>
631 list nextvol job=<job-name>
633 list nextvol job=<job-name> days=nnn
638 What most of the above commands do should be more or less obvious. In
639 general if you do not specify all the command line arguments, the
640 command will prompt you for what is needed.
642 The {\bf list nextvol} command will print the Volume name to be used by
643 the specified job. You should be aware that exactly what Volume will be
644 used depends on a lot of factors including the time and what a prior job
645 will do. It may fill a tape that is not full when you issue this
646 command. As a consequence, this command will give you a good estimate
647 of what Volume will be used but not a definitive answer. In addition,
648 this command may have certain side effect because it runs through the
649 same algorithm as a job, which means it may automatically purge or
650 recycle a Volume. By default, the job specified must run within the
651 next two days or no volume will be found. You can, however, use the
652 {\bf days=nnn} specification to specify up to 50 days. For example,
653 if on Friday, you want to see what Volume will be needed on Monday,
654 for job MyJob, you would use {\bf list nextvol job=MyJob days=3}.
656 If you wish to add specialized commands that list the contents of the
657 catalog, you can do so by adding them to the {\bf query.sql} file.
658 However, this takes some knowledge of programming SQL. Please see the
659 {\bf query} command below for additional information. See below for
660 listing the full contents of a catalog record with the {\bf llist}
663 As an example, the command {\bf list pools} might produce the following
668 +------+---------+---------+---------+----------+-------------+
669 | PoId | Name | NumVols | MaxVols | PoolType | LabelFormat |
670 +------+---------+---------+---------+----------+-------------+
671 | 1 | Default | 0 | 0 | Backup | * |
672 | 2 | Recycle | 0 | 8 | Backup | File |
673 +------+---------+---------+---------+----------+-------------+
677 As mentioned above, the {\bf list} command lists what is in the
678 database. Some things are put into the database immediately when Bacula
679 starts up, but in general, most things are put in only when they are
680 first used, which is the case for a Client as with Job records, etc.
682 Bacula should create a client record in the database the first time you
683 run a job for that client. Doing a {\bf status} will not cause a
684 database record to be created. The client database record will be
685 created whether or not the job fails, but it must at least start. When
686 the Client is actually contacted, additional info from the client will
687 be added to the client record (a "uname -a" output).
689 If you want to see what Client resources you have available in your conf
690 file, you use the Console command {\bf show clients}.
693 \index[console]{llist}
694 The llist or "long list" command takes all the same arguments that the
695 list command described above does. The difference is that the llist
696 command list the full contents of each database record selected. It
697 does so by listing the various fields of the record vertically, with one
698 field per line. It is possible to produce a very large number of output
699 lines with this command.
701 If instead of the {\bf list pools} as in the example above, you enter
702 {\bf llist pools} you might get the following output:
713 VolRetention: 1,296,000
714 VolUseDuration: 86,400
730 VolUseDuration: 3,600
742 \index[console]{messages}
743 This command causes any pending console messages to be immediately displayed.
747 \index[console]{mount}
748 The mount command is used to get Bacula to read a volume on a physical
749 device. It is a way to tell Bacula that you have mounted a tape and
750 that Bacula should examine the tape. This command is normally
751 used only after there was no Volume in a drive and Bacula requests you to mount a new
752 Volume or when you have specifically unmounted a Volume with the {\bf
753 unmount} console command, which causes Bacula to close the drive. If
754 you have an autoloader, the mount command will not cause Bacula to
755 operate the autoloader unless you specify a {\bf slot} and possibly a
756 {\bf drive}. The various forms of the mount command are:
758 mount storage=\lt{}storage-name\gt{} [ slot=\lt{}num\gt{} ] [
759 drive=\lt{}num\gt{} ]
761 mount [ jobid=\lt{}id\gt{} | job=\lt{}job-name\gt{} ]
763 If you have specified {\bf Automatic Mount = yes} in the Storage daemon's
764 Device resource, under most circumstances, Bacula will automatically access
765 the Volume unless you have explicitly {\bf unmount}ed it in the Console
769 \index[console]{python}
770 The python command takes a single argument {\bf restart}:
774 This causes the Python interpreter in the Director to be reinitialized.
775 This can be helpful for testing because once the Director starts and the
776 Python interpreter is initialized, there is no other way to make it
777 accept any changes to the startup script {\bf DirStartUp.py}. For more
778 details on Python scripting, please see the \ilink{Python
779 Scripting}{PythonChapter} chapter of this manual.
781 \label{ManualPruning}
783 \index[console]{prune}
784 The Prune command allows you to safely remove expired database records
785 from Jobs and Volumes. This command works only on the Catalog database
786 and does not affect data written to Volumes. In all cases, the Prune
787 command applies a retention period to the specified records. You can
788 Prune expired File entries from Job records; you can Prune expired Job
789 records from the database, and you can Prune both expired Job and File
790 records from specified Volumes.
792 prune files|jobs|volume client=\lt{}client-name\gt{}
793 volume=\lt{}volume-name\gt{}
795 For a Volume to be pruned, the {\bf VolStatus} must be Full, Used, or
796 Append, otherwise the pruning will not take place.
799 \index[console]{purge}
800 The Purge command will delete associated Catalog database records from
801 Jobs and Volumes without considering the retention period. {\bf Purge}
802 works only on the Catalog database and does not affect data written to
803 Volumes. This command can be dangerous because you can delete catalog
804 records associated with current backups of files, and we recommend that
805 you do not use it unless you know what you are doing. The permitted
806 forms of {\bf purge} are:
808 purge files jobid=\lt{}jobid\gt{}|job=\lt{}job-name\gt{}|client=\lt{}client-name\gt{}
810 purge jobs client=\lt{}client-name\gt{} (of all jobs)
812 purge volume|volume=\lt{}vol-name\gt{} (of all jobs)
814 For the {\bf purge} command to work on Volume Catalog database records the
815 {\bf VolStatus} must be Append, Full, Used, or Error.
817 The actual data written to the Volume will be unaffected by this command.
820 \index[console]{relabel}
821 \index[general]{relabel}
822 This command is used to label physical volumes. The full form of this
825 relabel storage=\lt{}storage-name\gt{} oldvolume=\lt{}old-volume-name\gt{}
826 volume=\lt{}newvolume-name\gt{}
828 If you leave out any part, you will be prompted for it. In order for
829 the Volume (old-volume-name) to be relabeled, it must be in the catalog,
830 and the volume status must be marked {\bf Purged} or {\bf Recycle}.
831 This happens automatically as a result of applying retention periods, or
832 you may explicitly purge the volume using the {\bf purge} command.
834 Once the volume is physically relabeled, the old data previously written
835 on the Volume is lost and cannot be recovered.
838 \index[console]{release}
839 This command is used to cause the Storage daemon to rewind (release) the
840 current tape in the drive, and to re-read the Volume label the next time
843 release storage=\lt{}storage-name\gt{}
845 After a release command, the device is still kept open by Bacula (unless
846 Always Open is set to No in the Storage Daemon's configuration) so it
847 cannot be used by another program. However, with some tape drives, the
848 operator can remove the current tape and to insert a different one, and
849 when the next Job starts, Bacula will know to re-read the tape label to
850 find out what tape is mounted. If you want to be able to use the drive
851 with another program (e.g. {\bf mt}), you must use the {\bf unmount}
852 command to cause Bacula to completely release (close) the device.
855 \index[console]{reload}
856 The reload command causes the Director to re-read its configuration
857 file and apply the new values. The new values will take effect
858 immediately for all new jobs. However, if you change schedules,
859 be aware that the scheduler pre-schedules jobs up to two hours in
860 advance, so any changes that are to take place during the next two
861 hours may be delayed. Jobs that have already been scheduled to run
862 (i.e. surpassed their requested start time) will continue with the
863 old values. New jobs will use the new values. Each time you issue
864 a reload command while jobs are running, the prior config values
865 will queued until all jobs that were running before issuing
866 the reload terminate, at which time the old config values will
867 be released from memory. The Directory permits keeping up to
868 ten prior set of configurations before it will refuse a reload
869 command. Once at least one old set of config values has been
870 released it will again accept new reload commands.
872 While it is possible to reload the Director's configuration on the fly,
873 even while jobs are executing, this is a complex operation and not
874 without side effects. Accordingly, if you have to reload the Director's
875 configuration while Bacula is running, it is advisable to restart the
876 Director at the next convenient opportunity.
878 \label{restore_command}
880 \index[console]{restore}
881 The restore command allows you to select one or more Jobs (JobIds) to be
882 restored using various methods. Once the JobIds are selected, the File
883 records for those Jobs are placed in an internal Bacula directory tree,
884 and the restore enters a file selection mode that allows you to
885 interactively walk up and down the file tree selecting individual files
886 to be restored. This mode is somewhat similar to the standard Unix {\bf
887 restore} program's interactive file selection mode.
889 restore storage=\lt{}storage-name\gt{} client=\lt{}backup-client-name\gt{}
890 where=\lt{}path\gt{} pool=\lt{}pool-name\gt{} fileset=\lt{}fileset-name\gt{}
891 restoreclient=\lt{}restore-client-name\gt{}
892 select current all done
894 Where {\bf current}, if specified, tells the restore command to
895 automatically select a restore to the most current backup. If not
896 specified, you will be prompted. The {\bf all} specification tells the
897 restore command to restore all files. If it is not specified, you will
898 be prompted for the files to restore. For details of the {\bf restore}
899 command, please see the \ilink{Restore Chapter}{RestoreChapter} of this
902 The client keyword initially specifies the client from which the backup
903 was made and the client to which the restore will be make. However,
904 if the restoreclient keyword is specified, then the restore is written
909 This command allows you to schedule jobs to be run immediately. The full form
912 run job=\lt{}job-name\gt{} client=\lt{}client-name\gt{}
913 fileset=\lt{}FileSet-name\gt{} level=\lt{}level-keyword\gt{}
914 storage=\lt{}storage-name\gt{} where=\lt{}directory-prefix\gt{}
915 when=\lt{}universal-time-specification\gt{} yes
917 Any information that is needed but not specified will be listed for
918 selection, and before starting the job, you will be prompted to accept,
919 reject, or modify the parameters of the job to be run, unless you have
920 specified {\bf yes}, in which case the job will be immediately sent to
923 On my system, when I enter a run command, I get the following prompt:
927 A job name must be specified.
928 The defined Job resources are:
938 Select Job resource (1-9):
943 If I then select number 5, I am prompted with:
949 FileSet: Minou Full Set
954 When: 2003-04-23 17:08:18
955 OK to run? (yes/mod/no):
960 If I now enter {\bf yes}, the Job will be run. If I enter {\bf mod}, I will
961 be presented with the following prompt.
965 Parameters to modify:
973 Select parameter to modify (1-7):
978 If you wish to start a job at a later time, you can do so by setting the When
979 time. Use the {\bf mod} option and select {\bf When} (no. 6). Then enter the
980 desired start time in YYYY-MM-DD HH:MM:SS format.
983 \index[console]{setdebug}
984 \index[dir]{setdebug}
985 \index[dir]{debugging}
986 \index[dir]{debugging Win32}
987 \index[dir]{Windows!debugging}
988 This command is used to set the debug level in each daemon. The form of this
991 setdebug level=nn [trace=0/1 client=\lt{}client-name\gt{} | dir | director |
992 storage=\lt{}storage-name\gt{} | all]
994 If trace=1 is set, then tracing will be enabled, and the daemon will be
995 placed in trace mode, which means that all debug output as set by the
996 debug level will be directed to the file {\bf bacula.trace} in the
997 current directory of the daemon. Normally, tracing is needed only for
998 Win32 clients where the debug output cannot be written to a terminal or
999 redirected to a file. When tracing, each debug output message is
1000 appended to the trace file. You must explicitly delete the file when
1004 \index[console]{show}
1006 The show command will list the Director's resource records as defined in
1007 the Director's configuration file (normally {\bf bacula-dir.conf}).
1008 This command is used mainly for debugging purposes by developers.
1009 The following keywords are accepted on the
1010 show command line: catalogs, clients, counters, devices, directors,
1011 filesets, jobs, messages, pools, schedules, storages, all, help.
1012 Please don't confuse this command
1013 with the {\bf list}, which displays the contents of the catalog.
1016 \index[console]{sqlquery}
1017 The sqlquery command puts the Console program into SQL query mode where
1018 each line you enter is concatenated to the previous line until a
1019 semicolon (;) is seen. The semicolon terminates the command, which is
1020 then passed directly to the SQL database engine. When the output from
1021 the SQL engine is displayed, the formation of a new SQL command begins.
1022 To terminate SQL query mode and return to the Console command prompt,
1023 you enter a period (.) in column 1.
1025 Using this command, you can query the SQL catalog database directly.
1026 Note you should really know what you are doing otherwise you could
1027 damage the catalog database. See the {\bf query} command below for
1028 simpler and safer way of entering SQL queries.
1030 Depending on what database engine you are using (MySQL, PostgreSQL or
1031 SQLite), you will have somewhat different SQL commands available. For
1032 more detailed information, please refer to the MySQL, PostgreSQL or
1033 SQLite documentation.
1037 This command will display the status of the next jobs that are scheduled
1038 during the next 24 hours as well as the status of currently
1039 running jobs. The full form of this command is:
1041 status [all | dir=\lt{}dir-name\gt{} | director |
1042 client=\lt{}client-name\gt{} | storage=\lt{}storage-name\gt{} |
1045 If you do a {\bf status dir}, the console will list any currently
1046 running jobs, a summary of all jobs scheduled to be run in the next 24
1047 hours, and a listing of the last ten terminated jobs with their statuses.
1048 The scheduled jobs summary will include the Volume name to be used. You
1049 should be aware of two things: 1. to obtain the volume name, the code
1050 % TODO: use bullets here or be consistent with numbering items
1051 goes through the same code that will be used when the job runs, which
1052 means that it may prune or recycle a Volume; 2. The Volume listed is
1053 only a best guess. The Volume actually used may be different because of
1054 the time difference (more durations may expire when the job runs) and
1055 another job could completely fill the Volume requiring a new one.
1057 In the Running Jobs listing, you may find the following types of
1063 2507 Catalog MatouVerify.2004-03-13_05.05.02 is waiting execution
1064 5349 Full CatalogBackup.2004-03-13_01.10.00 is waiting for higher
1065 priority jobs to finish
1066 5348 Differe Minou.2004-03-13_01.05.09 is waiting on max Storage jobs
1067 5343 Full Rufus.2004-03-13_01.05.04 is running
1071 Looking at the above listing from bottom to top, obviously JobId 5343
1072 (Rufus) is running. JobId 5348 (Minou) is waiting for JobId 5343 to
1073 finish because it is using the Storage resource, hence the "waiting on
1074 max Storage jobs". JobId 5349 has a lower priority than all the other
1075 jobs so it is waiting for higher priority jobs to finish, and finally,
1076 JobId 2508 (MatouVerify) is waiting because only one job can run at a
1077 time, hence it is simply "waiting execution"
1079 If you do a {\bf status dir}, it will by default list the first
1080 occurrence of all jobs that are scheduled today and tomorrow. If you
1081 wish to see the jobs that are scheduled in the next three days (e.g. on
1082 Friday you want to see the first occurrence of what tapes are scheduled
1083 to be used on Friday, the weekend, and Monday), you can add the {\bf
1084 days=3} option. Note, a {\bf days=0} shows the first occurrence of jobs
1085 scheduled today only. If you have multiple run statements, the first
1086 occurrence of each run statement for the job will be displayed for the
1089 If your job seems to be blocked, you can get a general idea of the
1090 problem by doing a {\bf status dir}, but you can most often get a
1091 much more specific indication of the problem by doing a
1092 {\bf status storage=xxx}. For example, on an idle test system, when
1093 I do {\bf status storage=File}, I get:
1097 Connecting to Storage daemon File at 192.168.68.112:8103
1099 rufus-sd Version: 1.39.6 (24 March 2006) i686-pc-linux-gnu redhat (Stentz)
1100 Daemon started 26-Mar-06 11:06, 0 Jobs run since started.
1106 Jobs waiting to reserve a drive:
1110 JobId Level Files Bytes Status Finished Name
1111 ======================================================================
1112 59 Full 234 4,417,599 OK 15-Jan-06 11:54 kernsave
1116 utochanger "DDS-4-changer" with devices:
1118 Device "DDS-4" (/dev/nst0) is mounted with Volume="TestVolume002"
1120 Slot 2 is loaded in drive 0.
1121 Total Bytes Read=0 Blocks Read=0 Bytes/block=0
1122 Positioned at File=0 Block=0
1123 Device "Dummy" is not open or does not exist.
1124 No DEVICE structure.
1126 Device "DVD-Writer" (/dev/hdc) is not open.
1127 Device "File" (/tmp) is not open.
1130 In Use Volume status:
1135 Now, what this tells me is that no jobs are running and that none of
1136 the devices are in use. Now, if I {\bf unmount} the autochanger, which
1137 will not be used in this example, and then start a Job that uses the
1138 File device, the job will block. When I re-issue the status storage
1139 command, I get for the Device status:
1146 Autochanger "DDS-4-changer" with devices:
1148 Device "DDS-4" (/dev/nst0) is not open.
1149 Device is BLOCKED. User unmounted.
1150 Drive 0 is not loaded.
1151 Device "Dummy" is not open or does not exist.
1152 No DEVICE structure.
1154 Device "DVD-Writer" (/dev/hdc) is not open.
1155 Device "File" (/tmp) is not open.
1156 Device is BLOCKED waiting for media.
1162 Now, here it should be clear that if a job were running that wanted
1163 to use the Autochanger (with two devices), it would block because
1164 the user unmounted the device. The real problem for the Job I started
1165 using the "File" device is that the device is blocked waiting for
1166 media -- that is Bacula needs you to label a Volume.
1169 \index[console]{unmount}
1170 This command causes the indicated Bacula Storage daemon to unmount the
1171 specified device. The forms of the command are the same as the mount command:
1174 unmount storage=<storage-name> [ drive=<num> ]
1176 unmount [ jobid=<id> | job=<job-name> ]
1180 Once you unmount a storage device, Bacula will no longer be able to use
1181 it until you issue a mount command for that device. If Bacula needs to
1182 access that device, it will block and issue mount requests periodically
1185 If the device you are unmounting is an autochanger, it will unload
1186 the drive you have specified on the command line. If no drive is
1187 specified, it will assume drive 1.
1189 \label{UpdateCommand}
1191 \index[console]{update}
1192 This command will update the catalog for either a specific Pool record, a Volume
1193 record, or the Slots in an autochanger with barcode capability. In the case
1194 of updating a Pool record, the new information will be automatically taken
1195 from the corresponding Director's configuration resource record. It can be
1196 used to increase the maximum number of volumes permitted or to set a maximum
1197 number of volumes. The following main keywords may be specified:
1200 media, volume, pool, slots
1204 In the case of updating a Volume, you will be prompted for which value you
1205 wish to change. The following Volume parameters may be changed:
1211 Volume Retention Period
1214 Maximum Volume Files
1215 Maximum Volume Bytes
1223 All Volumes from Pool
1224 All Volumes from all Pools
1229 For slots {\bf update slots}, Bacula will obtain a list of slots and
1230 their barcodes from the Storage daemon, and for each barcode found, it
1231 will automatically update the slot in the catalog Media record to
1232 correspond to the new value. This is very useful if you have moved
1233 cassettes in the magazine, or if you have removed the magazine and
1234 inserted a different one. As the slot of each Volume is updated, the
1235 InChanger flag for that Volume will also be set, and any other Volumes
1236 in the Pool that were last mounted on the same Storage device
1237 will have their InChanger flag turned off. This permits
1238 Bacula to know what magazine (tape holder) is currently in the
1241 If you do not have barcodes, you can accomplish the same thing in
1242 version 1.33 and later by using the {\bf update slots scan} command.
1243 The {\bf scan} keyword tells Bacula to physically mount each tape and to
1244 read its VolumeName.
1246 For Pool {\bf update pool}, Bacula will move the Volume record from its
1247 existing pool to the pool specified.
1249 For {\bf Volume from Pool}, {\bf All Volumes from Pool} and {\bf All Volumes
1250 from all Pools}, the following values are updated from the Pool record:
1251 Recycle, RecyclePool, VolRetention, VolUseDuration, MaxVolJobs, MaxVolFiles,
1252 and MaxVolBytes. (RecyclePool feature is available with bacula 2.1.4 or
1255 The full form of the update command with all command line arguments is:
1259 update volume=xxx pool=yyy slots volstatus=xxx VolRetention=ddd
1260 VolUse=ddd MaxVolJobs=nnn MaxVolBytes=nnn Recycle=yes|no
1261 slot=nnn enabled=n recyclepool=zzz
1267 \index[console]{use}
1268 This command allows you to specify which Catalog database to use. Normally,
1269 you will be using only one database so this will be done automatically. In
1270 the case that you are using more than one database, you can use this command
1271 to switch from one to another.
1273 use \lt{}database-name\gt{}
1277 \index[console]{var name}
1278 This command takes a string or quoted string and does variable expansion on
1279 it the same way variable expansion is done on the {\bf LabelFormat} string.
1280 Thus, for the most part, you can test your LabelFormat strings. The
1281 difference between the {\bf var} command and the actual LabelFormat process
1282 is that during the var command, no job is running so "dummy" values are
1283 used in place of Job specific variables. Generally, however, you will get a
1284 good idea of what is going to happen in the real case.
1287 \index[console]{version}
1288 The command prints the Director's version.
1291 \index[console]{quit}
1292 This command terminates the console program. The console program sends the
1293 {\bf quit} request to the Director and waits for acknowledgment. If the
1294 Director is busy doing a previous command for you that has not terminated, it
1295 may take some time. You may quit immediately by issuing the {\bf .quit}
1296 command (i.e. quit preceded by a period).
1299 \index[console]{query}
1300 This command reads a predefined SQL query from the query file (the name and
1301 location of the query file is defined with the QueryFile resource record in
1302 the Director's configuration file). You are prompted to select a query from
1303 the file, and possibly enter one or more parameters, then the command is
1304 submitted to the Catalog database SQL engine.
1306 The following queries are currently available (version 1.24):
1312 2: List where a file is saved:
1313 3: List where the most recent copies of a file are saved:
1314 4: List total files/bytes by Job:
1315 5: List total files/bytes by Volume:
1316 6: List last 20 Full Backups for a Client:
1317 7: List Volumes used by selected JobId:
1318 8: List Volumes to Restore All Files:
1319 9: List where a File is saved:
1320 Choose a query (1-9):
1326 \index[console]{exit}
1327 This command terminates the console program.
1330 \index[console]{wait}
1331 The wait command causes the Director to pause until there are no jobs
1332 running. This command is useful in a batch situation such as regression
1333 testing where you wish to start a job and wait until that job completes
1334 before continuing. This command now has the following options:
1337 wait [jobid=nn] [jobuid=unique id] [job=job name]
1340 If specified with a specific JobId, ... the wait command will wait
1341 for that particular job to terminate before continuing.
1346 \section{Special dot Commands}
1347 \index[general]{Commands!Special dot}
1348 \index[general]{Special dot Commands}
1350 There is a list of commands that are prefixed with a period (.). These
1351 commands are intended to be used either by batch programs or graphical user
1352 interface front-ends. They are not normally used by interactive users. Once
1353 GUI development begins, this list will be considerably expanded. The following
1354 is the list of dot commands:
1358 .backups job=xxx list backups for specified job
1359 .clients list all client names
1360 .defaults client=xxx fileset=yyy list defaults for specified client
1361 .die cause the Director to segment fault (for debugging)
1362 .dir when in tree mode prints the equivalent to the dir command,
1363 but with fields separated by commas rather than spaces.
1365 .filesets list all fileset names
1366 .help help command output
1367 .jobs list all job names
1368 .levels list all levels
1369 .messages get quick messages
1370 .msgs return any queued messages
1371 .pools list all pool names
1373 .status get status output
1374 .storage return storage resource names
1375 .types list job types
1381 \section{Special At (@) Commands}
1382 \index[general]{Commands!Special At @}
1383 \index[general]{Special At (@) Commands}
1385 Normally, all commands entered to the Console program are immediately
1386 forwarded to the Director, which may be on another machine, to be executed.
1387 However, there is a small list of {\bf at} commands, all beginning with an at
1388 character (@), that will not be sent to the Director, but rather interpreted
1389 by the Console program directly. Note, these commands are implemented only in
1390 the tty console program and not in the GNOME Console. These commands are:
1394 \item [@input \lt{}filename\gt{}]
1395 \index[console]{@input \lt{}filename\gt{}}
1396 Read and execute the commands contained in the file specified.
1398 \item [@output \lt{}filename\gt{} w/a]
1399 \index[console]{@output \lt{}filename\gt{} w/a}
1400 Send all following output to the filename specified either overwriting the
1401 file (w) or appending to the file (a). To redirect the output to the
1402 terminal, simply enter {\bf @output} without a filename specification.
1403 WARNING: be careful not to overwrite a valid file. A typical example during a
1404 regression test might be:
1415 \item [@tee \lt{}filename\gt{} w/a]
1416 \index[console]{@tee \lt{}filename\gt{} w/a}
1417 Send all subsequent output to both the specified file and the terminal. It is
1418 turned off by specifying {\bf @tee} or {\bf @output} without a filename.
1420 \item [@sleep \lt{}seconds\gt{}]
1421 \index[console]{@sleep \lt{}seconds\gt{}}
1422 Sleep the specified number of seconds.
1425 \index[console]{@time}
1426 Print the current time and date.
1429 \index[console]{@version}
1430 Print the console's version.
1433 \index[console]{@quit}
1437 \index[console]{@exit}
1440 \item [@\# anything]
1441 \index[console]{anything}
1447 \section{Running the Console from a Shell Script}
1448 \index[general]{Script!Running the Console Program from a Shell}
1449 \index[general]{Running the Console Program from a Shell Script}
1451 You can automate many Console tasks by running the console program from a
1452 shell script. For example, if you have created a file containing the following
1457 ./bconsole -c ./bconsole.conf <<END_OF_DATA
1458 unmount storage=DDS-4
1464 when that file is executed, it will unmount the current DDS-4 storage device.
1465 You might want to run this command during a Job by using the {\bf
1466 RunBeforeJob} or {\bf RunAfterJob} records.
1468 It is also possible to run the Console program from file input where the file
1469 contains the commands as follows:
1473 ./bconsole -c ./bconsole.conf <filename
1477 where the file named {\bf filename} contains any set of console commands.
1479 As a real example, the following script is part of the Bacula regression
1480 tests. It labels a volume (a disk volume), runs a backup, then does a restore
1485 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
1488 @output /tmp/log1.out
1489 label volume=TestVolume001
1496 @output /tmp/log2.out
1507 The output from the backup is directed to /tmp/log1.out and the output from
1508 the restore is directed to /tmp/log2.out. To ensure that the backup and
1509 restore ran correctly, the output files are checked with:
1513 grep "^Termination: *Backup OK" /tmp/log1.out
1515 grep "^Termination: *Restore OK" /tmp/log2.out
1520 \section{Adding Volumes to a Pool}
1521 \index[general]{Adding Volumes to a Pool}
1522 \index[general]{Pool!Adding Volumes to a}
1524 If you have used the {\bf label} command to label a Volume, it will be
1525 automatically added to the Pool, and you will not need to add any media to the
1528 Alternatively, you may choose to add a number of Volumes to the pool without
1529 labeling them. At a later time when the Volume is requested by {\bf Bacula}
1530 you will need to label it.
1532 Before adding a volume, you must know the following information:
1535 \item The name of the Pool (normally "Default")
1536 \item The Media Type as specified in the Storage Resource in the Director's
1537 configuration file (e.g. "DLT8000")
1538 \item The number and names of the Volumes you wish to create.
1541 For example, to add media to a Pool, you would issue the following commands to
1542 the console program:
1547 Enter name of Pool to add Volumes to: Default
1548 Enter the Media Type: DLT8000
1549 Enter number of Media volumes to create. Max=1000: 10
1550 Enter base volume name: Save
1551 Enter the starting number: 1
1552 10 Volumes created in pool Default
1557 To see what you have added, enter:
1561 *list media pool=Default
1562 +-------+----------+---------+---------+-------+------------------+
1563 | MedId | VolumeNa | MediaTyp| VolStat | Bytes | LastWritten |
1564 +-------+----------+---------+---------+-------+------------------+
1565 | 11 | Save0001 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1566 | 12 | Save0002 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1567 | 13 | Save0003 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1568 | 14 | Save0004 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1569 | 15 | Save0005 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1570 | 16 | Save0006 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1571 | 17 | Save0007 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1572 | 18 | Save0008 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1573 | 19 | Save0009 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1574 | 20 | Save0010 | DLT8000 | Append | 0 | 0000-00-00 00:00 |
1575 +-------+----------+---------+---------+-------+------------------+
1580 Notice that the console program automatically appended a number to the base
1581 Volume name that you specify (Save in this case). If you don't want it to
1582 append a number, you can simply answer 0 (zero) to the question "Enter number
1583 of Media volumes to create. Max=1000:", and in this case, it will create a
1584 single Volume with the exact name you specify.