备份工具bacula部署使用

牧云@^-^@ 提交于 2019-12-04 08:53:12

官方文档:https://www.bacula.org/9.0.x-manuals/en/main/Configuring_Director.html

环境:

CentOS Linux release 7.4.1708

mysql 5.7.28

bacula 9.4.4

 

组件说明

Directory: 管理所有备份,恢复,验证,和存档事务,定制备份和恢复文件的计划.
Storge: 指定进行存储和恢复文件属性和数据的物理备份媒介.
File: 安装在被备份机器上的程序,将被directory调用时候,它提供关于自己的操作系统、文件属性、数据等资料.
Console: 管理控制台,与directory进行通讯.
Catalog: 负责维护所有备份文件的索引和数据库.Catalog服务允许系统管理员或用户能够快速地找到并恢复任何需要的档案。catalog维护所有Volume使用情况的记录,所有任务的运行情况,和所有档案的保存情况,允许有效的恢复和Volume管理。 Bacula目前支持的三个数据库(postgresql、mysql、sqlite),在安装Bacula时,必须选择其中之一。
Monitor: 监控directory、file、storage的守护进程

 

软件安装

       准备工作:

       mysql 需要准备数据库bacula,用户:bacula,授权:grant all privileges on bacula.* to bacula@"%"  identified by "passwd";

 

服务端安装

yum install gcc gcc-c++ mysql-devel -y

下载地址:https://www.bacula.org/source-download-center/

bacula-9.4.4.tar.gz

tar -xvzf bacula-9.4.4.tar.gz

cd bacula-9.4.4

./configure --prefix=/data/software/bacula --with-mysql

make 

make install

 

基础配置

bconsole.conf

Director {
Name = bacula-center  #Directory的name
DIRport = 9101
address = tusdao-tex-base-11
Password = "passwd"  #用于和bacula-center验证
}

 

bacula-dir.conf

Director { 
Name = bacula-center
DIRport = 9101 
QueryFile = "/data/software/bacula/etc/query.sql"
WorkingDirectory = "/data/software/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 20 #根据需要调整
Password = "passwd" # Console password
Messages = Daemon
}

Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "passwd"   #数据库
}

Console {
Name = tusdao-tex-base-11-mon  #监控
Password = "passwd" 
CommandACL = status, .status
}

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
Label Format = "Vol-" # Auto label
}

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
}

FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/opt/bacula/working/bacula.sql"     #需要备份的目标数据
}
}

Autochanger {
Name = File1
Address = tusdao-tex-base-11 # storage地址
SDPort = 9103
Password = "passwd" #验证密码
Device = FileChgr1    #驱动name,在sd中会有对应的配置
Media Type = File1
Maximum Concurrent Jobs = 10 # run up to 10 jobs a the same time
Autochanger = File1 # point to ourself
}

Client {
Name = tusdao-tex-base-11-fd
Address = tusdao-tex-base-11  #客户端地址
FDPort = 9102
Catalog = MyCatalog
Password = "passwd" # 与fd中对应
File Retention = 60 days # 60 days  #留存策略
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}

Job {
Name = "redis-bak"
Type = "Backup"  #可用类型有backup,restore,verify,admin
Level = "Incremental" #可用的值是Full(全备份),Incremental(增量备份),Differential(差异备份)如果第一次没做Full则会先做Full以后才执行Incremental
Messages = "Daemon"
Storage = "db"
Pool = "File"
Client = "node2db"
Fileset = "dbredis"
Schedule = "WeeklyCycle"


RunScript {
RunsWhen = Before
FailJobOnError = Yes
RunsOnClient = Yes
Command = "redis-cli -h 127.0.0.1 -p 6379 save"
}
}

Restore 不会自动执行,需要bconsole手动执行

 

 

 

WEB UI安装

         说明:

                 api /webui安装 默认密码都是admin/admin,web调用api接口
                 api 默认端口9096
                web 默认端口9095

rpm --import http://bacula.org/downloads/baculum/baculum.pub
/etc/yum.repos.d/baculum.repo

[baculumrepo]
name=Baculum CentOS repository
baseurl=http://bacula.org/downloads/baculum/stable/centos
gpgcheck=1
enabled=1

yum install php php-devel php-json baculum-common baculum-api baculum-api-httpd baculum-web baculum-web-httpd httpd -y

systemctl enable httpd

授权
cat /etc/sudoers.d/baculum
Defaults:apache !requiretty
apache ALL=NOPASSWD: /data/software/bacula/sbin/bconsole
apache ALL=NOPASSWD: /data/software/bacula/sbin/bdirjson
apache ALL=NOPASSWD: /data/software/bacula/sbin/bsdjson
apache ALL=NOPASSWD: /data/software/bacula/sbin/bfdjson
apache ALL=NOPASSWD: /data/software/bacula/sbin/bbconsjson

 

setfacl -R -m u:apache:rwx /data/software/bacula/etc  #apache可以读取配置文件,执行脚本

 

授权完成后

systemctl start httpd

首先,访问API,9096端口,根据提示配置/修改访问密码,然后访问WEBUI,根据提示配置/修改访问密码

然后连接webui

配置完成以后,界面如下

http://172.17.73.208:9095/web/

 

 

客户端安装

yum install gcc gcc-c++  -y

bacula-9.4.4.tar.gz

tar -xvzf bacula-9.4.4.tar.gz

cd bacula-9.4.4

./configure --prefix=/data/software/bacula  --enable-client-only

make 

make install

配置

Director {
Name = node3-dir
Password = "passwd"  #密码与center中的client密码对应
}

Director {
Name = node3-mon
Password = "passwd" #密码与center中的监控模块对应
Monitor = yes
}

FileDaemon { 
Name = node3-fd
FDport = 9102 # where we listen for the director
WorkingDirectory = /opt/bacula/client/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
Plugin Directory = /data/bacula/lib
}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!