Bacula Enterprise Backup Configuration

Bacula is a powerful, network-based backup system providing enterprise-grade backup and recovery capabilities for large heterogeneous environments. With support for multiple storage backends, advanced scheduling, and comprehensive disaster recovery features, Bacula scales from small networks to large data centers. This guide covers deploying Bacula infrastructure, configuring backup jobs, and implementing recovery procedures.

Table of Contents

  1. Bacula Architecture
  2. Installation and Deployment
  3. Director Configuration
  4. Storage Daemon Setup
  5. File Daemon Installation
  6. Job and Schedule Configuration
  7. Pool and Volume Management
  8. Backup and Recovery Operations
  9. Conclusion

Bacula Architecture

Bacula comprises four essential components:

  • Director (DIR): Master control and scheduling daemon managing backup policies
  • Storage Daemon (SD): Manages physical storage devices and volume handling
  • File Daemon (FD): Client-side agent performing actual file backup
  • Console: Administrative interface for operator interaction

Communication uses TCP/IP with mutual authentication between components. Director maintains configuration, schedules, and catalog database tracking all backup objects.

Installation and Deployment

Prerequisites

# System requirements per node:
# - 2+ vCPU cores
# - 4+ GB RAM
# - Network connectivity on TCP ports 9101-9103
# - Sufficient disk space for storage and catalogs

# Check available resources
nproc
free -h
df -h

# Create Bacula system user
sudo useradd -r -s /bin/false bacula || true

Installing Director (Ubuntu/Debian)

# Add Bacula repository
sudo add-apt-repository ppa:bacula/stable

# Update packages
sudo apt-get update

# Install Director and Console
sudo apt-get install -y bacula-director bacula-console

# Install PostgreSQL database (recommended)
sudo apt-get install -y postgresql postgresql-contrib

# Create Bacula database
sudo /usr/lib/bacula/make_postgresql_tables

# Set database permissions
sudo chown bacula:bacula /var/lib/bacula
sudo chmod 755 /var/lib/bacula

# Start services
sudo systemctl enable bacula-dir
sudo systemctl start bacula-dir

# Verify service
sudo systemctl status bacula-dir

Installing Director on CentOS/RHEL

# Install EPEL repository
sudo yum install -y epel-release

# Install Bacula Director
sudo yum install -y bacula-director bacula-console

# Install PostgreSQL
sudo yum install -y postgresql-server postgresql-contrib

# Initialize database
sudo postgresql-setup initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Create Bacula tables
sudo /usr/libexec/bacula/make_postgresql_tables

# Start Bacula
sudo systemctl enable bacula-dir
sudo systemctl start bacula-dir

Firewall Configuration

# UFW (Ubuntu)
sudo ufw allow 9101/tcp  # Director
sudo ufw allow 9102/tcp  # File Daemon
sudo ufw allow 9103/tcp  # Storage Daemon

# Firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --add-port=9101/tcp
sudo firewall-cmd --permanent --add-port=9102/tcp
sudo firewall-cmd --permanent --add-port=9103/tcp
sudo firewall-cmd --reload

Director Configuration

Main Director Configuration File

Modify /etc/bacula/bacula-dir.conf:

# Edit configuration
sudo nano /etc/bacula/bacula-dir.conf

# Basic Director configuration structure:
# Director {
#   Name = bacula-dir
#   DIRport = 9101
#   QueryFile = "/etc/bacula/query.sql"
#   WorkingDirectory = "/var/spool/bacula"
#   PidDirectory = "/var/run"
#   Maximum Concurrent Jobs = 20
#   Password = "long_random_password"
#   DirAddress = 192.168.1.10
# }

# Verify configuration syntax
sudo bacula-dir -t /etc/bacula/bacula-dir.conf

# Restart with valid configuration
sudo systemctl restart bacula-dir

Messages Configuration

Configure message routing:

# Edit messages configuration
sudo nano /etc/bacula/bacula-dir.conf

# Add Messages resource:
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
Messages {
  Name = Standard
  director = bacula-dir = all
  append = "/var/log/bacula/bacula.log" = all
  catalog = all
}
EOF

# Restart director
sudo systemctl restart bacula-dir

Storage Daemon Setup

Installing Storage Daemon

# Install on dedicated storage server
sudo apt-get install -y bacula-sd bacula-sd-mysql

# Or on same server as Director (not recommended for production)
sudo apt-get install -y bacula-sd

# Create storage directories
sudo mkdir -p /bacula/storage
sudo chown bacula:bacula /bacula/storage
sudo chmod 700 /bacula/storage

# Start Storage Daemon
sudo systemctl enable bacula-sd
sudo systemctl start bacula-sd

# Verify service
sudo systemctl status bacula-sd

Storage Daemon Configuration

Edit /etc/bacula/bacula-sd.conf:

# Storage Daemon section
cat <<'EOF' | sudo tee /etc/bacula/bacula-sd.conf
Storage {
  Name = bacula-sd
  SDPort = 9103
  WorkingDirectory = "/var/spool/bacula"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
  SDAddress = 192.168.1.20
}

# Configure device for backups
Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /bacula/storage
  LabelMedia = yes
  Random Access = yes
  AutomaticMount = yes
  RemovableMedia = no
  AlwaysOpen = no
  MaximumOpenWait = 30
  MaximumNetworkBufferSize = 65536
}

# Messages routing
Messages {
  Name = Standard
  director = bacula-dir = all
}

# Director authorization
Director {
  Name = bacula-dir
  Password = "director_password_here"
}
EOF

# Verify configuration
sudo bacula-sd -t /etc/bacula/bacula-sd.conf

# Restart Storage Daemon
sudo systemctl restart bacula-sd

File Daemon Installation

Installing File Daemon on Backup Clients

# Ubuntu/Debian client installation
sudo apt-get install -y bacula-fd bacula-common

# CentOS/RHEL client installation
sudo yum install -y bacula-client bacula-common

# Create client configuration
sudo nano /etc/bacula/bacula-fd.conf

# Minimum FD configuration:
cat <<'EOF' | sudo tee /etc/bacula/bacula-fd.conf
FileDaemon {
  Name = client-fd
  FDport = 9102
  WorkingDirectory = "/var/spool/bacula"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
  FDAddress = 192.168.1.30
}

Director {
  Name = bacula-dir
  Password = "fd_password_here"
}

Messages {
  Name = Standard
  director = bacula-dir = all
}
EOF

# Start File Daemon
sudo systemctl enable bacula-fd
sudo systemctl start bacula-fd

# Verify service
sudo systemctl status bacula-fd

Job and Schedule Configuration

Defining Backup Jobs

Add job definitions to /etc/bacula/bacula-dir.conf:

# Job definition for full backup
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
Job {
  Name = "Full_Backup"
  Type = Backup
  Client = client-fd
  FileSet = "Full Set"
  Schedule = "WeeklyCycle"
  Storage = File
  Messages = Standard
  Pool = Default
  Priority = 10
  Write Bootstrap = "/var/spool/bacula/%c.bsr"
}
EOF

# Job definition for incremental backup
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
Job {
  Name = "Incremental_Backup"
  Type = Backup
  Client = client-fd
  FileSet = "Full Set"
  Schedule = "DailySchedule"
  Storage = File
  Messages = Standard
  Pool = Default
  Level = Incremental
  Priority = 20
}
EOF

# Job for restore operations
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
Job {
  Name = "RestoreJob"
  Type = Restore
  Client = client-fd
  FileSet = "Full Set"
  Storage = File
  Messages = Standard
  Pool = Default
}
EOF

Defining FileSets

FileSets specify which files to backup:

# FileSet definition
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
FileSet {
  Name = "Full Set"
  Include {
    Options {
      signature = MD5
      compression = GZIP
    }
    File = /home
    File = /etc
    File = /var/www
    File = /opt
  }
  Exclude {
    File = /home/*/.cache
    File = /home/*/Downloads
    File = /var/spool/bacula
    File = /proc
    File = /sys
    File = /dev
  }
}
EOF

# Specific application FileSet
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
FileSet {
  Name = "Database Backup"
  Include {
    Options {
      signature = MD5
      compression = LZ4
    }
    File = /var/lib/mysql
    File = /var/lib/postgresql
  }
}
EOF

Scheduling Backups

# Weekly schedule with daily incrementals
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
Schedule {
  Name = "WeeklyCycle"
  Run = Full 1st sun at 23:05
  Run = Differential 2nd-5th sun at 23:05
  Run = Incremental mon-sat at 23:05
}

Schedule {
  Name = "DailySchedule"
  Run = Incremental daily at 02:00
}

Schedule {
  Name = "HourlySchedule"
  Run = Incremental hourly at 0:30
}
EOF

# Verify configuration
sudo bacula-dir -t /etc/bacula/bacula-dir.conf

# Restart Director
sudo systemctl restart bacula-dir

Pool and Volume Management

Creating Storage Pools

# Pool for regular backups
cat <<'EOF' | sudo tee -a /etc/bacula/bacula-dir.conf
Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Action On Purge = Truncate
  Volume Retention = 365 days
  Maximum Volume Bytes = 50G
  Maximum Volumes = 100
}

# Pool for long-term retention
Pool {
  Name = Monthly
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 2555 days
  Maximum Volume Bytes = 100G
  Maximum Volumes = 50
}

# Pool for restore operations
Pool {
  Name = Scratch
  Pool Type = Backup
  Recycle = yes
}
EOF

Volume Management via Bconsole

# Connect to Bacula console
bconsole

# Within bconsole:
# List all pools
list pools

# List all volumes
list volumes

# List volumes in specific pool
list volumes pool=Default

# Label new volume
label
# Follow prompts to assign volume to pool

# Purge old volumes
purge volume=vol001

# Recycle volume
recycle volume=vol001

# Exit console
exit

Backup and Recovery Operations

Running Backups

# Via bconsole:
bconsole

# Run backup job
run
# Select job number
# Review parameters
# Select "yes" to confirm

# Or from command line:
bconsole -b <<EOF
run job="Full_Backup"
yes
EOF

# Monitor backup progress
status dir
status sd

Restore Operations

# Via bconsole:
bconsole

# Start restore dialog
restore

# Specify restore options:
# - Select client
# - Pick backup date
# - Navigate directory structure
# - Select files to restore

# View selected files
ls

# Execute restore
done

# Restore from command line:
echo "restore select all" | bconsole

Restore to Alternate Location

# Connect to bconsole
bconsole

# Start restore for specific file
restore
cd /path/to/restore
select file.txt
cd /

# Change restore location
mod
# When prompted: Job,File
# Enter alternate directory like /tmp/restore

# Complete restore
done

Monitoring and Maintenance

Backup Status Monitoring

# Check recent backups
bconsole -b <<EOF
list jobs
EOF

# Detailed job information
bconsole -b <<EOF
list jobids
EOF

# View specific job details
bconsole -b <<EOF
list files jobid=1
EOF

# Check backup statistics
sqlite3 /var/spool/bacula/bacula.db \
  "SELECT Job.Name, COUNT(*) as FileCount, \
   SUM(File.FileIndex) as TotalBytes FROM Job \
   JOIN File ON Job.JobId=File.JobId GROUP BY Job.Name;"

Database Optimization

# Vacuum database (reduces size)
sqlite3 /var/spool/bacula/bacula.db "VACUUM;"

# PostgreSQL optimization
sudo -u postgres vacuumdb -z bacula

# Analyze catalog
sudo /usr/libexec/bacula/dbcheck -b /etc/bacula/bacula-dir.conf

# Cleanup orphaned records
bconsole -b <<EOF
prune catalog
yes
EOF

Log Monitoring

# View Director logs
tail -f /var/log/bacula/bacula.log

# View Storage Daemon logs
tail -f /var/log/bacula/bacula-sd.log

# View File Daemon logs (on client)
tail -f /var/log/bacula/bacula-fd.log

# Search for errors
grep -i error /var/log/bacula/*.log

Conclusion

Bacula provides a robust, enterprise-grade backup solution suitable for complex, heterogeneous environments. By properly configuring Directors, Storage Daemons, and File Daemons, along with well-designed jobs and retention policies, organizations achieve comprehensive data protection at scale. Rigorous testing of restore procedures ensures disaster recovery capabilities when needed most. Whether managing small networks or large data centers, Bacula's flexible architecture and mature feature set deliver the reliability and control required for critical backup infrastructure.