Installing and Configuring PostgreSQL

Bacula 1.34 User's Guide |
Installing and Configuring MySQL | Index | Installing and Configuring SQLite
# Installing and Configuring PostgreSQL ## Installing and Configuring PostgreSQL -- Phase I If you use the ./configure --with-postgresql=PostgreSQL-Directory statement for configuring Bacula, you will need PostgreSQL version 7.3 or later installed. NOTE! PostgreSQL versions earlier than 7.3 do not work with Bacula. If PostgreSQL is installed in the standard system location, you need only enter --with-postgresql since the configure program will search all the standard locations. If you install PostgreSQL in your home directory or some other non-standard directory, you will need to provide the full path with the --with-postgresql option. Installing and configuring PostgreSQL is not difficult but can be confusing the first time. If you prefer, you may want to use a package provided by your chosen operating system. Binary packages are available on most PostgreSQL mirrors. If you prefer to install from source, we recommend following the instructions found in the PostgreSQL documentation. If you are using FreeBSD, this FreeBSD Diary article will be useful. Even if you are not using FreeBSD, the article will contain useful configuration and setup information. After installing PostgreSQL, you should return to completing the installation of Bacula. Later, after Bacula is installed, come back to this chapter to complete the installation. Please note, the installation files used in the second phase of the PostgreSQL installation are created during the Bacula Installation. ## Installing and Configuring PostgreSQL -- Phase II At this point, you should have built and installed PostgreSQL, or already have a running PostgreSQL, and you should have configured, built and installed Bacula. If not, please complete these items before proceeding. Please note that the ./configure used to build Bacula will need to include --with-postgresql=PostgreSQL-directory, where PostgreSQL-directory is the directory name that you specified on the ./configure command for configuring PostgreSQL (if you didn't specify a directory or PostgreSQL is installed in a default location, you do not need to specify the directory). This is needed so that Bacula can find the necessary include headers and library files for interfacing to PostgreSQL. Bacula will install scripts for manipulating the database (create, delete, make tables etc) into the main installation directory. These files will be of the form *_bacula_* (e.g. create_bacula_database). These files are also available in the <bacula-src>/src/cats directory after running ./configure. If you inspect create_bacula_database, you will see that it calls create_postgresql_database. The *_bacula_* files are provided for convenience. It doesn't matter what database you have chosen; create_bacula_database will always create your database. Now you will create the Bacula PostgreSQL database and the tables that Bacula uses. These instructions assume that you already have PostgreSQL running. You will need to perform these steps as a user that is able to create new databases. This can be the PostgreSQL user (on most systems, this is the pgsql user). cd <install-directory> This directory contains the Bacula catalog interface routines. ./create_bacula_database This script creates the PostgreSQL bacula database. ./make_bacula_tables This script creates the PostgreSQL tables used by Bacula. ./grant_bacula_privileges This script creates the database user bacula with restricted access rights. You may want to modify it to suit your situation. Please note that this database is not password protected. Each of the three scripts (create_bacula_database, make_bacula_tables, and grant_bacula_privileges) allows the addition of a command line argument. This can be useful for specifying the user name. For example, you might need to add -h hostname to the command line to specify a remote database server. To take a closer look at the access privileges that you have setup with the above, you can do:
    PostgreSQL-directory/bin/psql --command \\dp bacula
## Re-initializing the Catalog Database After you have done some initial testing with Bacula, you will probably want to re-initialize the catalog database and throw away all the test Jobs that you ran. To do so, you can do the following:
      cd <install-directory>
      ./drop_bacula_tables
      ./make_bacula_tables
      ./grant_bacula_privileges
Please note that all information in the database will be lost and you will be starting from scratch. If you have written on any Volumes, you must write and end of file mark on the volume so that Bacula can reuse it. Do so with:
       (stop Bacula or unmount the drive)
       mt -f /dev/nst0 rewind
       mt -f /dev/nst0 weof
Where you should replace /dev/nst0 with the appropriate tape drive device name for your machine. ## Credits Many thanks to Dan Languille for writing the PostgreSQL driver. This will surely become the most popular database that Bacula supports.
Installing and Configuring MySQL | Index | Installing and Configuring SQLite
Bacula 1.34 User's Guide The Network Backup Solution | Copyright © 2000-2004 Kern Sibbald and John Walker