В этой статье опишу свой экспириэнс с таким продуктом как bacula. Начну с того, что в нашей компании этот продукт уже был внедрен, но внедрен очень странно 0_о, а именно из бэкапа нельзя восстановить данные. Даже и не знаю, как эту ситуацию обозвать можно)). Отпишу сразу, что не буду останавливаться много на моментах, которые описаны в документации.
Опишу что мы имеем:
- Ленточная библиотека IBM TS 3100, со scsi интерфейсом.
- Сервер с осью CentOS 5 x86_64
- 20 касет Ultrium 3, перезаписываемые.
- Bacula 5.0.3, была установлена из исходников с поддержкой mysq c причем скомпилировано все с кучей параметров(не знаю почему, но не перенашу это, ведь на это нет объективных причин).(Будем это исправлять)
- Все демоны установлены на одном ПК, хотя есть отдельный сервер БД mysql.(Будем это исправлять)
- Бэкапы бесполезны, т.к. восстановить из архива нельзя(опишу ошибки ниже)(Будем это исправлять)
С чего все началось
Всех больше бесило вот это: Restore OK -- warning file count mismatch.11-Jan 15:11 logserv-dir JobId 2986: Start Restore Job RestoreFiles.2011-01-11_15.11.07_2111-Jan 15:11 logserv-dir JobId 2986: Using Device "ULT3580-TD3"11-Jan 15:11 logserv-sd JobId 2986: 3307 Issuing autochanger "unload slot 20, drive 0" command.11-Jan 15:12 logserv-sd JobId 2986: 3304 Issuing autochanger "load slot 19, drive 0" command.11-Jan 15:13 logserv-sd JobId 2986: 3305 Autochanger "load slot 19, drive 0", status is OK.11-Jan 15:13 logserv-sd JobId 2986: Ready to read from volume "163JJJL3" on device "ULT3580-TD3" (/dev/IBMtape0n).11-Jan 15:13 logserv-sd JobId 2986: Forward spacing Volume "163JJJL3" to file:block 1021:0.11-Jan 15:37 logserv-sd JobId 2986: End of Volume at file 407 on device "ULT3580-TD3" (/dev/IBMtape0n), Volume "163JJJL3"11-Jan 15:37 logserv-sd JobId 2986: End of all volumes.11-Jan 15:37 logserv-dir JobId 2986: Bacula logserv-dir 5.0.3 (04Aug10): 11-Jan-2011 15:37:18Build OS: x86_64-unknown-linux-gnu redhatJobId: 2986Job: RestoreFiles.2011-01-11_15.11.07_21Restore Client: atx-fdStart time: 11-Jan-2011 15:11:09End time: 11-Jan-2011 15:37:18Files Expected: 1Files Restored: 0Bytes Restored: 0Rate: 0.0 KB/sFD Errors: 0FD termination status: OKSD termination status: OKTermination: Restore OK -- warning file count mismatch
Начал рыть сайт bacula и гуглить, чтобы понять в чем все таки дело. Так же начал изучать маны от ленточной библиотеки. Первое что пришло в голову, это обновить драйвер от библиотеки, который лежит на сайте IBM(lin_tape), в последствии из списков рассылки и манов вычитал что нужно вообще использовать стандартный линуксовый драйвер, т.к. bacula работает через системный вызовы *NIX.
Удаление драйвера от IBM
- rmmod lin_tape (выгружаем модуль библиотеки)
- modprobe st (подгружаем стандартный модуль)
- Сносим нафиг это добро rpm -e lin_taped-1.27.0-1 lin_tape-1.27.0-1
- Правим конфиг, а именно: ставим Archive Device = /dev/st* вместо Archive Device = /dev/IBMtape* (Т.к. сменили дрова)
- Теперь можно прогнать тесты (В моем случае команда btape ULT3580-TD3).
- После этого я забэкапил инфу и смог ее восстановить.(Вот что мы и хотели сделать!!!)
Устанавливаем Bacula
Я сторонник того, что лучше брать все из первоисточника, т.е. ман по установке взял с официальной википедии проекта, там нет ничего сложного.
Кладем базу на другой хост
В официальных howto не нашел описания как это сделать, поэтому опишу это. Задаче просатая, нужно лишь поменять в скриптах создания БД, таблиц и т.д. ключи к команде mysql. Мой пример:
[root@logserv bacula]# [root@logserv bacula]# head ./make_mysql_tables
#!/bin/sh
#
# shell script to create Bacula MySQL tables
#
bindir=/usr/bin
PATH="$bindir:$PATH"
db_name=${db_name:-bacula}
if mysql -h -u -p -f <
#!/bin/sh
#
# shell script to create Bacula MySQL tables
#
bindir=/usr/bin
PATH="$bindir:$PATH"
db_name=${db_name:-bacula}
if mysql -h
так же в конфиге директора не забываем указать хост СУБД.
Мои конфиги
[root@logserv bacula]# cat ./bacula-sd.conf
#
# Default Bacula Storage Daemon Configuration file
#
# For Bacula release 5.0.3 (30 August 2010) -- redhat
#
# You may need to change the name of your tape drive
# on the "Archive Device" directive in the Device
# resource. If you change the Name and/or the
# "Media Type" in the Device resource, please ensure
# that dird.conf has corresponding changes.
#
Storage { # definition of myself
Name = logserv-sd
SDPort = 9103 # Director's port
WorkingDirectory = "/var/lib/bacula"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
#
# List Directors who are permitted to contact Storage daemon
#
Director {
Name = logserv-dir
Password = "1234"
}
#
# Restricted Director, used by tray-monitor to get the
# status of the storage daemon
#
Director {
Name = logserv-mon
Password = "5678"
Monitor = yes
}
#
# Note, for a list of additional Device templates please
# see the directory/examples/devices
# Or follow the following link:
# http://bacula.svn.sourceforge.net/viewvc/bacula/trunk/bacula/examples/devices/
#
#
# Devices supported by this Storage daemon
# To connect, the Director's bacula-dir.conf must have the
# same Name and MediaType.
#
Device {
Name = FileStorage
Media Type = File
Archive Device = /var/spool/bacula
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
}
#
# An autochanger device with two drives
#
Autochanger {
Name = Autochanger
Device = ULT3580-TD3
Changer Command = "/usr/lib64/bacula/mtx-changer %c %o %S %a %d"
Changer Device = /dev/sg4
}
#
# A Linux or Solaris LTO-3 tape drive
#
Device {
Name = ULT3580-TD3
Media Type = LTO-3
Archive Device = /dev/st0
AutomaticMount = yes; # when device opened, read it
AlwaysOpen = yes;
RemovableMedia = yes;
RandomAccess = no;
Maximum File Size = 4GB
# Changer Command = "/usr/lib64/bacula/mtx-changer %c %o %S %a %d"
# Changer Device = /dev/sg4
AutoChanger = yes
# Enable the Alert command only if you have the mtx package loaded
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
}
#
# Send all messages to the Director,
# mount messages also are sent to the email address
#
Messages {
Name = Standard
director = logserv-dir = all
}
#
# Default Bacula Storage Daemon Configuration file
#
# For Bacula release 5.0.3 (30 August 2010) -- redhat
#
# You may need to change the name of your tape drive
# on the "Archive Device" directive in the Device
# resource. If you change the Name and/or the
# "Media Type" in the Device resource, please ensure
# that dird.conf has corresponding changes.
#
Storage { # definition of myself
Name = logserv-sd
SDPort = 9103 # Director's port
WorkingDirectory = "/var/lib/bacula"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
#
# List Directors who are permitted to contact Storage daemon
#
Director {
Name = logserv-dir
Password = "1234"
}
#
# Restricted Director, used by tray-monitor to get the
# status of the storage daemon
#
Director {
Name = logserv-mon
Password = "5678"
Monitor = yes
}
#
# Note, for a list of additional Device templates please
# see the directory
# Or follow the following link:
# http://bacula.svn.sourceforge.net/viewvc/bacula/trunk/bacula/examples/devices/
#
#
# Devices supported by this Storage daemon
# To connect, the Director's bacula-dir.conf must have the
# same Name and MediaType.
#
Device {
Name = FileStorage
Media Type = File
Archive Device = /var/spool/bacula
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
}
#
# An autochanger device with two drives
#
Autochanger {
Name = Autochanger
Device = ULT3580-TD3
Changer Command = "/usr/lib64/bacula/mtx-changer %c %o %S %a %d"
Changer Device = /dev/sg4
}
#
# A Linux or Solaris LTO-3 tape drive
#
Device {
Name = ULT3580-TD3
Media Type = LTO-3
Archive Device = /dev/st0
AutomaticMount = yes; # when device opened, read it
AlwaysOpen = yes;
RemovableMedia = yes;
RandomAccess = no;
Maximum File Size = 4GB
# Changer Command = "/usr/lib64/bacula/mtx-changer %c %o %S %a %d"
# Changer Device = /dev/sg4
AutoChanger = yes
# Enable the Alert command only if you have the mtx package loaded
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
}
#
# Send all messages to the Director,
# mount messages also are sent to the email address
#
Messages {
Name = Standard
director = logserv-dir = all
}
Конфиг директора
[root@logserv bacula]# cat ./bacula-dir.conf
#
# Default Bacula Director Configuration file
#
# The only thing that MUST be changed is to add one or more
# file or directory names in the Include directive of the
# FileSet resource.
#
# For Bacula release 5.0.3 (30 August 2010) -- redhat
#
# You might also want to change the default email address
# from root to your address. See the "mail" and "operator"
# directives in the Messages resource.
#
Director { # define myself
Name = logserv-dir
DIRport = 9101 # where we listen for UA connections
QueryFile = "/usr/lib64/bacula/query.sql"
WorkingDirectory = "/var/lib/bacula"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "password" # Console password
Messages = Daemon
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = logserv-fd
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
####All clients append to this file
@/etc/bacula/include/clients.conf
####All jobs append to this file
@/etc/bacula/include/jobs.conf
####All filesets append to this file
@/etc/bacula/include/filesets.conf
####All filesets append to this file
@/etc/bacula/include/scheldure.conf
# Definition of file storage device
Storage {
Name = File
Address = logserv # N.B. Use a fully qualified name here
SDPort = 9103
Password = "blablabla"
Device = FileStorage
Media Type = File
}
Storage {
Name = ULT3580-TD3
Address = logserv # N.B. Use a fully qualified name here
SDPort = 9103
Password = "blablabla" # password for Storage daemon
Device = ULT3580-TD3 # must be same as Device in Storage daemon
Media Type = LTO-3 # must be same as MediaType in Storage daemon
Autochanger = yes # enable for autochanger device
}
# Generic catalog service
Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = "dbi:mysql"; dbaddress = 127.0.0.1; dbport =
dbname = "bacula"; dbuser = "user"; dbpassword = "password"; dbaddress= "host.example.com" ;
}
# Reasonable message delivery -- send most everything to email address
# and to the console
Messages {
Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
# to replace the %r in the from field (-f part) with a single valid
# email address in both the mailcommand and the operatorcommand.
# What this does is, it sets the email address that emails would display
# in the FROM field, which is by default the same email as they're being
# sent to. However, if you send email to more than one address, then
# you'll have to set the FROM address manually, to a single address.
# for example, a 'no-reply@mydomain.com', is better since that tends to
# tell (most) people that its coming from an automated source.
#
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = streamer@noc.example.com = all, !skipped
operator = streamer@noc.example.com = mount
console = all, !skipped, !saved
#
# WARNING! the following will create a file that you must cycle from
# time to time as it will grow indefinitely. However, it will
# also keep all your messages if they scroll off the console.
#
append = "/var/lib/bacula/log" = all, !skipped
catalog = all
}
#
# Message delivery for daemon messages (no job).
Messages {
Name = Daemon
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = streamer@noc.example.com = all, !skipped
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}
#Include pools config
@/etc/bacula/include/pools.conf
#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
Name = logserv-mon
Password = "blablabla"
CommandACL = status, .status
}
#
# Default Bacula Director Configuration file
#
# The only thing that MUST be changed is to add one or more
# file or directory names in the Include directive of the
# FileSet resource.
#
# For Bacula release 5.0.3 (30 August 2010) -- redhat
#
# You might also want to change the default email address
# from root to your address. See the "mail" and "operator"
# directives in the Messages resource.
#
Director { # define myself
Name = logserv-dir
DIRport = 9101 # where we listen for UA connections
QueryFile = "/usr/lib64/bacula/query.sql"
WorkingDirectory = "/var/lib/bacula"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "password" # Console password
Messages = Daemon
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = logserv-fd
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
####All clients append to this file
@/etc/bacula/include/clients.conf
####All jobs append to this file
@/etc/bacula/include/jobs.conf
####All filesets append to this file
@/etc/bacula/include/filesets.conf
####All filesets append to this file
@/etc/bacula/include/scheldure.conf
# Definition of file storage device
Storage {
Name = File
Address = logserv # N.B. Use a fully qualified name here
SDPort = 9103
Password = "blablabla"
Device = FileStorage
Media Type = File
}
Storage {
Name = ULT3580-TD3
Address = logserv # N.B. Use a fully qualified name here
SDPort = 9103
Password = "blablabla" # password for Storage daemon
Device = ULT3580-TD3 # must be same as Device in Storage daemon
Media Type = LTO-3 # must be same as MediaType in Storage daemon
Autochanger = yes # enable for autochanger device
}
# Generic catalog service
Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = "dbi:mysql"; dbaddress = 127.0.0.1; dbport =
dbname = "bacula"; dbuser = "user"; dbpassword = "password"; dbaddress= "host.example.com" ;
}
# Reasonable message delivery -- send most everything to email address
# and to the console
Messages {
Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
# to replace the %r in the from field (-f part) with a single valid
# email address in both the mailcommand and the operatorcommand.
# What this does is, it sets the email address that emails would display
# in the FROM field, which is by default the same email as they're being
# sent to. However, if you send email to more than one address, then
# you'll have to set the FROM address manually, to a single address.
# for example, a 'no-reply@mydomain.com', is better since that tends to
# tell (most) people that its coming from an automated source.
#
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = streamer@noc.example.com = all, !skipped
operator = streamer@noc.example.com = mount
console = all, !skipped, !saved
#
# WARNING! the following will create a file that you must cycle from
# time to time as it will grow indefinitely. However, it will
# also keep all your messages if they scroll off the console.
#
append = "/var/lib/bacula/log" = all, !skipped
catalog = all
}
#
# Message delivery for daemon messages (no job).
Messages {
Name = Daemon
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = streamer@noc.example.com = all, !skipped
console = all, !skipped, !saved
append = "/var/lib/bacula/log" = all, !skipped
}
#Include pools config
@/etc/bacula/include/pools.conf
#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
Name = logserv-mon
Password = "blablabla"
CommandACL = status, .status
}
Вот и все, у нас все работает.))
Ссылки:
Прикопипасте ссылку на источник оставлять обязательно)
Статья гуд! Тоже бакулу ковыряю с таким же тейпером на Centos 5.6. Какие настройки у тебя на клиентах и джобах в приклюденных файлах?
ОтветитьУдалить####All clients append to this file
@/etc/bacula/include/clients.conf
####All jobs append to this file
@/etc/bacula/include/jobs.conf
####All filesets append to this file
@/etc/bacula/include/filesets.conf
####All filesets append to this file
@/etc/bacula/include/scheldure.conf
cat ./jobs.conf
ОтветитьУдалить# Backup the catalog database (after the nightly save)
Job {
Name = "zabbixdbfull"
Type = Backup
FileSet="ZabbixDB"
Level = Full
Storage = ULT3580-TD3
Pool = databases
Schedule = "MonthFull"
ClientRunBeforeJob = "/var/db/mysql/zabbix/backup.sh"
ClientRunAfterJob = "/var/db/mysql/zabbix/afterbackup.sh"
Write Bootstrap = "/var/lib/bacula/%c.bsr"
Priority = 10 # run after main backup
Client = "mdb-fd"
#Pool = databases
Messages = Standard
}
JobDefs {
Name = "Default"
Type = Backup
Level = Incremental
FileSet = "Default Set"
Schedule = "WeeklyCycle"
Storage = ULT3580-TD3
Messages = Standard
Pool = Default
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
#
# Define the main nightly save backup job
# By default, this job will back up to disk in /tmp
Job {
Name = "Pent"
Client = "pent-fd"
JobDefs = "Default"
}
....
....
Job {
Name = "zabbix-etc"
Client = "zabbix-fd"
Type = Backup
Level = Incremental
FileSet = "etc"
Schedule = "WeeklyCycle"
Storage = ULT3580-TD3
Messages = Standard
Pool = Default
Write Bootstrap = "/var/lib/bacula/%c.bsr"
}
cat ./clients.conf
ОтветитьУдалить# Client (File Services) to backup
Client {
Name = logserv-fd
Address = logserv
FDPort = 9102
Catalog = MyCatalog
Password = "blablabla" # password for FileDaemon
# File Retention = 30 days # 30 days
# Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
Client {
Name = pent-fd
Address = pent
FDPort = 9102
Catalog = MyCatalog
Password = "blablabla+blablabla" # password for FileDaemon
# File Retention = 30 days # 30 days
# Job Retention = 6 months # six months
AutoPrune = no # Prune expired Jobs/Files
}
...
...
....
cat ./filesets.conf | grep -v ^'#' | grep -v $^
ОтветитьУдалитьFileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/var/lib/bacula/bacula.sql"
}
}
FileSet {
Name = "ZabbixDB"
Include {
Options {
signature = MD5
}
File = "/var/db/mysql/zabbix/backup.sql"
}
}
FileSet {
Name = "etc"
Include {
Options {
signature = MD5
}
File = /etc
File = /usr/local/etc
}
}