备份恢复需要启动并且配置正确的组件 为了保证备份与恢复的成功,下列组件必须配置正确并保证运行 the Director daemon, the File daemon, the Storage daemon, and the Catalog service (MySQL, PostgreSQL or SQLite作者推荐MySQL). 各组成部分的配置文件之间的相互关系 三个主要的配置文件不是彼此独立的,而是相互影响的,director的文件变动storage和client的文件都要做相应的修改,而storage和client的变动又得在director上修改否则就无法正常控制他们。如下图所示:
二、安装bacula2.1 配置makefile,编译,安装 # ./configure --prefix=/opt/Rhythm_backup # make ; make install
定义将客户机的数据保存到哪个存储设备,可以定义多个 Storage { Name = storage_mail #必须与bacula-sd.conf配置文件里的Name = storage_mail相同 Address = 192.168.0.210 #安装sd服务的服务器ip SDPort = 9103 Password = "" #访问sd服务器的口令 Device = storage1 #必须与192.168.0.210机器里bacula-sd.conf配置件里的Device { Name = storage1相同。 Media Type = File #必须与bacula-sd.conf配置文件里的Device {Media Type = File相同,这是指定备份介质的地方,最好直接写存储设备名,例“HP DLT8000”,如果有多个相同的存储设备存在,你最好做个区分,这里只标记一个唯一的设备。 Autochanger = yes # enable for autochanger device
定义给Job使用的池属性,即是否循环覆盖备份数据,是否自动清除过期的备份,循环的过期时间 Pool { Name = Default Pool Type = Backup #与Job里的Type协调可用值Archive,Cloned,Migration,Copy,Save Recycle = yes # Bacula can automatically recycle Volumes AutoPrune = yes # Prune expired volumes Volume Retention = 365 days # one year }
定义调度时间,每个时间表都可以定义多个Level执行的时间,Job资源的Level=对应那个级别就按哪个时间执行 Schedule { Name = "backup_WeeklyCycle" Run = Full 1st sun at 23:05 #定义全备份的时间 Run = Differential 2nd-5th sun at 23:05 #定义差异备份的时间 Run = Incremental mon-sat at 23:05 这里定义的模式和Job资源的Level对应,相应的Level=Incremental按照这里的定时执行。 } Schedule { Name = "restore_WeeklyCycle" Run = Full 1st sun at 23:05 }
定义后台数据库,否则启动不了 Catalog { Name = MyCatalog dbname = bacula; user = bacula; password = "" DB Address = 192.168.0.210 #不要用localhost DB Port = 33060 }
定义发送报告邮件和记录日志的位置 Messages { Name = backup_messages #为备份客户端mail主机提供的messages资源。其他客户机改其他名字就行了,下面可以改其他管理员的邮箱,多人用“,”分隔。 mailcommand = "/opt/Rhythm_backup/sbin/bsmtp -h 211.155.251.234 -f \"\(Rhythm_backup备份报告\) %r\" -s \"备份结果: %t %e of %c %l\" %r" operatorcommand = "/opt/Rhythm_backup/sbin/bsmtp -h 211.155.251.234 -f \"\(Rhythm_backup备份报告\) %r\" -s \"Rhythm_backup: Intervention needed for %j\" %r" mail = = all, !skipped operator = = mount console = all, !skipped, !saved append = "/opt/Rhythm_backup/var/log/Rhythm_backup.log" = all, !skipped append ="/opt/Rhythm_backup/var/log/Rhythm_backup_err.log" = error, warning, fatal } Messages { Name = restore_messages #恢复用的messages mailcommand = "/opt/Rhythm_backup/sbin/bsmtp -h 211.155.251.234 -f \"\(Rhythm_backup恢复报告\) %r\" -s \"恢复结果: %t %e of %c %l\" %r" operatorcommand = "/opt/Rhythm_backup/sbin/bsmtp -h 211.155.251.234 -f \"\(Rhythm_backup恢复报告\) %r\" -s \"Rhythm_backup: Intervention needed for %j\" %r" mail = = all, !skipped operator = = mount console = all, !skipped, !saved append = "/opt/Rhythm_backup/var/log/Rhythm_backup.log" = all, !skipped append ="/opt/Rhythm_backup/var/log/Rhythm_backup_err.log" = error, warning, fatal } 参考资料: http://man.chinaunix.net/network/bacula/bacula_manual/Messages_Resource.html
定义一个SD用的messaged Messages { Name = messages_mail director = backup_mail_server = all }
4.6 配置FD(client)端 必须定义的资源
Client -- to define what Clients are to be backed up.
Director -- to define the Director's name and its access password.
Messages -- to define where error and information messages are to be sent.
定义一个允许连接FD的控制端 Director { Name = backup_mail_server Password = "" }
定义一个允许连接FD的监控端 Director { Name = backup_server-mon Password = "" Monitor = yes }
定义一个FD端 FileDaemon { # this is me Name = mail FDAddress = 211.155.251.138 # define special FD ip FDport = 9102 # where we listen for the director WorkingDirectory = /opt/Rhythm_backup/working Pid Directory = /opt/Rhythm_backup/var Maximum Concurrent Jobs = 20 }
定义message Messages { Name = messages_mail director = backup_mail_server = all, !skipped, !restored } 好了,到此为止,一个完整的bacula运行环境已经搭建好了,下期我们将开始重点介绍Bacula程序服务器端和客户端图形界面安装和配置。