Bacula 1.29 User's Guide Chapter 6
Back
Console Configuration
Index
Index
Next
The Console Program

Running Bacula

The general flow of running Bacula is:
  1. cd <install-directory>
  2. Start the Database (if using MySQL)
  3. Start the Daemons with ./bacula start
  4. Start the Console program to interact with the Director
  5. Run a job
  6. When the tape fills, unmount the old tape, label a new one, and continue running
  7. Test recovering some files from the tape just written to ensure the tape is good and that you know how to recover. Better test before disaster strikes
Each of these steps is described in more detail below.

Before Running Bacula

Before running Bacula for the first time, we recommend that you run the test command in the btape program as described in the Utility Program Chapter of this manual. This will help ensure that Bacula functions correctly with your tape drive. If you have a modern HP, Sony, or Quantum DDS or DLT tape drive running on Linux or Solaris, you can probably skip this test as Bacula is well tested with these drives and systems. For all other cases, you are strongly encouraged to run the test before continuing. btape also has a fill command that attempts to duplicate what Bacula does when filling a tape and writing on the next tape. You should consider trying this command as well, but be fore warned, it can take hours (about 4 hours on my drive) to fill a large capacity tape.

Starting the Database

If you are using MySQL as the Bacula database, you should start it before you attempt to run a job to avoid getting error messages from Bacula when it starts. The scripts startmysql and stopmysql are what I (Kern) use to start and stop my local MySQL. Note, if you are using the internal database or SQLite, you will not want to use startmysql or stopmysql. If you are running this in production, you will probably want to find some way to automatically start MySQL after each system reboot.

If you are using SQLite or the internal database (i.e. you did not specify the --with-mysql=xxx option on the ./configure command, you need do nothing. SQLite and the internal database are automatically started by Bacula.

Starting the Daemons

To start the three daemons, from the top level directory, simply enter:

./bacula start

This script starts the Storage daemon, the File daemon, and the Director daemon, which all normally run as daemons in the background.

Note, on Windows, currently only the File daemon is ported, and it must be started differently. Please see the Windows Version of Bacula Chapter of this manual.

The installation chapter of this manual explains how you can install scripts that will automatically restart the daemons when the system starts.

Daemon Command Line Options

Each of the three daemons (Director, File, Storage) accepts a small set of options on the command line. In general, each of the daemons as well as the Console program accepts the following options:
-c <file>
Define the file to use as a configuration file. The default is the daemon name followed by .conf i.e. bacula-dir.conf for the Director, bacula-fd.conf for the File daemon, and bacula-sd for the Storage daemon.
-d nn
Set the debug level to nn. Higher levels of debug cause more information to displayed on STDOUT concerning what the daemon is doing.
-f
Run the daemon in the foreground. This option is needed to run the daemon under the debugger.
-s
Do not trap signals. This option is needed to run the daemon under the debugger.
-t
Read the configuration file and print any error messages, then immediately exit. Useful for syntax testing of new configuration files.
-?
Print the version and list of options.
The Director has the following additional Director specific option:
-r <job>
Run the named job immediately. This is for debugging and should not be used.
The File daemon has the following File daemon specific option:
-i
Assume that the daemon is called from inetd or xinetd. In this case, the daemon assumes that a connection has already been made and that it is passed as STDIN. After the connection terminates the daemon will exit.
The Storage daemon has no Storage daemon specific options.

The Console program has no console specific options.

Interacting with the Director to Query or Start Jobs

To communicate with the director and to query the state of Bacula or run jobs, from the top level directory, simply enter:

./console

Alternatively, if you have GNOME installed and used the --enable-gnome on the configure command, you may use the GNOME Console program:

./gnome-console

For simplicity, here we will describe only the ./console program. Most of what is described here applies equally well to ./gnome-console.

The ./console runs the Bacula Console program, which connects to the Director daemon. Normally, it will print something similar to the following:

[kern@polymatou bin]$ ./console
Connecting to Director lpmatou:9101
1000 OK: HeadMan Version: 1.21 (20 June 2002)
*
the asterisk is the console command prompt.

Type help to see a list of available commands:
*help
  Command    Description
  =======    ===========
  add        add media to a pool
  autodisplay autodisplay [on/off] -- console messages
  automount  automount [on/off] -- after label
  cancel     cancel job=nnn -- cancel a job
  create     create DB Pool from resource
  delete     delete [pool= | media volume=]
  help       print this command
  label      label a tape
  list       list [pools | jobs | jobtotals | media  |
             files job=]; from catalog
  messages   messages
  mount      mount 
  prune      prune expired records from catalog
  purge      purge records from catalog
  restore    restore files
  run        run 
  setdebug   sets debug level
  show       show (resource records) [jobs | pools | ... | all]
  sqlquery   use SQL to query catalog
  status     status [storage | client]=
  unmount    unmount 
  update     update Volume or Pool
  use        use catalog xxx
  version    print Director version
  quit       quit
  query      query catalog
  exit       exit = quit

*
Details of the console program's commands are explained in the Console Chapter of this manual.

Have Patience When Starting the Daemons or Mounting Blank Tapes

When you start the Bacula daemons, the Storage daemon attempts to open all defined storage devices and verify the currently mounted Volume (if configured). Until all the storage devices are verified, the Storage daemon will not accept connections from the Console program. If a tape was previously used, it will be rewound, and on some devices this can take several minutes. As a consequence, you may need to have a bit of patience when first contacting the Storage daemon after starting the daemons.

The same considerations apply if you have just mounted a blank tape in a drive such as an HP DLT. It can take a minute or two before the drive properly recognizes that the tape is blank. If you attempt to mount the tape with the Console program during this recognition period, it is quite possible that you will hang your SCSI driver (at least on my RedHat Linux system). As a consequence, you are again urged to have patience when inserting blank tapes. Let the device settle down before attempting to access it.

Last Steps Before Running a Job

There are only three more steps before you can run a job.
  1. Create a Pool to hold Volume names. Bacula will automatically create all Pools you defined in the Director's configuration file.
  2. You must label one or more Volume. That is physically write a label on the tape Volume. This can be done "on the fly" if you wish.
  3. You must add one or more Volume names (tapes, or files) to the Pool database. If you use the label command, this last step will automatically be done.

Creating a Pool

If you understand Pools, you can skip to the next section.

When you run a job, one of the things that Bacula must know is what Volumes to use to backup the FileSet. Instead of specifying a Volume (tape) directly, you specify which Pool of Volumes you want Bacula to consult when it wants a tape for writing backups. Bacula will select the first available Volume from the Pool that is appropriate for the Storage device you have specified for the Job being run. When a volume is filled up with data, Bacula will change its Pool entry from Append to Full, and Bacula will use the next volume and so on. If no appendable Volume exists in the Pool, the Director will attempt to recycle an old Volume, if there are still no appendable Volumes available, Bacula send messages requesting the operator to create an appropriate Volume.

Bacula keeps track of the Pool name, the volumes contained in the Pool, and a number of attributes of each of those Volumes.

When Bacula starts, it ensures that all Pool resource definitions have been recorded in the catalog. You can verify this by entering:
list pools
to the console program, which should print something like the following:
*list pools
Using default Catalog name=MySQL DB=bacula
+--------+---------+---------+---------+----------+-------------+
| PoolId | Name    | NumVols | MaxVols | PoolType | LabelFormat |
+--------+---------+---------+---------+----------+-------------+
| 1      | Default | 3       | 0       | Backup   | *           |
| 2      | File    | 12      | 12      | Backup   | File        |
+--------+---------+---------+---------+----------+-------------+
*
If you attempt to create the same Pool name a second time, Bacula will print:
Error: Pool Default already exists.

Once created, you may use the update command to modify many of the values in the Pool record.

Labeling Your Volumes

Bacula requires that each Volume contain a software label. There are several strategies for labeling volumes. The one I use is to label them as they are needed by Bacula using the console program. That is when Bacula needs a new Volume, and it does not find one in the catalog, it will send me an email message requesting that I add Volumes to the Pool. I then use the label command in the Console program to label a new Volume and to define it in the Pool database, after which Bacula will begin writing on the new Volume.

Another strategy is to label a set of volumes at the start, then use them as Bacula requests them. This is most often done if you are cycling through a set of tapes. For more details on recycling, please see the Automatic Volume Recycling chapter of this manual.

If you run a Bacula job, and you have no labeled tapes in the Pool, Bacula will inform you, and you can create them "on-the-fly" so to speak. In my case, I label my tapes with the date, for example: DLT-18April2002. See below for the details of using the label command.

Labeling Volumes with the Console Program

Labeling volumes is normally done by using the console program.
  1. ./console
  2. label
If Bacula complains that you cannot label the tape because it is already labeled, simply unmount the tape using the unmount command in the console, then physically mount a blank tape and re-issue the label command.

Since the physical storage media is different for each device, the label command will provide you with a list of the defined Storage resources such as the following:

The defined Storage resources are:
     1: Floppy
     2: File
     3: 8mmDrive
     4: DLTDrive
     5: SDT-10000
Select Storage resource (1-5):
At this point, you should have a blank tape in the drive corresponding to the Storage resource that you select.

It will then ask you for the Volume name.

Enter new Volume name:
If Bacula complains:
Media record for Volume xxxx already exists.
It means that the volume name xxxx that you entered already exists in the Media database. You can list all the defined Media (Volumes) with the list media command. Note, the LastWritten column has been truncated for proper printing.
+---------------+-----------+-----------+----------------+-----/~/-+------------+---------+
| VolumeName    | MediaType | VolStatus | VolBytes       | LastWri | VolReten   | Recycle |
+---------------+-----------+-----------+----------------+---------+------------+---------+
| DLTVol0002    | DLT8000   | Full      | 56,128,042,217 | 2001-10 | 31,536,000 |       0 |
| DLT-07Oct2001 | DLT8000   | Full      | 56,172,030,586 | 2001-11 | 31,536,000 |       0 |
| DLT-08Nov2001 | DLT8000   | Full      | 55,691,684,216 | 2001-12 | 31,536,000 |       0 |
| DLT-01Dec2001 | DLT8000   | Full      | 55,162,215,866 | 2001-12 | 31,536,000 |       0 |
| DLT-28Dec2001 | DLT8000   | Full      | 57,888,007,042 | 2002-01 | 31,536,000 |       0 |
| DLT-20Jan2002 | DLT8000   | Full      | 57,003,507,308 | 2002-02 | 31,536,000 |       0 |
| DLT-16Feb2002 | DLT8000   | Full      | 55,772,630,824 | 2002-03 | 31,536,000 |       0 |
| DLT-12Mar2002 | DLT8000   | Full      | 50,666,320,453 | 1970-01 | 31,536,000 |       0 |
| DLT-27Mar2002 | DLT8000   | Full      | 57,592,952,309 | 2002-04 | 31,536,000 |       0 |
| DLT-15Apr2002 | DLT8000   | Full      | 57,190,864,185 | 2002-05 | 31,536,000 |       0 |
| DLT-04May2002 | DLT8000   | Full      | 60,486,677,724 | 2002-05 | 31,536,000 |       0 |
| DLT-26May02   | DLT8000   | Append    |  1,336,699,620 | 2002-05 | 31,536,000 |       1 |
+---------------+-----------+-----------+----------------+-----/~/-+------------+---------+

Once Bacula has verified that the volume does not already exist, it will then prompt you for the name of the Pool in which the Volume (tape) to be created. If there is only one Pool (Default), it will be automatically selected.

If the tape is successfully labeled, a media record will also be created in the Pool. That is the Volume name and all its other attributes will appear when you list the Pool. In addition, that Volume will be available for backup if the MediaType matches what is requested by the Storage daemon.

When you labeled the tape, you answered very few questions about it -- principally the Volume name, and perhaps the Slot. However, a Volume record in the catalog database (internally known as a Media record) contains quite a few attributes. Most of these attributes will be filled in from the default values that were defined in the Pool (i.e. the Pool holds most of the default attributes used when creating a Volume).

It is also possible to add media to the pool without physically labeling the Volumes. This can be done with the add command. For more information, please see the Console Chapter of this manual.

Running a Job

If you have specified all the necessary Job resources including a schedule, your Backup jobs will be automatically scheduled. To find out what jobs are running and what jobs are scheduled to be run in the next 24 hours, enter the status dir command to the console program:
[kern@polymatou bin]$ ./console
Connecting to Director localhost:9101
1000 OK: rufus-dir Version: 1.15 (5 March 2002)
*status dir
HeadMan Version: 1.15 (5 March 2002)
Daemon started 05-Mar-2002 19:15, 0 Jobs run.
Console connected at 05-Mar-2002 19:15
No jobs are running.
Backup job "Rufus" scheduled for 06-Mar-2002 01:05
Backup job "Minou" scheduled for 06-Mar-2002 01:05
Backup job "Minimatou" scheduled for 06-Mar-2002 01:05
Verify job "MatouVerify" scheduled for 06-Mar-2002 05:05
Backup job "Matou" scheduled for 06-Mar-2002 01:05
Backup job "Polymatou" scheduled for 06-Mar-2002 01:05
====
*
In this case, you can see that no jobs are running, but that there are five jobs scheduled to be run at 1:05am (note they will run one at a time since the Director is configured for one job maximum).

Now to run a Job immediately, you can simply enter:
run Rufus
where Rufus is the name of the job to be run. The default job level will be used (normally incremental).

Alternatively, you can simply enter:

run
and Bacula will prompt you to choose a job to run from the list of all jobs.

Before actually running the job, Bacula will display the parameters of the job to be run and request you to confirm. In the following example, the user has requested to run job kernsave:

Run Backup job
JobName:  kernsave
FileSet:  Kerns Files
Level:    incremental
Client:   Rufus
Storage:  SDT-10000
OK to run? (yes/mod/no):
If you wish to run the job, simply enter yes. If you want to change the parameters shown before running the job, enter mod for modify, and Bacula will prompt you for the values you wish to change.

You can use the status command to watch the progress of your job.

When the job completes, it will normally email you a message and send it to the Console (depending on your configuration). The output from a typical backup Job such as the one started above looks like the following:

rufus-dir: 19-Sep-2002 10:52
JobId:                  6
Job:                    kernsave.2002-09-19.10:50:48
FileSet:                Kerns Files
Backup Level:           Full
Client:                 Rufus
Start time:             19-Sep-2002 10:50
End time:               19-Sep-2002 10:52
Files Written:          85
Bytes Written:          4,181,712
Rate:                   50.4 KB/s
Volume names(s):        test5
Volume Session Id:      1
Volume Session Time:    1032425434
Volume Bytes:           25,158,136
Termination:            Backup OK

rufus-dir: Begin pruning Jobs.
rufus-dir: No Jobs found to prune.
rufus-dir: Begin pruning Files.
rufus-dir: No Files found to prune.
rufus-dir: End auto prune.
If you have defined a Schedule resource for your job, it will be run automatically according to the defined schedule.

Quitting the Console Program

Simply enter the command quit.

When The Tape Fills

If you have scheduled your job, typically nightly, there will come a time when the tape fills up and Bacula cannot continue. In this case, Bacula will send you a message similar to the following:
rufus-sd: block.c:337 === Write error errno=28: ERR=No space left
          on device
This indicates that Bacula got a write error because the tape is full. Bacula will then search the Pool specified for your Job looking for an appendable volume. In the simplest case, it will not find one, and it will send you a message similar to the following:
rufus-sd: Job kernsave.2002-09-19.10:50:48 waiting. Cannot find any
          appendable volumes.
Please use the "label"  command to create a new Volume for:
    Storage:      SDT-10000
    Media type:   DDS-4
    Pool:         Default
Until you create a new Volume, this message will be repeated an hour later, then two hours later, and so on doubling the interval each time up to a maximum interval of 1 day.

The obvious question at this point is: What do I do now?

The answer is simple: first, using the Console program, release the tape using the unmount command. If you only have a single drive, it will be automatically selected, otherwise, make sure you release the one specified on the message (in this case STD-10000).

Next, you remove the tape from the drive and insert a new blank tape. Note, on some older tape drives, you may need to write an end of file mark (mt -f /dev/nst0 weof) to prevent the drive from running away when Bacula attempts to read the label.

Finally, you use the label command in the Console to write a label to the new Volume. The label command will contact the Storage daemon to write the software label, if it is successful, it will add the new Volume to the Pool, then issue a mount command to the Storage daemon. See the previous sections of this chapter for more details on labeling tapes.

The result is that Bacula will continue the previous Job writing the backup to the new Volume.

Other Useful Console Commands

status dir
Print a status of all running jobs and jobs scheduled in the next 24 hours.
status
The console program will prompt you to select a daemon type, then will request the daemon's status.
status jobid=nn
Print a status of JobId nn if it is running. The Storage daemon is contacted and requested to print a current status of the job as well.
list pools
List the pools defined in the Catalog (normally only Default is used).
list media
Lists all the media defined in the Catalog.
list jobs
Lists all jobs in the Catalog that have run.
list jobid=nn
Lists JobId nn from the Catalog.
list jobtotals
Lists totals for all jobs in the Catalog.
list files jobid=nn
List the files that were saved for JobId nn.
list jobmedia
List the media information for each Job run.
messages
Prints any messages that have been directed to the console.
unmount storage=storage-name
Unmounts the drive associated with the storage device with the name storage-name if the drive is not currently being used. This command is used if you wish Bacula to free the drive so that you can use it to label a tape.
mount storage=storage-name
Causes the drive associated with the storage device to be mounted again. When Bacula reaches the end of a volume and requests you to mount a new volume, you must issue this command after you have placed the new volume in the drive. In effect, it is the signal needed by Bacula to know to start reading or writing the new volume.
quit
Exit or quit the console program.
Most of the commands given above, with the exception of list, will prompt you for the necessary arguments if you simply enter the command name.

Debug Daemon Output

If you want debug output from the daemons as they are running, start the daemons from the install directory as follows:

./bacula start -d20
To stop the three daemons, enter the following from the install directory:
./bacula stop

The execution of bacula stop may complain about pids not found. This is OK, especially if one of the daemons has died, which is very rare.

To do a full system save, each File daemon must be running as root so that it will have permission to access all the files. None of the other daemons require root privileges. However, the Storage daemon must be able to open the tape drives. On many systems, only root can access the tape drives. Either run the Storage daemon as root, or change the permissions on the tape devices to permit non-root access. MySQL can be installed and run with any userid; root privilege is not necessary.


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