开源备份之Bacula篇2配置篇

Tom哥致力于开源 www.cloudbps.com

环境:Centos6U3
Bacula版本:5.2.13
官方主页:http://www.bacula.org
典型的C/S模型
一.Server相关组件
1、      Director:管理备份恢复和所有组件的配置
2、      Database:用于存放数据的编目,以及备份恢复的索引信息
3、      Storage:存储相关,定义相关的存储设备
4、      Console:用于管理Director
5、      Monitor:监控数据备份还原的信息
6、      File Daemon:Client端的相关配置
                                                            
二.Server端的相关配置
1.安装 gcc gcc-c++ make软件包
#yum �Cy install gcc gcc-c++ make
2.通过源码安装bacula,三部曲
#./configure  --prefix=/opt/bacula --enable-smartablloc
--with-mysql --with-working-dir=/opt/bacula/working --with-pid-dir=/opt/bacula/working --with-subsys-dir=/opt/bacula/working
--enable-readline
# make && make install
#导入数据库,我这边用的是mysql,保证导入的时候root密码为空
#./grant_bacula_privileges
#./grant_mysql_privileges
#./make_mysql_tables
3.配置Bacule server
1.Director相关配置
Director {                            # define myself
Name = master.backup.com-dir
DIRport = 9101       # where we listen for UA connections
QueryFile = "/opt/bacula/etc/query.sql"
WorkingDirectory = "/opt/bacula/working"
PidDirectory = "/opt/bacula/working"
Maximum Concurrent Jobs = 1  最大并发数
Password="GYkBngRwqbD4+UDZKCVv+G0/SrjCfLBrfwtcnroBcBlF"         # Console password
Messages = Daemon
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = master.backup.com-fd
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = FileStorage
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/opt/bacula/working/%c.bsr"
}
Job {
Name = "BackupClient1"
JobDefs = "DefaultJob"
}
Job {
Name = "BackupCatalog"    #defind一个名字
JobDefs = "DefaultJob"
Level = Full                   #backup leve
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 = "/opt/bacula/etc/make_catalog_backup.pl MyCatalog"
# This deletes the copy of the catalog
RunAfterJob  = "/opt/bacula/etc/delete_catalog_backup"
Write Bootstrap = "/opt/bacula/working/%n.bsr"
Priority = 11                   # run after main backup
}
Job {                        #备份node1这个客户端的数据
Name = Node
Type = Backup                     #有backup、restore、virfiey
Client = node1.backup.com-fd #客户端主机名,需要解析到
FileSet= imange                              #定义备份文件的属性
Schedule = "WeeklyCycleAfterBackup"
Storage = imange                      #定义存储的属性
Pool = Default                          #定义一个默认的池
Messages = Standard
Level = Incremental           #进行增量备份
Priority = 10                               #权重是10
Write Bootstrap = "/opt/bacula/working/%n.bsr"   #定义引导文件路径
}
Job {                                                 --默认有个恢复
Name = "RestoreFiles"
Type = Restore
Client=master.backup.com-fd
FileSet="Full Set"
Storage = FileStorage
Pool = Default
Messages = Standard
Where = /tmp/bacula-restores
}
FileSet {                 #文件列表定义
Name = "Full Set"      #下面会连连相扣
Include {
Options {
signature = MD5     #数据经过md5加密
}
File = /boot             #备份/boot下面的数据
}
Exclude {                   #排除下面的不备份
File = /opt/bacula/working
File = /tmp
File = /proc
File = /tmp
File = /.journal
File = /.fsck
}
}
#下面这个是官方指定的只备份/var/www下以.jpg结尾的数据
FileSet {
Name = "imange"
Include {
Options {
Compression=GZIP    #通过GZIP压缩
wildfile= "*.jpg"             #备份以.jpg结尾的文件
signature = MD5   #md5数据加密
}
Options {
Exclude = yes
RegexFile = ".*"
}
File = /var/www/
}
}
Schedule {    #备份策略
Name = "WeeklyCycle"
Run = Full 1st sun at 23:45  #第一周的周日23:45做全备
Run = Differential 2nd-5th sun at 23:45  #第二周到第五周做差备份在23:45
Run = Incremental mon-sat at 23:45 #每周一到周六做增量备份
}
Schedule {
Name = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 23:45
}
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/opt/bacula/working/bacula.sql"
}
}
Client {
Name = master.backup.com-fd
Address = localhost
FDPort = 9102
Catalog = MyCatalog
Password = "YjdMH4bpWUhHR1bJ8kQmv2gChO0xzO/Ydfe7b9N4yOim"          # password for FileDaemon
File Retention = 30 days            # 30 days
Job Retention = 6 months            # six months
AutoPrune = yes                     # Prune expired Jobs/Files
}
Client {
Name = node1.backup.com-fd
Address = 10.0.0.200
FDPort = 9102
Catalog = MyCatalog
Password = "GYkBngRwqbD4+UDZKCVv+G0/SrjCfLBrfwtcnroBcBlF"          # password for FileDaemon
File Retention = 30 days            # 30 days
Job Retention = 6 months            # six months
AutoPrune = yes                     # Prune expired Jobs/Files
}
Storage {
Name = imange
Address = 10.0.0.100
SDPort = 9103
Password = "FLWxhOM9dIQnxrUXI4NF8r4H8bVijxpyxVJM4m/Cn6X5"
Device = FileStorage
Media Type = File
Autochanger = yes
}
Storage {
Name = FileStorage
Address = 10.0.0.100                # N.B. Use a fully qualified name here
SDPort = 9103
Password = "FLWxhOM9dIQnxrUXI4NF8r4H8bVijxpyxVJM4m/Cn6X5"
Device = FileStorage
Media Type = File
Autochanger = yes
}
Catalog {
Name = MyCatalog
dbdriver = "dbi:mysql"; dbaddress = localhost; dbport = 3306;
dbname = "bacula"; dbuser = "root"; dbpassword = "redhat"
}
Messages {
Name = Standard
mailcommand = "/opt/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/opt/bacula/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 = "/opt/bacula/opt/bacula/log/bacula.log" = all, !skipped
catalog = all, !skipped, !saved
}
Messages {
Name = Daemon
mailcommand = "/opt/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/opt/bacula/opt/bacula/log/bacula.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
Label Format ="db-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}"
Maximum Volume Bytes = 50G
Maximum Volumes = 100
Recycle Current Volume = yes
}
Pool {
Name = File
Pool Type = Backup
Recycle = yes                       # Bacula can automatically recycle Volumes
AutoPrune = yes                     # Prune expired volumes
Volume Retention = 365 days         # one year
Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
Maximum Volumes = 100               # Limit number of Volumes in Pool
}
Pool {
Name = Scratch
Pool Type = Backup
}
Console {
Name = master.backup.com-mon
Password = "XONK1TOOgNaZuQ7tw9sr3BMnThzK613Jx2UV2aFiYpbg"
CommandACL = status, .status
}
                                                            
2.Storage相关配置
Storage {                             # definition of myself
Name = master.backup.com-sd
SDPort = 9103                  # Director's port
WorkingDirectory = "/opt/bacula/working"
Pid Directory = "/opt/bacula/working"
Maximum Concurrent Jobs = 20
}
Director {
Name = master.backup.com-dir
Password = "FLWxhOM9dIQnxrUXI4NF8r4H8bVijxpyxVJM4m/Cn6X5"
}
Director {
Name = master.backup.com-mon
Password= "XONK1TOOgNaZuQ7tw9sr3BMnThzK613Jx2UV2aFiYpbg"
Monitor = yes
}
Device {
Name = FileStorage
Media Type = File
Archive Device = /tmp/backup     #卷存储的存放位置
LabelMedia = yes;                   # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes;               # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
}
Messages {
Name = Standard
director = master.backup.com-dir = all
}
                                                            
启动mysql && 启动bacula服务 && netstat �Cntlp查看9101-9103端口是否监听,注意selinux和防火墙
                                                            
                                                            
三.Client端相关配置
1.安装 gcc gcc-c++ make软件包
2.通过源码安装bacula,三部曲
3.配置Bacule File
Director {
Name = master.backup.com-dir  #必须和server端Directo逻辑端一样
Password="GYkBngRwqbD4+UDZKCVv+G0/SrjCfLBrfwtcnroBcBlF"
}
Director {
Name = master.backup.com-mon #必须要server端 console逻辑端一样
Password = "XONK1TOOgNaZuQ7tw9sr3BMnThzK613Jx2UV2aFiYpbg"
Monitor = yes
}
FileDaemon {                          # this is me
Name = node1.backup.com-fd
FDport = 9102                  # where we listen for the director
WorkingDirectory = /opt/bacule/opt/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20   #最大并发20,这个要和server端stoage端一致
}
Messages {
Name = Standard
director = node1.backup.com-dir = all, !skipped, !restored
}


你可能感兴趣的:(bacula,配置篇,开源备份)