前面文章介绍了bacula有5个组成部分,在实际的应用中,没有必要将5个部分分别放在不同的服务器上,它们之间的某些部分是可以合并的,常见的bacula部署结构有如下几种:
Director与SD以及Console在一台机器上,而客户端FD在另外一台机器上,当然客户端FD可以有一台或者多台上。
Director与Console在一台机器上,SD在一台机器上,客户端FD在一台或者多台上。
Director与客户端FD、SD以及Console端都在一台机器上,也就是服务器自己备份自己,数据保存在本机。
本文介绍的部署方案为最后一种,
Director与客户端FD、SD以及Console端都在一台机器上,也就是服务器自己备份自己,数据保存在本机。
一、Bacula服务端配置
作为存储服务器兼控制台,现在需要依次对bconsole.conf(控制台)、bacula-dir.conf(全局)和bacula-sd.conf(存储)配置文件进行修改。
1、更改bconsole.conf文件
cd /opt/bacula/etc
vim bconsole.conf
Director {
Name =bacula-dir#控制端名称,在bacula-dir.conf和bacula-sd.conf文件中的director段都会被用到
DIRport =9101
address =193.168.3.59#可以写IP地址,也可以写hostname,不过如果写hostname的话,要在hosts文件中添加相应的项目
Password ="123456"#控制端密码文件与bacula-dir中的director中的password要相同
}
2、
2. 配置Director端
在bacula-dir.conf中共有10个逻辑段:
- Director 定义全局设置
- Jobdefs 定义执行任务的一些共同属性,可以让任务继承,如果有冲突则以job中的为准。
- job 自定义一个备份或恢复的任务
- Fileset 定义备份哪些数据,不备份哪些数据
- Sehedule 定义备份时间策略
- Client 定义需要被备份的主机地址,也就是客户端地址
- Storage 定义数据的存储方式
- Catalog 定义后台数据库
- Message 定义发送日志报告和记录日志的位置
- Pool 定义供job使用的池属性 下面是一个已经配置好的文件
Director { #定义Bacula的全局配置
Name = ubuntu-dir
DIRport = 9101
QueryFile = "/usr/local//bacula/bin/query.sql"
WorkingDirectory = "/usr/local//bacula/bin/working"
PidDirectory = "/usr/local//bacula/bin/working"
Maximum Concurrent Jobs = 1 #定义一次能处理的最大并发数
Password = "123456" # Console password 控制密码,这个密码必须与bconsole.conf文件中对应的Director逻辑段密码相同
Messages = Daemon #定义日志输出方式,“Daemon”在下面的Messages逻辑段中进行了定义
}
#自动生成
JobDefs { #定义执行任务的一些默认属性,后面定义的job可以继承,但是如果有冲突以job中为准
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = ubuntu-fd
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/usr/local//bacula/bin/working/%c.bsr"
}
#自动生成
Job { #定义一个名为backupclient1的增量备份的任务,defaultJob中定义的是incremental
Name = "BackupClient1"
JobDefs = "DefaultJob"
}
#自动生成
#Job { #这个任务是新增的,不同的是级别为差异备份。
#Name = "BackupClient2"
#Client = server2-fd
#JobDefs = "DefaultJob"
#Level = Differential
#}
#自动生成
Job {
Name = "BackupCatalog"
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
# This creates an ASCII copy of the catalog
# Arguments to make_catalog_backup.pl are:
# make_catalog_backup.pl <catalog-name>
RunBeforeJob = "/usr/local/bacula/etc/make_catalog_backup.pl MyCatalog"
# This deletes the copy of the catalog
RunAfterJob = "/usr/local/bacula/etc/delete_catalog_backup"
Write Bootstrap = "/usr/local/bacula/opt/bacula/working/%n.bsr"
Priority = 11 # run after main backup
}
#自动生成
Job { #定义一个还原任务
Name = "RestoreFiles"
Type = Restore
Client=ubuntu-fd
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /tmp/bacula-restores #指定默认恢复数据到这个路径
}
#自定义
#Job { #自定义一个备份任务,可以有多个
# Name = "FullBackup" #备份任务名称,随便写
# Client = client_fd #指定要备份的客户端主机,client_fd在后面Client逻辑段中进行定义
# Level = Full #定义备份的级别,Incremental为增量备份。Level的取值#可为Full(完全备份)、Incremental(增量备份)和#Differential(差异备份),如果第一#次没做完全备份,则先进>行完全备份后再执行Incremental
# Type = Backup #定义Job的类型,“backup”为备份任务,可选的类型还有restore和verify等
# FileSet = "Full Set" #指定要备份的客户端数据,在后面FileSet逻辑段中进行定义
# Schedule = "WeeklyCycle" #指定这个备份任务的执行时间策略,在后面的Schedule逻辑段中行了定义
# Storage = File #指定备份数据的存储路径与介质,在后面的Storage逻辑段中进行定
# Messages = Standard
# Pool = File #指定备份使用的pool属性,在后面的Pool逻辑段中进行定义。
# Write Bootstrap = "/usr/local//bacula/working/client_fd.bsr" #指定备份的引导信息路径,可以自定义
#}
#自动生成
FileSet { #定义一个名为"Full Set"的备份资源,也就是指定需要备份哪些数据,需要排除哪些数据等,可以指定多个FileSet
Name = "Full Set"
Include {
Options {
signature = MD5; #表示使用MD5签名
}
File = "/usr/local//bacula/bin" #指定客户端FD需要备份的文件目录
}
Exclude { #通过Exclude排除不需要备份的文件或者目录,可根据具体情况修改
File = /usr/local//bacula/working
File = /tmp
File = /proc
File = /tmp
File = /.journal
File = /.fsck
}
}
#自定义
#FileSet {
# Name = "Client_epsi"
# Include {
# Options {
# signature = MD5; #表示使用MD5签名
# Compression=GZIP; #表示使用并压缩
# }
# File = "/usr/local//bacula/working/epsi"
# }
# Exclude {
# File = /usr/local//bacula/working
# File = /tmp
# File = /proc
# File = /tmp
# File = /.journal
# File = /.fsck
# }
#}
#自动生成
Schedule { #定义一个备份任务调度策略
Name = "WeeklyCycle"
Run = Full 1st sun at 23:05 #第一周的周日晚23:05分进行完全备份
Run = Differential 2nd-5th sun at 23:05 #第2~5周的周日晚23:05进行差异备份
Run = Incremental mon-sat at 23:05 #所有周一至周六晚23:05分进行增量备份
}
#自动生成
Schedule { #定义一个WeeklyCycleAfterBackup备份策略
Name = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 23:10
}
#自动生成
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/usr/local//bacula/bin/working/bacula.sql"
}
}
#自动生成
Client { #Client用来定义备份哪个客户端FD的数据
Name = ubuntu-fd #Clinet的名称,可以在前面的Job中调用
Address = 193.168.3.59 #要备份的客户端FD主机的IP地址,也可以写hostname,不过如果写hostname的话,要在hosts文件中添加相应的项目
FDPort = 9102 #与客户端FD通信的端口
Catalog = MyCatalog #使用哪个数据库存储信息,“MyCatalog”在后面的MyCatalog逻辑段中进定义
Password = "123456" #Director端与客户端FD的验证密码,这个值必须与客户端FD配置文件bacula-fd.conf中密码相同
File Retention = 30 days #指定保存在数据库中的记录多久循环一次,这里是30天,只影响数>据库中的记录不影响备份的文件
Job Retention = 6 months #指定Job的保持周期,应该大于File Retention指定的值
AutoPrune = yes #当达到指定的保持周期时,是否自动删除数据库中的记录,yes表示自动清除过期的Job
}
#自动生成
Storage { #Storage用来定义将客户端的数据备份到哪个存储设备上
Name = File
Address = 193.168.3.59 #指定存储端SD的IP地址,也可以写hostname,不过如果写hostname的话,要在hosts文件中添加相应的项目
SDPort = 9103 #指定存储端SD通信的端口
Password = "123456" #这个值必须与存储端SD(这里是server)的配置文件bacula-sd.conf中Director逻辑段密码相同
Device = FileStorage #指定数据备份的存储介质,必须与存储端SD(这里是server)的bacula-sd.conf配置文件中的“Device” 逻辑段的“Name”项名称相同
Media Type = File #指定存储介质的类别,必须与存储端SD(这里是server)的bacula-sd.conf配置文件中的“Device” 逻辑段的“Media Type”项名称相同
}
#自动生成
Catalog { #Catalog逻辑段用来定义关于日志和数据库设定
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "" #指定库名、用户名和密码
}
#自动生成
Messages { #Messages逻辑段用来设定Director端如何保存日志,以及日志的保存格式,可以将日志信息发送到管理员邮箱,前提是必须开启sendmail服务
Name = Standard
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 = dba.gao@gmail.com = all, !skipped
operator = itchenyi@gmail.com = mount
console = all, !skipped, !saved
append = "/usr/local//bacula/bin/working/log" = all, !skipped #定义bacula的运行日志
append ="/usr/local//bacula/log/bacula.err.log" = error,warning, fatal #定义bacula的错误日志
catalog = all
}
#自动生成
Messages { #定义了一个名为Daemon的Messages逻辑段,“Daemon”已经在前面进行了引用
Name = Daemon
mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = exitgogo@126.com = all, !skipped
console = all, !skipped, !saved
append = "/usr/local//bacula/log/bacula_demo.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
}
#自动生成
Pool { #定义供Job任务使用的池属性信息,例如,设定备份文件过期时间、是否覆盖过期的备份数据、是否自动清除过期备份等
Name = File
Pool Type = Backup
Recycle = yes #重复使用
AutoPrune = yes #表示自动清除过期备份文件
Volume Retention = 365 days #指定备份文件保留的时间
Maximum Volume Bytes = 50G # Limit Volume size
Maximum Volumes = 100 #设置最多保存多少个备份文件
#Label Format ="db-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}" #设定备份文件的命名格式,这个设定格式会产生的命名文件为:db-2013-01-27-xxx
#Recycle Current Volume = yes #表示可以使用最近过期的备份文件来存储新备份
#Maximum Volume Jobs = 1 #表示每次执行备份任务创建一个备份文件
}
#自动生成
Console { #限定Console利用tray-monitor获得Director的状态信息
Name = ubuntu-mon
Password = "123456"
CommandACL = status, .status
}
3、配置SD端
Storage { # definition of myself
Name = ubuntu-sd
SDPort = 9103 # Director's port
WorkingDirectory = "/opt/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
Director {
Name = ubuntu-dir
Password = "1234567"
}
Director {
Name = ubuntu-mon
Password = "1234567"
Monitor = yes
}
Autochanger {
Name = FileChgr1
Device = FileChgr1-Dev1, FileChgr1-Dev2
Changer Command = ""
Changer Device = /dev/null
}
Device {
Name = FileChgr1-Dev1
Media Type = File1
Archive Device = /tmp
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
Maximum Concurrent Jobs = 5
}
Device {
Name = FileChgr1-Dev2
Media Type = File1
Archive Device = /tmp
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
Maximum Concurrent Jobs = 5
}
Autochanger {
Name = FileChgr2
Device = FileChgr2-Dev1, FileChgr2-Dev2
Changer Command = ""
Changer Device = /dev/null
}
Device {
Name = FileChgr2-Dev1
Media Type = File2
Archive Device = /tmp
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
Maximum Concurrent Jobs = 5
}
Device {
Name = FileChgr2-Dev2
Media Type = File2
Archive Device = /tmp
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
Maximum Concurrent Jobs = 5
}
Messages {
Name = Standard
director = ubuntu-dir = all
}
Bacula FD端配置
1、配置bacula-fd.conf
Director {
Name = ubuntu-dir
Password = "123456"
}
#
# Restricted Director, used by tray-monitor to get the
# status of the file daemon
#
Director {
Name = ubuntu-mon
Password = "123456"
Monitor = yes
}
#
# "Global" File daemon configuration specifications
#
FileDaemon { # this is me
Name = ubuntu-fd
FDport = 9102 # where we listen for the director
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run/bacula
Maximum Concurrent Jobs = 20
# Plugin Directory = /usr/lib/bacula
FDAddress = 192.168.3.59
}
# Send all messages except skipped files back to Director
Messages {
Name = Standard
director = ubuntu-dir = all, !skipped, !restored
}
二、bacula的FD端配置,FD端共有两个文件bacula-fd.conf和bconsole.conf需要配置
1. 配置bacula-fd.conf
Director {
Name = ubuntu-dir
Password = "123456"
}
#
# Restricted Director, used by tray-monitor to get the
# status of the file daemon
#
Director {
Name = ubuntu-mon
Password = "123456"
Monitor = yes
}
#
# "Global" File daemon configuration specifications
#
FileDaemon { # this is me
Name = ubuntu-fd
FDport = 9102 # where we listen for the director
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run/bacula
Maximum Concurrent Jobs = 20
# Plugin Directory = /usr/lib/bacula
FDAddress = 192.168.3.59
}
# Send all messages except skipped files back to Director
Messages {
Name = Standard
director = ubuntu-dir = all, !skipped, !restored
}
2. 配置bconsole.conf
Director {
Name = ubuntu-dir
DIRport = 9101
address = 192.168.3.59
Password = "1234567"
}
对于bacula服务器的部署,建议大家不要使用最新版7.4以后的版本,目前网上大都是之前版本的教程,如果真有需求的话也可以通过阅读官方文档来使用,如果大家在部署过程中有什么问题,也欢迎加我扣扣留言交流1759755327