Bacula на Debian Jessie

Добавляем репозиторий
vim /etc/apt/sources.list:

deb http://ftp.ua.debian.org/debian/ jessie main


aptitude update
aptitude -y install bacula-common-mysql bacula-console bacula-director-mysql bacula-fd bacula-sd-mysql sqlite3 zendframework unzip mysql-server apache2 iptables-persistent

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

Director {
  Name = localhost-dir
  DIRport = 9101
  QueryFile = "/etc/bacula/scripts/query.sql"
  WorkingDirectory = "/var/lib/bacula"
  PidDirectory = "/var/run/bacula"
  Maximum Concurrent Jobs = 1
  Password = "mypassword"
  Messages = Daemon
  DirAddress = 127.0.0.1
}

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Client = localhost-fd
  FileSet = "Full Set"
  Schedule = "WeeklyCycle"
  Storage = File
  Messages = Standard
  Pool = File
  Priority = 10
  Write Bootstrap = "/var/lib/bacula/%c.bsr"
}

Job {
  Name = "localhost"
  JobDefs = "DefaultJob"
}

Job {
  Name = "RestoreFiles"
  Type = Restore
  Client = localhost-fd
  FileSet = "Full Set"
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /nonexistant/path/to/file/archive/dir/bacula-restores
}

Storage {
  Name = File
  Address = example.com
  SDPort = 9103
  Password = "mypassword"
  Device = FileStorage
  Media Type = File
}

Catalog {
  Name = MyCatalog
  dbname = "bacula"; dbuser = "bacula"; dbpassword = "baculadbpasswd"
}

Console {
  Name = localhost-mon
  Password = "mypassword"
  CommandACL = status, .status
}
#Прикрепляем конфигурационные файлы для наших клиентов
@/etc/bacula/localhost.conf

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

Storage {
  Name = example.com-sd
  SDPort = 9103
  WorkingDirectory = "/var/lib/bacula"
  Pid Directory = "/var/run/bacula"
  Maximum Concurrent Jobs = 20
#  SDAddress = 127.0.0.1
}
Director {
  Name = example.com-dir
  Password = "mypassword"
}

Director {
  Name = example.com-mon
  Password = "mypassword"
  Monitor = yes
}

Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /res/bacula #папка, в которую будем складывать резервные копии
  LabelMedia = yes;
  Random Access = Yes;
  AutomaticMount = yes;
  RemovableMedia = no;
  AlwaysOpen = no;
}

Device {
        Name = localhost
        Media Type = File
        Archive Device = /res/bacula
        LabelMedia = yes;
        Random Access = yes;
        AutomaticMount = yes;
        RemovableMedia = no;
        AlwaysOpen = no;
}

Клиентский конфигурационный файл
vim /etc/bacula/localhost.conf:

Client {
        Name = localhost-fd
        Address = 127.0.0.1
        FDPort = 9102
        Catalog = MyCatalog
        Password = "mypassword"
        File Retention = 30 days
        Job Retention = 60 day
        AutoPrune = yes
}

Pool {
        Name = localhost
        Pool Type = Backup
        LabelFormat = localhost
        Recycle = yes
        Recycle Oldest Volume = yes
        AutoPrune = yes
        Volume Retention = 30 days
        Maximum Volume Bytes = 30G
        Maximum Volumes = 10
        Maximum Volume Jobs = 1
        Purge Oldest Volume = yes
}

FileSet {
        Name = "localhost-set"
        Include {
                Options {
                        Signature=MD5
                        compression = GZIP
                        }
                File = /
                }
        Exclude {
                File = /tmp
                File = /var/tmp
                File = /proc
                File = /sys
                File = /run
                File = /lost+found
                }
}

Job {
        Name = "localhost-job"
        Type = Backup
        Level = Full
        Client = localhost-fd
        FileSet = "localhost-set"
        Storage = localhost
        Schedule = "localhost"
        Enabled = yes
        Rerun Failed Levels = yes
        Pool = localhost
        Messages = Standard
}

Storage {
        Name = localhost
        Address = 127.0.0.1
        SDPort = 9103
        Password = "mypasswd"
        Device = localhost
        Media Type = File
        Maximum Concurrent Jobs = 2
}

Schedule {
        Name = "localhost"
        Run = Full 1st sat at 2:00
        Run = Differential 2nd-5th sat at 2:00
        Run = Incremental mon-fri at 3:00
}

Делаем базу данных для bacula
vim /usr/share/bacula-director/make_mysql_tables:

##!/bin/sh
#bindir=/usr/bin
#PATH="$bindir:$PATH"
#db_name=${db_name:-XXX_DBNAME_XXX}
#if mysql -D ${db_name} $* -f <<END-OF-DATA
#END-OF-DATA
#then
#   echo "Creation of Bacula MySQL tables succeeded."
#else
#   echo "Creation of Bacula MySQL tables failed."
#fi
#exit 0

mysql -u root -p
create database bacula;
grant all privileges on bacula.* to 'bacula'@'localhost' identified by 'baculadbpasswd';
use bacula;
source /usr/share/bacula-director/make_mysql_tables
quit

Настраиваем клиент
vim /etc/bacula/bacula-fd.conf:

Director {
  Name = localhost-dir
  Password = "mypassword"
}

Director {
  Name = localhost-mon
  Password = "mypassword"
  Monitor = yes
}

FileDaemon {
  Name = localhost-fd
  FDport = 9102
  WorkingDirectory = /var/lib/bacula
  Pid Directory = /var/run/bacula
  Maximum Concurrent Jobs = 20
  FDAddress = 127.0.0.1
}

Messages {
  Name = Standard
  director = localhost-dir = all, !skipped, !restored
}

vim /etc/bacula/bconsole.conf:

Director {
  Name = localhost-dir
  DIRport = 9101
  address = 127.0.0.1
  Password = "mypassword"
}

invoke-rc.d bacula-director restart
invoke-rc.d bacula-sd restart
invoke-rc.d bacula-fd restart

Устанавливаем webacula веб интерфейс для bacula
wget https://github.com/tim4dev/webacula/archive/master.zip
unzip master.zip
mv webacula-master /var/www/webacula

Проверяем зависимости устанавливаем, чего нет
php5 /var/www/webacula/install/check_system_requirements.php

vim /var/www/webacula/application/config.ini:

db.config.host = localhost
db.config.username = bacula
db.config.password = "baculadbpasswd"
db.config.dbname = bacula
def.timezone = "Europe/Kiev"
locale = "ru"
bacula.sudo = ""
bacula.bconsole = "/usr/sbin/bconsole"

vim /var/www/webacula/install/db.conf:

db_name="bacula"
db_user="bacula"
db_pwd="baculadbpasswd"
webacula_root_pwd="mypasswd" #пароль от учетной записи root на веб интерфейс

usermod -a -G bacula www-data
chown root:bacula /usr/sbin/bconsole
chmod u=rwx,g=rx,o= /usr/sbin/bconsole
chown root:bacula /etc/bacula/bconsole.conf
chmod u=rw,g=r,o= /etc/bacula/bconsole.conf

Создаем таблицы для webacula
./var/www/webacula/install/MySql/10_make_tables.sh
./var/www/webacula/install/MySql/20_acl_make_tables.sh

Настраиваем apache
vim /etc/apache2/conf-enabled/webacula.conf

Alias /webacula /var/www/webacula/html
<Directory "/var/www/webacula/html">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

vim /var/www/webacula/html/index.php:

define('BACULA_VERSION', 14);

chown -R www-data:www-data /var/www/webacula/
invoke-rc.d apache2 reload

Открываем порты
iptables -I INPUT 1 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I INPUT 2 -s 192.168.0.0/24 -d 192.168.0.1 -i eth0 -p tcp -m state --state NEW -m multiport --dports 80,9101:9103 -j ACCEPT
invoke-rc.d netfilter-persistent save

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *