个人工具

UbuntuHelp:Bacula

来自Ubuntu中文

跳转至: 导航, 搜索

Introduction

Bacula is a backup program enabling you to backup, restore, and verify data across your network. There are Bacula clients for Linux, Windows, and Mac OSX. Making it a cross platform network wide solution. There is an official documentation about Bacula here : https://help.ubuntu.com/8.04/serverguide/C/bacula.html List of graphical confiuration tools : http://www.bacula.org/en/rel-manual/GUI_Programs.html

Overview

Bacula is made up of several components and services used to manage what to backup and where to back it up to:

  • Bacula Director -- service that controls all backup, restore, verify, and archive operations.
  • Bacula Console -- application allowing communication with the Director. There are three versions of the Console:
  • Text based command line version.
  • Gnome based gtk+ GUI interface.
  • wxWidgets interface GUI interface.
  • Bacula File -- also known as the Bacula Client program. Installed on machines to be backed up, and is responsible for the data requested by the Director.
  • Bacula Storage -- the programs that perform the storage and recovery of data to the physical media.
  • Bacula Catalog -- responsible for maintaining the file indexes and volume databases for all files backed up. The catalog enables quick location and restoration of archived files. The Catalog supports three different databases MySQL, PostgreSQL, and SQLite.
  • Bacula Monitor -- allows the monitoring of the Director, File daemons, and Storage daemons. Currently the Monitor is only available as a GTK+ GUI application.

These services and applications can be run on multiple servers and clients, or they can be installed on one machine if backing up a single disk or volume.

Installation

There are multiple packages containing the different Bacula components. Currently the Bacula packages are in the Universe repository, but work is being done to get the core packages into the Main repository. By default installing the bacula package will install the bacula-director-sqlite3 package which will use SQLite for the Catalog. If you want to use MySQL or PostgreSQL for the catalog install bacula-director-mysql or bacula-director-pgsql respectively. NOTE: as of Karmic (Ubuntu 9.10) the default database backend is mysql. See InstallingSoftware for information on repositories and using package managers. After installing Bacula the bacula-sd daemon may have an issue starting because there is no storage device configured. A work around for this error is to configure an Archive Device in the /etc/bacula/bacula-sd.conf file, and enter the following apt command to complete the package install:

sudo apt-get install -f

Bacula also requires a Mail Transfer Agent (MTA). The default Ubuntu MTA is Postfix, but it is possible to use another MTA such as Exim4. For details on setting up Postfix see Postfix

Configuration

Bacula configuration files are formatted based on resources comprising of directives surrounded by "{}" braces. The files are located in the /etc/bacula directory, and there is a file for each component. The various Bacula components must authorize themselves to each other. This is accomplished using the password directive. For example the Storage resource password in the /etc/bacula/bacula-dir.conf file must match the Director resource password in /etc/bacula/bacula-sd.conf. By default Bacula configures a FileSet and job to backup itself. The job name is Client1 by default. If you plan on using the server to backup more than one client you should change the name of this job to something more descriptive. To change the name edit /etc/bacula/bacula-dir.conf:

#
# Define the main nightly save backup job
#   By default, this job will back up to disk in 
Job {
  Name = "BackupServer"
  JobDefs = "DefaultJob"
  Write Bootstrap = "/var/lib/bacula/Client1.bsr"
}
  • The example above changes the job name to BackupServer matching the machine's host name.

The Console can be used to query the Director about jobs, but to use the Console with a non-root user the user needs to be in the bacula group. To add a user to the bacula group enter the following from a terminal prompt:

sudo adduser $username bacula
  • Replacing $username with an actual username. Also, if you are adding the current user to the group you will need to log out and back in for the new permissions to take effect.

Localhost Backup

This section describes how to backup specified directories on a single host to a local tape drive.

  • First, the Storage device needs to be configured. Edit /etc/bacula/bacula-sd.conf add:
Device {
  Name = "Tape Drive"
  Device Type = tape
  Media Type = DDS-4
  Archive Device = /dev/st0
  Hardware end of medium = No;
  AutomaticMount = yes;               # when device opened, read it
  AlwaysOpen = Yes;
  RemovableMedia = yes;
  RandomAccess = no;
  Alert Command = "sh -c 'tapeinfo -f %c | grep TapeAlert'"
}
  • The example is for a DDS-4 tape drive adjust the Media Type and Archive Device to match your hardware.
  • You could also uncomment one of the other examples in the file.
  • After editing /etc/bacula/bacula-sd.conf the Bacula Storage deamon will need to be restarted:
sudo /etc/init.d/bacula-sd restart
  • Now add a Storage resource in /etc/bacula/bacula-dir.conf to use the new Device:
# Definition of "Tape Drive" storage device
Storage {
  Name = TapeDrive
  # Do not use "localhost" here    
  Address = backupserver               # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "Cv70F6pf1t6pBopT4vQOnigDrR0v3LT3Cgkiyj"
  Device = "Tape Drive"
  Media Type = tape
}
  • The Address directive needs to be the Fully Qualified Domain Name (FQDN) of the server. Change backupserver to the actual host name.
  • Make sure the Password directive matches the password string in /etc/bacula/bacula-sd.conf.
  • Create a new FileSet which will determines what directories to backup, add:
# LocalhostBacup FileSet.
FileSet {
  Name = "LocalhostFiles"
  Include {
    Options {
      signature = MD5
      compression=GZIP
    }
    File = /etc
    File = /home
  }
}
  • This FileSet will backup the /etc and /home directories. The Options resource directives configure the FileSet to create a MD5 signature for each file backed up, and to compress the files using GZIP.
  • Next, create a new Schedule for the backup job:
# LocalhostBackup Schedule -- Daily.
Schedule {
  Name = "LocalhostDaily"
  Run = Full daily at 00:01
}
  • The job will run every day at 00:01 or 12:01 am. There are many other scheduling options available.
  • Finally create the Job:
# Localhost backup.
Job {
  Name = "LocalhostBackup"
  JobDefs = "DefaultJob"
  Enabled = yes
  Level = Full
  FileSet = "LocalhostFiles"
  Schedule = "LocalhostDaily"
  Storage = TapeDrive
  Write Bootstrap = "/var/lib/bacula/LocalhostBackup.bsr"
}  
  • The job will do a Full backup every day to the tape drive.
  • Each tape used will need to have a Label. If the current tape does not have a label Bacula will send an email letting you know. To label a tape using the Console enter the following from a terminal:
bconsole
  • At the Bacula Console prompt enter:
label
  • You will then be prompted for the Storage resource:
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
The defined Storage resources are:
     1: File
     2: TapeDrive
Select Storage resource (1-2): 2
  • Enter the new Volume name:
Enter new Volume name: Sunday
Defined Pools:
     1: Default
     2: Scratch
  • Select the Pool:
Select the Pool (1-2): 1
Connecting to Storage daemon TapeDrive at backupserver:9103 ...
Sending label command for Volume "Sunday" Slot 0 ...

Notes

By using the apt-get command we are downloading the available build from Ubuntu universe. For karmic you can check the version available at http://packages.ubuntu.com/karmic/admin/ (at time of writting it was version 2.4.4-1ubuntu9 and in source there is up to verison 5)

Resources