Bacula 1.29 User's Guide Chapter 7
Back
Running Bacula
Index
Index
Next
The Console Restore Command

Bacula Console

General

The Bacula Console (sometimes called the User Agent) is a program that allows the user or the System Administrator, to interact with the Bacula Director daemon while the daemon is running.

The current Bacula Console comes in two versions: a shell interface (TTY style), and a GNOME GUI interface. Both permit the administrator or authorized users to interact with Bacula. You can determine the status of a particular job, examine the contents of the Catalog as well as perform certain tape manipulations with the Console program.

Since the Console program interacts with the Director by the network, your Console and Director programs do not necessarily need to run on the same machine.

In fact, a certain minimal knowledge of the Console program is needed in order for Bacula to be able to write on more than one tape, because when Bacula requests a new tape, it waits until the user, via the Console program, indicates that the new tape is mounted.

Configuration

When the Console starts, it reads a standard Bacula configuration file named console.conf or gnome-console.conf in the case of the GNOME Console version. This file allows default configuration of the Console, and at the current time, the only Resource Record defined is the Director resource, which gives the Console the name and address of the Director. For more information on configuration of the Console program, please see the Console Configuration File Chapter of this document.

Running the Console Program

After launching the Console program, it will prompt you for the next command with an asterisk (*). (Note, in the GNOME version, the prompt is not present; you simply enter the commands you want in the command text box at the bottom of the screen.) Generally, for all commands, you can simply enter the command name and the Console program will prompt you for the necessary arguments. Alternatively, in most cases, you may enter the command followed by arguments. The general format is:
 <command> <keyword1>[=<argument1>] <keyword2>[=<argument2>] ...
where command is one of the commands listed below; keyword is one of the keywords listed below (usually followed by an argument); and argument is the value.

For example:
list files jobid=23
will list all files saved for JobId 23. Or:
show pools
will display all the Pool resource records.

Stopping the Console Program

Normally, you simply enter quit or exit and the Console program will terminate. However, it waits until the Director acknowledges the command. If the Director is already doing a lengthy command (e.g. prune), it may take some time. If you want to immediately terminate the Console program, enter the .quit command.

There is currently no way to interrupt a Console command once issued (i.e. ctl-C does not work). However, if you are at a prompt that is asking you to select one of several possibilities and you would like to abort the command, you can enter a period (.), and in most cases, you will either be returned to the main command prompt or if appropriate the previous prompt (in the case of nested prompts).

Console Commands

The following commands are currently implemented:
add
This command is used to add Volumes to an existing Pool. The Volume names entered are placed in the Catalog and thus become available for backup operations. Normally, the label command is used rather than this command because the label command labels the physical media (tape) and does the equivalent of the add command. This command affects only the Catalog and not the physical media. The physical media must exist and be labeled before use (usually with the label command). This command can, however, be useful if you wish to add a number of Volumes to the Pool that will be physically labeled at a later time. It can also be useful if you are importing a tape from another site.
autodisplay
This command accepts on or off as an argument, and turns auto-display of messages on or off respectively. The default for the console program is off, which means that you will be notified when there are console messages pending, but they will not automatically be displayed. The default for the gnome-console program is on, which means that messages will be displayed when they are received (usually within 5 seconds of them being generated).

When autodisplay is turned off, you must explicitly retrieve the messages with the messages command. When autodisplay is turned on, the messages will be displayed on the console as they are received.

automount
This command accepts on or off as the argument, and turns auto-mounting of the tape after a label command on or off respectively. The default is on. If automount is turned off, you must explicitly mount the tape after a label command to use it.
cancel
This command is used to cancel a job and accepts jobid=nnn or job=xxx as an argument where nnn is replaced by the JobId and xxx is replaced by the job name. If you do not specify a keyword, the Console program will prompt you with the names of all the active jobs allowing you to choose one.

Once a Job is marked to be canceled, it may take a bit of time (generally within a minute) before it actually terminates, depending on what operations it is doing. If a Job is waiting for a tape to be mounted, it will normally check every 20 minutes. You can cause it to be immediately check (and thus canceled) by issuing a mount command from the Console.

create
This command is used to create a Pool record in the database using the Pool resource record defined in the Director's configuration file. So in a sense, this command simply transfers the information from the Pool resource in the configuration file into the Catalog. Normally this is the very first command that you will issue when first communicating with the Director. It is typically done only once to create the Pool, and usually the first Pool (and possibly the only Pool) record that you will create will be for the Default Pool. Immediately after creating the Pool, you will most likely use the label command to label one or more volumes and add their names to the Media database.

When starting a Job, when Bacula determines that there is no Pool record in the database, but there is a Pool resource of the appropriate name, it will create it for you.

setdebug
This command is used to set the debug level in each daemon. The form of this command is:

setdebug level=nn [client=<client-name> | dir | director | storage=<storage-name> | all]

delete
The delete command is used to delete a Pool record from the Catalog as well as all associated Volume records that were created. This command is very dangerous and we strongly recommend that you do not use it unless you know what you are doing.

The full form of this command is:

delete pool=<pool-name>

or

delete media pool=<pool-name> volume=<volume-name>

The first form deletes a Pool record from the catalog database. The second form deletes a Volume record from the specified pool in the catalog database.

help
This command displays the list of commands available.
label
This command is used to label physical volumes. The full form of this command is:

label storage=<storage-name> volume=<volume-name>

The media type is automatically taken from the Storage resource definition that you supply. Once the necessary information is obtained, the Console program contacts the specified Storage daemon and requests that the tape be labeled. If the tape labeling is successful, the Console program will create a Volume record in the appropriate Pool.

The label command can fail for a number of reasons:

  1. The Volume name you specify is already in the Volume database.
  2. The Storage daemon has a tape already mounted on the device, in which case you must unmount the device, insert a blank tape, then do the label command.
  3. The tape in the device is already a Bacula labeled tape. (Bacula will never relabel a Bacula labeled tape).
  4. There is no tape in the drive.
list
The list command lists particular contents of the Catalog. The various forms of the list command are:

list jobs

list jobid=<id>

list job=<job-name>

list jobmedia [jobid=<id> | job=<job-name>]

list files [jobid=<id> | job=<job-name>]

list pools

list jobtotals

list media

If you wish to add specialized commands that list the contents of the catalog, you can do so by adding them to the query.sql file. However, this takes some knowledge of programming SQL. Please see the query command below for additional information.
messages
This command causes any pending console messages to be immediately displayed.
mount
The mount command is used to mount a volume on a physical device. This command is used only if there is no Volume in a drive and Bacula requests a mount or when you have specifically unmounted a Volume with the unmount console command. The various forms of the mount command are:

mount storage=<storage-name>

mount [ jobid=<id> | job=<job-name> ]

If you have specified Automatic Mount = yes in the Storage daemon's Device resource, under most circumstances, Bacula will automatically access the Volume unless you have explicitly unmounted it in the Console program.

prune
The Prune command allows you to safely remove associated records from Jobs and Volumes. In all cases, the Prune command applies a retention period to the specified records. You can Prune expired File entries from Job records; you can Prune expired Job records from the database, and you can Prune both expired Job and File records from specified Volumes.
purge
The Purge command will delete associated records from Jobs and Volumes without considering the retention period. This command is dangerous and we recommend that you do not use it unless you know what you are doing.
restore
The restore command allows you to select one or more Jobs (JobIds) to be restored using various methods. Once the JobIds are selected, the File records for those Jobs are placed in an internal Bacula directory tree, and the restore enters a file selection mode that allows you to interactively walk up and down the file tree selecting individual files to be restored. This mode is somewhat similar to the standard Unix restore program's interactive file selection mode.

For details of the restore command, please see the Restore Chapter of this manual.

run
This command allows you to schedule jobs to be run immediately. The full form of the command is:

run job=<job-name> client=<client-name> fileset=<FileSet-name> level=<level-keyword> storage=<storage-name> where=<directory-prefix>

Any information that is needed but not specified will be listed for selection, and before starting the job, you will be prompted to accept, reject, or modify the parameters of the job to be run.

On my system, when I enter a run command, I get the following prompt:

A job name must be specified.
The defined Job resources are:
     1: Matou
     2: Polymatou
     3: Rufus
     4: Minimatou
     5: Minou
     6: PmatouVerify
     7: MatouVerify
     8: RufusVerify
     9: Watchdog
Select Job resource (1-9):
     
If I then select number 5, I am prompted with:
Run Backup job
JobName:  Minou
FileSet:  Minou Full Set
Level:    Incremental
Client:   Minou
Storage:  DLTDrive
OK to run? (yes/mod/no):
     
If I now enter yes, the Job will be run. If I enter mod, I will be presented with the following prompt.
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Client
Select parameter to modify (1-5):
     
show
The show command will list the Director's resource records as defined in the Director's configuration file (normally bacula-dir.conf). This command is used mainly for debugging purposes by developers.
sqlquery
The sqlquery command puts the Console program into SQL query mode where each line you enter is concatenated to the previous line until a semicolon (;) is seen. The semicolon terminates the command, which is then passed directly to the SQL database engine. When the output from the SQL engine is displayed, the formation of a new SQL command begins. To terminate SQL query mode and return to the Console command prompt, you enter a period (.) in column 1.

Using this command, you can query the SQL catalog database directly. Note you should really know what you are doing otherwise you could damage the catalog database. See the query command below for simpler and safer way of entering SQL queries.

Depending on what database engine you are using (MySQL or SQLite), you will have somewhat different SQL commands available. For more detailed information, please refer to the MySQL or SQLite documentation.

status
This command will display the status of the next jobs that are scheduled during the next twenty-four hours as well as the status of currently running jobs.
unmount
This command causes the indicated Bacula Storage daemon to unmount the specified device. The forms of the command are the same as the mount command:

unmount storage=<storage-name>

unmount [ jobid=<id> | job=<job-name> ]

update
This command will update either a specific Pool record or a Volume record in the Catalog. In the case of updating a Pool record, the new information will be pulled from the corresponding Director's configuration resource record. It can be used to increase the maximum number of volumes permitted or to set a maximum number of volumes.

In the case of updating a Volume, you will be prompted for which value you wish to change. The following Volume parameters may be changed:

      Volume Status
      Volume Retention Period
      Recycle Flag
      Slot
      
use
This command allows you to specify which Catalog database to use. Normally, you will be using only one database so this will be done automatically. In the case that you are using more than one database, you can use this command to switch from one to another.
version
The command prints the Director's version.
quit
This command terminates the console program. The console program sends the quit request to the Director and waits for acknowledgment. If the Director is busy doing a previous command for you that has not terminated, it may take some time. You may quit immediately by issuing the .quit command (i.e. quit preceded by a period).
query
This command reads a predefined SQL query from the query file (the name and location of the query file is defined with the QueryFile resource record in the Director's configuration file). You are prompted to select a query from the file, and possibly enter one or more parameters, then the command is submitted to the Catalog database SQL engine.

The following queries are currently available (version 1.24):

Available queries:
     1: List Job totals:
     2: List where a file is saved:
     3: List where the most recent copies of a file are saved:
     4: List total files/bytes by Job:
     5: List total files/bytes by Volume:
     6: List last 20 Full Backups for a Client:
     7: List Volumes used by selected JobId:
     8: List Volumes to Restore All Files:
     9: List where a File is saved:
Choose a query (1-9):
      
exit
This command terminates the console program.

Adding Media to a Pool

If you have used the label command to label a Volume, it will be automatically added to the Pool, and you will not need to add any media to the pool.

Alternatively, you may choose to add a number of Volumes to the pool without labeling them. At a later time when the Volume is requested by Bacula you will need to label it.

Before adding media, you must know the following information:

  1. The name of the Pool (normally "Default")
  2. The Media Type as specified in the Storage Resource in the Director's configuration file (e.g. "DLT8000")
  3. The number and names of the Volumes you wish to create.
For example, to add media to a Pool, you would issue the following commands to the console program:
*add
Enter name of Pool to add Volumes to: Default
Enter the Media Type: DLT8000
Enter number of Media volumes to create. Max=1000: 10
Enter base volume name: Save
Enter the starting number: 1
10 Volumes created in pool Default
*
To see what you have added, enter:
*list media pool=Default
+---------+------------+-----------+-----------+----------+---------------------+
| MediaId | VolumeName | MediaType | VolStatus | VolBytes | LastWritten         |
+---------+------------+-----------+-----------+----------+---------------------+
|      11 | Save0001   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      12 | Save0002   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      13 | Save0003   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      14 | Save0004   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      15 | Save0005   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      16 | Save0006   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      17 | Save0007   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      18 | Save0008   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      19 | Save0009   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
|      20 | Save0010   | DLT8000   | Append    |        0 | 0000-00-00 00:00:00 |
+---------+------------+-----------+-----------+----------+---------------------+
*
Notice that the console program automatically appended a number to the base Volume name that you specify (Save in this case). If you don't want it to append a number, you can simply answer 0 (zero) to the question "Enter number of Media volumes to create. Max=1000:", and in this case, it will create a single Volume with the exact name you specify.


Back
Running Bacula
Index
Index
Next
The Console Restore Command
Bacula 1.29 User's Guide
The Network Backup Solution
Copyright © 2000-2003
Kern Sibbald and John Walker