您的位置:首页 > 其它

备份与还原---bacula安装与配置

2012-09-10 16:15 531 查看
一、环境描述

两台测试机,都是CentOS 5.8 x64的系统。

Director+Storage+Consle:192.168.144.80

Client:192.168.144.113

Bacula软件版本:bacula-5.2.1(目前最高版本是5.2.10)

二、下载与安装

1、下载最新版bacula-5.2.10

wget http://sourceforge.net/projects/bacula/files/bacula/5.2.10/bacula-5.2.10.tar.gz/download

此次实验版本为bacula-5.2.1。

2、server端安装bacula(192.168.144.80)

2.1 bacula需要使用mysql数据库,存储任务信息。安装bacula之前需要安装mysql数据库。

yum -y install mysql mysql-devel mysql-server

2.2 安装完mysql之后,再进行bacula的安装。

tar xzvf bacula-5.2.1.tar.gz
cd bacula-5.2.1
./configure --prefix=/data/bacula-5.2.1 \
--with-bat \
--with-mysql=/usr/local/mysql && make && make install

说明:--with-bat参数表明支持bat的GUI图形用户界面,图形界面管理任务更方便。bat需要qt4的支持,yum安装即可。Gnome的图形界面在5.2以上版本已经不再支持。

2.3 为bacula创建mysql数据库以及授权。

注意:执行Mysql初始代码时,默认由空密码的root用户执行,因此要请确保Mysql数据库root密码为空。

cd /data/bacula-5.2.1/etc/
./grant_mysql_privileges
./create_mysql_database
./make_mysql_tables

2.4 客户端安装bacula。(192.168.144.113)

./configure --prefix=/usr/local/bacula-5.2.1 --enable-client-only && make && make install


三、bacula配置文件的配置

配置bacula备份系统,其实就是对Director端配置文件bacula-dir.conf、SD配置文件bacula-sd.conf、客户端FD配置文件bacula-fd.conf以及Console端配置文件bconsole.conf进行配置的过程。

配置文件之间的关系,如下图:




本次示例配置文件如下:

3.1 bconsole.conf的内容:

Director {
Name = backup80-dir
DIRport = 9101
address = localhost
Password = "HCKMc2rdoE/v4KYrzD5FpJc6MXrP+w67RPO6MqOrrJ/6"
}

3.2 bacula-sd.conf的内容:

Storage {
Name = backup80-sd
SDPort = 9103
WorkingDirectory = "/data/bacula-5.2.1/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}

Director {
Name = backup80-dir
Password = "BwRCJ6oSA/FzN0rUY3Vu8WpEyNXIH/ppq33y1uXOCPI2"
}

Director {
Name = backup80-mon
Password = "IzjtsscUhAXfE/yrR+D1cAqVR7Hi4rNn5w1PzICHCVk4"
Monitor = yes
}

Device {
Name = backup80-sd
Media Type = File
Archive Device = /backup
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}

Messages {
Name = Standard
director = backup80-dir = all
}

3.3 bacula-dir.conf的内容:

Director {
Name = backup80-dir
DIRport = 9101
QueryFile = "/data/bacula-5.2.1/etc/query.sql"
WorkingDirectory = "/data/bacula-5.2.1/var/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "HCKMc2rdoE/v4KYrzD5FpJc6MXrP+w67RPO6MqOrrJ/6"
Messages = Daemon
}

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

Job {
Name = "backup80-backup"
JobDefs = "DefaultJob"
}

Job {
Name = "web113-backup"
Client = web113-fd
JobDefs = "DefaultJob"
}

Job {
Name = "BackupCatalog"
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
RunBeforeJob = "/data/bacula-5.2.1/etc/make_catalog_backup.pl MyCatalog"
RunAfterJob  = "/data/bacula-5.2.1/etc/delete_catalog_backup"
Write Bootstrap = "/data/bacula-5.2.1/var/bacula/working/%n.bsr"
Priority = 11
}

Job {
Name = "RestoreFiles"
Type = Restore
Client=backup80-fd
FileSet="Full Set"
Storage = File
Pool = File
Messages = Standard
Where = /tmp/bacula-restores
}

FileSet {
Name = "Full Set"
Include {
Options {
signature = MD5; Compression=GZIP;
}
File = /data/bacula-5.2.1/sbin
File = /etc
}
}

Schedule {
Name = "WeeklyCycle"
Run = Full 1st sun at 02:05
Run = Differential 2nd-5th sun at 02:05
Run = Incremental mon-sat at 02:05
}

Schedule {
Name = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 02:20
}

FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/data/bacula-5.2.1/var/bacula/working/bacula.sql"
}
}

Client {
Name = backup80-fd
Address = localhost
FDPort = 9102
Catalog = MyCatalog
Password = "61L0ZhxipREqc8v7d1UAHgoM3PgQT7BUxrE2+co4EXJa"
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}

Client {
Name = web113-fd
Address = 192.168.144.113
FDPort = 9102
Catalog = MyCatalog
Password = "abc123456"
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}

Storage {
Name = File
Address = 192.168.144.80
SDPort = 9103
Password = "BwRCJ6oSA/FzN0rUY3Vu8WpEyNXIH/ppq33y1uXOCPI2"
Device = backup80-sd

Media Type = File
}

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

Messages {
Name = Standard
mailcommand = "/data/bacula-5.2.1/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/data/bacula-5.2.1/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = pengcheng.xie@ipinyou.com = all, !skipped
operator = pengcheng.xie@ipinyou.com = mount
console = all, !skipped, !saved
append = "/data/bacula-5.2.1/var/bacula/working/log" = all, !skipped
catalog = all
}

Messages {
Name = Daemon
mailcommand = "/data/bacula-5.2.1/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = pengcheng.xie@ipinyou.com = all, !skipped
console = all, !skipped, !saved
append = "/data/bacula-5.2.1/var/bacula/working/log" = all, !skipped
}

Pool {
Name = File
Pool Type = Backup
Recycle = yes
Volumes
AutoPrune = yes
Volume Retention = 365 days
reasonable
}

Console {
Name = backup80-mon
Password = "PpVNZcD9+QusdjJS9Sr9/H+wMfAdzUtc8eUcBF/YbdFs"
CommandACL = status, .status
}


四、启动bacula

开启bacula程序有两种方式:

4.1 启动bacula所有服务。

/data/bacula-5.2.1/sbin/bacula start

4.2 单独启动bacula某一服务。

/data/bacula-5.2.1/sbin/bacula-dir start
/data/bacula-5.2.1/sbin/bacula-sd start
/data/bacula-5.2.1/sbin/bacula-fd start

第一种开启方式开启了所有能开启的bacula服务:dir、sd和fd。但是根据实际情况,dir、sd、fd往往不在同一台服务器上,有时没有必要在一台服务器上开启所有服务。

根据本次实验的环境来说:

在192.168.144.80上需要开启bacula-sd和bacula-dir。而作为被备份的一端,192.168.144.113上只需要开启bacula-fd即可。

在192.168.144.80上执行:

/data/bacula-5.2.1/sbin/bacula-dir start
/data/bacula-5.2.1/sbin/bacula-sd start

在192.168.144.113上执行:

/usr/local/bacula-5.2.1/sbin/bacula-fd start

查看进程和端口是否正确。如果程序没有正常开启,看一下log,进行排错。
本文出自 “运维之道” 博客,请务必保留此出处http://pesen.blog.51cto.com/4575807/986549
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: