分类: LINUX
2009-08-25 17:02:08
简介: Bacula,被誉为开源软件中最好的备份还原软件,它提供了企业级的客户机/服务器的备份解决方案,能够通过网络来管理文件的备份,恢复和核实工作.既有windows版本的,也有Linux,Unix的.
Directory:管理所有备份,恢复,验证,和存档事务,定制备份和恢复文件的计划.
Storge:指定进行存储和恢复文件属性和数据的物理备份媒介.
File:安装在被备份机器上的程序,将被directory调用时候,它提供
关于自己的操作系统、文件属性、数据等资料.
Console:与directory进行通讯.
Catalog:负责维护所有备份文件的索引和数据库.
Monitor:监控directory、file、storage的守护进程.
使用2台服务器来做这个网络备份的测试环境,环境如下:
10.10.2.226 作为directory、storage、catalog.
10.10.2.162 作为file.
bacula的安装不是很复杂,我这里安装的是bacula的2.4.3版本的.
#tar zxvf bacula-2.4.3.tar.gz
#./configure --with-mysql
#make&&make intall
默认情况下,bacula的安装路径为/etc/bacula.
#./grant_mysql_privileges
#./ create_mysql_database
#./ make_mysql_tables
在这里说明下,bacula的主要配置都在directory这个配置文件里面的,这个算是一个核心文件了,一定要搞清楚里面配置文件的配置项都代表什么意思,否则很难配置成功.
#####################################################################
directory端的配置:
#more bacula-dir.conf
//directory的全局配置
Director {
Name = linux-0fdr-dir
DirAddress=10.10.226 //这里是directory端的ip
DIRport = 9101 //这里是directory端的进程号
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/var/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
Messages = Daemon
}
//directory的job配置
Job {
Name =dbjob //job的名字,这个可以随便起,在后面的备份操作
的时候可以看到
Client=dbfd //这里要和后面的client的name名字要一样
Type=backup //可用类型有backup,restore,verify,admin
FileSet=dbfs //这个要和后面的fileset的name名字要一样
Messages=Daemon //这个要与后面的message的name名字要一样
Pool=dbpool //这个要与后面的pool的name名字要一样
Storage=dbsd //这个要与后面的storage的name名字要一样
Write Bootstrap = "/var/bacula/working/Client1.bsr"
Level=Full //这里是备份类型,可用的值是FULL(完全备份),incremental(增量备份),differential(差异备份)
schedule=dbscd //这里要与后面的schedule的name名字要一样
}
//directory的还原job配置
job{
Name=restrory
Client=dbfd
Type=Restore
FileSet=dbfs
Messages=Daemon
Pool=dbpool
Storage=dbsd
Write Bootstrap = "/var/bacula/working/Client1.bsr"
Where =/home/bacula/ //还原的路径
}
FileSet {
Name =dbfs //这个名字是应用到job里面的
Include{
Options {
Compression=GZIP //对备份文件进行gzip的压缩
signature = MD5 //验证方式为MD5码的方式
Sparse=yes
}
File =/home/mysql_packup //需要备份的目录
}
Exclude { // 排除的,不备份的内容
File = /proc //不备份/proce
File = /tmp
File = /.journal
File = /.fsck
}
}
Client {
Name = dbfd //这里要与FD配置文件的name相同,并且应用在job里面的
Address = 10.10.2.162 //要备份的客户机IP
FDPort = 9102
Catalog = dbcatalog //记录客户机备份情况的日志名,后面会定义
Password = "Nd+Yuqe+Kd5wBc1S9uMTEGTNqNIe1cupnfuOdwboej6Z" //与FD的密码一致
File Retention = 30 days //保存在数据库目录多久轮询一次,这里是30天
Job Retention = 6 months //job保持周期,大于FRetention
AutoPrune = yes //当FR/JR周期满了是否执行自动删除它们在数据库的目录
#priority =1 //如果多个client时,定义优先级1-1000,值越小越优先
}
Storage {
Name =dbsd //必须与SD配置文件的name相同,这个应用到了job里面
Address = 10.10.2.226 //安装sd服务的服务器IP
SDPort = 9103
Password = "5jipKA7pekDel6BUjgIwD3LkPPBgxcecbLpLfl9puj0c" //要与SD的password一样
Device =dbdev //要与SD配置文件的device的name相同
Media Type = File //要与SD配置文件device的Media Type相同
}
Pool {
Name =dbpool //这个应用到了job里面
Pool Type=backup
Maximum Volume Jobs = 1
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
}
Schedule { //定时任务
Name =dbscd //这个应用到了job里面
Run = Full 1st sun at 23:05
Run = Differential 2nd-5th sun at 23:05
Run = Incremental mon-sat at 23:05
}
Catalog {
Name =dbcatalog //这个应用到了job里面
dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
DB Address=10.10.2.226 //不要用localhost,数据库所在的IP
DB Port=3306
}
Messages {
Name = Daemon //这个应用到了job里面
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
}
Console {
Name = linux-0fdr-mon
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
CommandACL = status, .status
}
#####################################################################
SD配置:
Storage {
Name =dbsd //这里要与director配置文件的storage的name一样
SDAddress=10.10.2.226 //这里是SD的IP
SDPort = 9103
WorkingDirectory = "/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20 //job的最大连接数
}
Director {
Name =linux-0fdr-dir //这里要与directory的name相同
Password = "5jipKA7pekDel6BUjgIwD3LkPPBgxcecbLpLfl9puj0c " //这里与directory中storage的password相同
}
Director { //这个是做监控的配置
Name = linux-0fdr-dir
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
Monitor = yes
Device {
Name =dbdev //这里要与directory中storage的device一样
Media Type = File //这里要与diretory中storage的Media Type相同
Archive Device =/home/bakcup/ //备份的路径
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}
Messages {
Name = Standard
director = linux-0fdr-dir = all
}
console端的配置:
Director {
Name = linux-0fdr-dir //这里要与directory的name相 同
DIRport = 9101
address = 10.10.2.226 //console端的IP
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
//这个密码要与directory的password一样
}
在server端,只启动directory和storage的进程,启动命令如下:
#./bacula-ctl-dir start
#./bacula-ctl-sd start
启动之后,要给bacula添加存储介质,
linux-0fdr:/etc/bacula # ./bconsole
Connecting to Director 10.10.2.226:9101
1000 OK: linux-0fdr-dir Version: 2.4.3 (10 October 2008)
Enter a period to cancel a command.
*label
Automatically selected Catalog: dbcatalog
Using Catalog "dbcatalog"
Automatically selected Storage: dbsd
Enter new Volume name: woyun //这里随便给他起个卷名
Automatically selected Pool: dbpool
Connecting to Storage daemon dbsd at 10.10.2.226:9103 ...
Sending label command for Volume "test" Slot 0 ...
3000 OK label. VolBytes=188 DVD=0 Volume="test" Device="dbdev" (/home/bakcup/)
Catalog record for Volume "test", Slot 0 successfully created.
Requesting to mount dbdev ...
3906 File device "dbdev" (/home/bakcup/) is always mounted.
You have messages.
注意:上面黄色底红色字的为要输入的内容.