当前位置: 首页 > 工具软件 > Bacula > 使用案例 >

Bacula(5)配置详解

孙承弼
2023-12-01
相信经过前面的铺垫,我们已经对bacula有了一个整体的认识。这篇文章我将不再引用官方文档内容的翻译,直译这些文章并没有太多的实际意义(其实是很多术语并不是太会翻译。。。),接下来将是满满的干货。
启动一个fd client,在另一台需要备份的目标及其安装bacula,如果只是安装fd在编译的时候加上  -- enable-client-only就可以了。
fd配置文件
Director {
Name = "name-dir" #此处的名称要和服务端的director名称相同
    Password = #注意这个密码,在dir引入client的时候要使用这个密码
}

FileDaemon { # this is me
    Name = "name1"
    FDport = 9102 # where we listen for the director
    WorkingDirectory = /opt/bacula/working
    Pid Directory = /var/run
    Maximum Concurrent Jobs = 20
    Plugin Directory = /usr/lib64
}

Messages {
    Name = Standard
    director = "name1" = all, !skipped, !restored
}
配置好fd之后,在dir的配置文件中添加client,重新加载后就可以在baculum中看到添加的client。

bacula-sd
前面我们并没有配置它,并不是它不需要配置。它是真正负责存储文件的服务,bacula-fd会通过它存取文件。
下面是一个sd的示例配置
Storage { # definition of myself
Name = #你自己的storage name"
SDPort = 9103 # Director's port
WorkingDirectory = "/opt/bacula/working"
Pid Directory = "/var/run"
Plugin Directory = "/usr/lib64"
Maximum Concurrent Jobs = 20
}

Director {
Name = #这个要和bacula-dir中的name一致
Password = #注意这个密码,在配置dir时,dir需要使用这个密码访问sd
}

Device {
Name = #device名称,在配置bacula-dir中的storage时会用到
Media Type = File
Archive Device = #你的备份路径
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 = 4-180-dir = all
}
Bacula-dir配置
Director { # define myself
Name = #名称,默认安装会是机器名-dir,注意sd,fd,中的director name要与此一致
DIRport = 9101 # where we listen for UA connections
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/opt/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 20
Password = # Console password
Messages = Daemon
}

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
}

Storage {
Name = #在配置job的时候会用
Address = #storage的ip,注意如果sd和dir在同一台机器上,这里并不能写localhost或者127.0.0.1,因为这个地址会直接提供给客户端fd来进行备份还原操作
SDPort = 9103
Password = #注意这个密码是sd的密码
Device = #在sd中定义的device name
Media Type = File
Maximum Concurrent Jobs = 10
}

#这个不解释了
Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "bacula"; DB Address = ""; DB Port = ""
}

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 = "/opt/bacula/log/bacula.log" = all, !skipped
}

#注意这个message,我们可以用它进行任务提醒,这里我用python发送了一个钉钉消息
Messages {
Name = dingding
mailcommand = "python /var/shell/dingding.py \">Name:%n Status:%e Level:%l Bytes:%b Since:%s\""
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/opt/bacula/log/bacula.log" = all, !skipped
catalog = all
}

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
}

Console {
Name = 4-180-mon
Password = #
CommandACL = status, .status
}

#注意这里,意思是引入子配置文件,单个子文件可以使用@filename来实现,引入一个文件夹需要这样写,并不太友好
@|"sh -c 'for f in /etc/bacula/conf.d/*.conf ; do echo @${f} ; done'"
下面是子配置文件
client.conf
Client {
Name = #define your name
Address = #client fd address
FDPort = 9102
Catalog = MyCatalog
Password = 客户端fd的密码
File Retention = 60 days # 60 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
fileset.conf
FileSet {
Name = "103.wiki"
Include {
Options {
signature = MD5
}
File = #备份的文件(文件夹)
}
Exclude {
File = #需要排除的文件(文件夹)
}
}
job.conf
Job {
Name = #job 名称
Type = Backup
Level = Incremental
Client = #client名称,要和备份目标及其的client名称一致,即client.conf中的配置
FileSet = #fileset名称,要和定义的fileset一致
Schedule = "WeeklyCycle"
Storage = #storage名,在dir配置中
Messages = #message名
Pool = File
SpoolAttributes = yes
Priority = 10
}
 类似资料: