3
,修改配置
作为存储服务器兼控制台,现在需要依次对
bacula-dir.Conf
(管全局)
bacula.sd.conf
(管存储)和
bconsole.conf
(管控制台)配置文件进行修改。
bacula-dir.conf
是最复杂的一个文件,它一共有
10
个逻辑段:
director
(定义全局),
catalog
(定义日志),
jobdefs(
定义备份的默认值
)
,
job
(定义特定操作),
fileset
(定义备份哪些区域不备份哪些区域),
schedule
(定义备份时间),
pool
(定义备份介质),
client
(定义要备份的主机),
storage
(定义如何存储)
messages
(定义如何处理消息)
因为此文件比较复杂,所以我把我配置好的文件直接贴出来,一些特别重要的地方咱们拿出来讨论
Director { #
全局的一些配置
Name = RHEL5-dir
DIRport = 9101
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/var/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1 #
定义一次能处理的并发作业数
Password = "RTQVFEti4EAPrGLJV+xn+/7ScFU0D+iDs5OWCvy354uI" #
这个地方必须与控制台所在主机上的
bconsole.conf
一致,这里是本机
Messages = Daemon
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = RHEL5-fd #
如果本机也需备份就在后面去定义
RHEL5-fd
为本机
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = Default
Priority = 10
}
Job { #
定义一个任务
Name = "Client" #
任务的名称
后面咱们可以在
bacula
的控制台中看到
Client = Client #
引用后面定义的客户端“
Client
”,表示此任务对名字叫
client
主机进行操作
JobDefs = "DefaultJob"
Write Bootstrap = "/var/bacula/working/Client1.bsr" #
定义备份的引导信息放在什么地方
Level = Full #
定义备份类型为完全
FileSet = "Full Set" #
备份的范围根据后面定义的名叫“
Full Set
”的操作
Schedule = "WeeklyCycleAfterBackup" #
备份计划任务按
"WeeklyCycleAfterBackup"
定义的执行
}
Job {
Name = "BackupCatalog"
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
RunBeforeJob = "/etc/bacula/make_catalog_backup bacula bacula"
RunAfterJob = "/etc/bacula/delete_catalog_backup"
Write Bootstrap = "/var/bacula/working/BackupCatalog.bsr"
Priority = 11 # run after main backup
}
Job {
Name = "RestoreFiles"
Type = Restore
Client=RHEL5-fd #
这里就是指的
RHEL5
这台主机自己
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /bacula-restores
}
FileSet {
Name = "Full Set"
Include {
Options {
signature = MD5
}
File = /boot #
备份的范围,这里我根据需要只备份了
/boot
分区,如果要备份其他可加入相应路径
}
Exclude { #
排除的,不备份的内容
File = /proc
File = /tmp
File = /.journal
File = /.fsck
}
}
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 = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 23:10
}
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = /var/bacula/working/bacula.sql
}
}
Client {
Name = RHEL5-fd
Address = 192.168.0.5 #
指定了
RHEL5
这台主机的地址,如果有
DNS
可以写
FQDN
FDPort = 9102
Catalog = MyCatalog
Password = "f/4eSVt8B+tvY8fsWerClwGwWxnMRIgung8h+zWb4tRv" #
要和
RHEL5
上
bacula-fd.conf
的一致
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
Client {
Name = Client #
前面引用过的
client
就是在这定义的
Address = 192.168.0.6 #
告诉服务器
client
在什么地方
FDPort = 9102
Catalog = MyCatalog
Password = "f/4eSVt8B+tvY8fsWerClwGwWxnMRIgung8h+zWb4tRv2" #
要和
client
上
bacula-fd.conf
的一致
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
Storage { #
定义存储服务器
Name = File
Address = 192.168.0.5 #
告诉服务器数据存储在哪台机器上。这里是主机自己。
SDPort = 9103
Password = "oTJC6wYD/kTLcptwdReP/Gl7xxqngURQdZZfQINCeMzd" #
要和本机
bacula-sd.conf
上一致
Device = FileStorage
Media Type = File #
定义以文件方式存储
}
Catalog { #
关于日志和数据库的定义
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
}
Messages {
Name = Standard
mailcommand = "/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed
for %j\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/var/bacula/working/log" = all, !skipped
}
Messages {
Name = Daemon
mailcommand = "/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/var/bacula/working/log" = all, !skipped
}
Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
}
Pool {
Name = Scratch
Pool Type = Backup
}
Console {
Name = RHEL5-mon
Password = "YZDfclvKrfWVkmGdGtWygMOR8ZOX7XK7MYvaFd1dIraN"
CommandACL = status, .status
}
第二个文件
bacula-sd.conf
Storage { #
定义存储。本例中是自己
RHEL5
Name = RHEL5-sd
SDPort = 9103 #
存储端口
WorkingDirectory = "/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
Director {
Name = RHEL5-dir
Password = "oTJC6wYD/kTLcptwdReP/Gl7xxqngURQdZZfQINCeMzd" #
与
bacula-dir.conf
中对应的
Storage
项一致
}
Director {
Name = RHEL5-mon
Password = "xyqzFcPkpqwmQm7BD5OhegyynhOhFHcNZWoIfMZN2bY5"
Monitor = yes
}
Device {
Name = FileStorage
Media Type = File
Archive Device = /tmp/test #
定义备份到什么地方
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; #
如果设备可用,则读取
RemovableMedia = no;
AlwaysOpen = no;
}
Messages {
Name = Standard
director = RHEL5-dir = all
}
最后一个文件
bconsole.conf
Director {
Name = RHEL5-dir
DIRport = 9101
address = 192.168.0.5 #
服务器位置
Password = "RTQVFEti4EAPrGLJV+xn+/7ScFU0D+iDs5OWCvy354uI" #
与
bacula-dir.conf
中
director
中一致
}
现在启动进程
终于配置完毕,但还有关键的一步,添加存储介质
黄色的是要输入的部分。现在就已经进入到控制台了。
配置客户机(需要备份的
client
):
1,
编译安装
bacula
然后
make
和
make install
默认安装在
/etc/bacula/
目录下
1,
改配置文件
bacula-fd.conf
Director {
Name = RHEL5-dir #
与服务器上的
bacula-dir.conf
中一致
Password = "f/4eSVt8B+tvY8fsWerClwGwWxnMRIgung8h+zWb4tRv2" #
与服务器上的
bacula-dir.conf
中一致
}
Director {
Name = RHEL5-mon #
与服务器上的
bacula-dir.conf
中一致
Password = "yqzFcPkpqwmQm7BD5OhegyynhOhFHcNZWoIfMZN2bY5" #
与服务器上的
bacula-dir.conf
中一致
Monitor = yes
}
FileDaemon {
Name = Client #
指自己
FDport = 9102 #
监听端口
r
WorkingDirectory = /var/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
Messages {
Name = Standard
director = Client-dir = all, !skipped, !restored
}
客户端相对配置较简单。改这一个文件就行了。
然后启动进程
三,
验证
经过了艰苦的工作,现在到了享受结果的时候了(呵呵,这个东东我已经弄了
3
天了,痛苦呀)
咱们现在先备份
client
下的
/boot
目录吧
在
server
上
接着
可以通过
status
查看状态
呵呵,看见
OK
了吗,备份成功了哟
接下来咱们来做还原,首先咱们把
client
上的
/boot
中的文件删除掉
现在回到
server
上来还原(还是在控制台)
显示如下提示
接着标记要还原内容,并且执行
这个地方注意一下,如果要还原到
client
原位置则按以下步骤
现在再回到
client
下看看
哈哈,看见了吧,刚才删掉的文件现在全部回来了
四,
最后
因为手头上没有现成的资料,加上本人英语水平有限,有不足的地方还请大家谅解。