一、环境描述

两台测试机,都是CentOS 5.8 x64的系统。

Director+Storage+Consle:192.168.144.80

Client:192.168.144.113

Bacula软件版本:bacula-5.2.1(目前最高版本是5.2.10)

 

二、下载与安装

1、下载最新版bacula-5.2.10

   
   
   
   
  1. wget http://sourceforge.net/projects/bacula/files/bacula/5.2.10/bacula-5.2.10.tar.gz/download 

此次实验版本为bacula-5.2.1。

2、server端安装bacula(192.168.144.80)

2.1 bacula需要使用mysql数据库,存储任务信息。安装bacula之前需要安装mysql数据库。

   
   
   
   
  1. yum -y install mysql mysql-devel mysql-server 

2.2 安装完mysql之后,再进行bacula的安装。

 

   
   
   
   
  1. tar xzvf bacula-5.2.1.tar.gz 
  2. cd bacula-5.2.1 
  3. ./configure --prefix=/data/bacula-5.2.1 \ 
  4.  --with-bat \ 
  5.  --with-mysql=/usr/local/mysql && make && make install  

说明:--with-bat参数表明支持bat的GUI图形用户界面,图形界面管理任务更方便。bat需要qt4的支持,yum安装即可。Gnome的图形界面在5.2以上版本已经不再支持。

2.3 为bacula创建mysql数据库以及授权。

注意:执行Mysql初始代码时,默认由空密码的root用户执行,因此要请确保Mysql数据库root密码为空。

 

   
   
   
   
  1. cd /data/bacula-5.2.1/etc/ 
  2. ./grant_mysql_privileges 
  3. ./create_mysql_database 
  4. ./make_mysql_tables

2.4 客户端安装bacula。(192.168.144.113)

   
   
   
   
  1. ./configure --prefix=/usr/local/bacula-5.2.1 --enable-client-only && make && make install

 

三、bacula配置文件的配置

配置bacula备份系统,其实就是对Director端配置文件bacula-dir.conf、SD配置文件bacula-sd.conf、客户端FD配置文件bacula-fd.conf以及Console端配置文件bconsole.conf进行配置的过程。

配置文件之间的关系,如下图:

 

备份与还原---bacula安装与配置_第1张图片

本次示例配置文件如下:

3.1 bconsole.conf的内容:

   
   
   
   
  1. Director { 
  2.   Name = backup80-dir 
  3.   DIRport = 9101 
  4.   address = localhost 
  5.   Password = "HCKMc2rdoE/v4KYrzD5FpJc6MXrP+w67RPO6MqOrrJ/6" 
  6. }

3.2 bacula-sd.conf的内容:

 

   
   
   
   
  1. Storage { 
  2.   Name = backup80-sd 
  3.   SDPort = 9103 
  4.   WorkingDirectory = "/data/bacula-5.2.1/var/bacula/working" 
  5.   Pid Directory = "/var/run" 
  6.   Maximum Concurrent Jobs = 20 
  7.  
  8. Director { 
  9.   Name = backup80-dir 
  10.   Password = "BwRCJ6oSA/FzN0rUY3Vu8WpEyNXIH/ppq33y1uXOCPI2" 
  11.  
  12. Director { 
  13.   Name = backup80-mon 
  14.   Password = "IzjtsscUhAXfE/yrR+D1cAqVR7Hi4rNn5w1PzICHCVk4" 
  15.   Monitor = yes 
  16.  
  17. Device { 
  18.   Name = backup80-sd 
  19.   Media Type = File 
  20.   Archive Device = /backup 
  21.   LabelMedia = yes
  22.   Random Access = Yes
  23.   AutomaticMount = yes;             
  24.   RemovableMedia = no
  25.   AlwaysOpen = no
  26.  
  27. Messages { 
  28.   Name = Standard 
  29.   director = backup80-dir = all 
  30. }

3.3 bacula-dir.conf的内容:

 

   
   
   
   
  1. Director { 
  2.   Name = backup80-dir 
  3.   DIRport = 9101      
  4.   QueryFile = "/data/bacula-5.2.1/etc/query.sql" 
  5.   WorkingDirectory = "/data/bacula-5.2.1/var/bacula/working" 
  6.   PidDirectory = "/var/run" 
  7.   Maximum Concurrent Jobs = 1 
  8.   Password = "HCKMc2rdoE/v4KYrzD5FpJc6MXrP+w67RPO6MqOrrJ/6" 
  9.   Messages = Daemon 
  10.  
  11. JobDefs { 
  12.   Name = "DefaultJob" 
  13.   Type = Backup 
  14.   Level = Incremental 
  15.   Client = backup80-fd 
  16.   FileSet = "Full Set" 
  17.   Schedule = "WeeklyCycle" 
  18.   Storage = File 
  19.   Messages = Standard 
  20.   Pool = File 
  21.   Priority = 10 
  22.   Write Bootstrap = "/data/bacula-5.2.1/var/bacula/working/%c.bsr" 
  23.  
  24. Job { 
  25.   Name = "backup80-backup" 
  26.   JobDefs = "DefaultJob" 
  27.  
  28. Job { 
  29.   Name = "web113-backup" 
  30.   Client = web113-fd 
  31.   JobDefs = "DefaultJob" 
  32.  
  33. Job { 
  34.   Name = "BackupCatalog" 
  35.   JobDefs = "DefaultJob" 
  36.   Level = Full 
  37.   FileSet="Catalog" 
  38.   Schedule = "WeeklyCycleAfterBackup" 
  39.   RunBeforeJob = "/data/bacula-5.2.1/etc/make_catalog_backup.pl MyCatalog" 
  40.   RunAfterJob  = "/data/bacula-5.2.1/etc/delete_catalog_backup" 
  41.   Write Bootstrap = "/data/bacula-5.2.1/var/bacula/working/%n.bsr" 
  42.   Priority = 11 
  43.  
  44. Job { 
  45.   Name = "RestoreFiles" 
  46.   Type = Restore 
  47.   Client=backup80-fd                 
  48.   FileSet="Full Set"                  
  49.   Storage = File                       
  50.   Pool = File 
  51.   Messages = Standard 
  52.   Where = /tmp/bacula-restores 
  53.  
  54. FileSet { 
  55.   Name = "Full Set" 
  56.   Include { 
  57.     Options { 
  58.      signature = MD5Compression=GZIP
  59.     } 
  60.     File = /data/bacula-5.2.1/sbin 
  61.     File = /etc 
  62.   } 
  63.  
  64. Schedule { 
  65.   Name = "WeeklyCycle" 
  66.   Run = Full 1st sun at 02:05 
  67.   Run = Differential 2nd-5th sun at 02:05 
  68.   Run = Incremental mon-sat at 02:05 
  69.  
  70. Schedule { 
  71.   Name = "WeeklyCycleAfterBackup" 
  72.   Run = Full sun-sat at 02:20 
  73.  
  74. FileSet { 
  75.   Name = "Catalog" 
  76.   Include { 
  77.     Options { 
  78.       signature = MD5 
  79.     } 
  80.     File = "/data/bacula-5.2.1/var/bacula/working/bacula.sql" 
  81.   } 
  82.  
  83. Client { 
  84.   Name = backup80-fd 
  85.   Address = localhost 
  86.   FDPort = 9102 
  87.   Catalog = MyCatalog 
  88.   Password = "61L0ZhxipREqc8v7d1UAHgoM3PgQT7BUxrE2+co4EXJa" 
  89.   File Retention = 30 days 
  90.   Job Retention = 6 months 
  91.   AutoPrune = yes 
  92.  
  93. Client { 
  94.  Name = web113-fd 
  95.  Address = 192.168.144.113 
  96.  FDPort = 9102 
  97.  Catalog = MyCatalog 
  98.  Password = "abc123456" 
  99.  File Retention = 30 days 
  100.  Job Retention = 6 months 
  101.  AutoPrune = yes 
  102.  
  103. Storage { 
  104.   Name = File 
  105.   Address = 192.168.144.80 
  106.   SDPort = 9103 
  107.   Password = "BwRCJ6oSA/FzN0rUY3Vu8WpEyNXIH/ppq33y1uXOCPI2" 
  108.   Device = backup80-sd 
  109.  
  110.   Media Type = File 
  111.  
  112. Catalog { 
  113.   Name = MyCatalog 
  114.   dbname = "bacula"dbuser = "bacula"dbpassword = "" 
  115.  
  116. Messages { 
  117.   Name = Standard 
  118.   mailcommand = "/data/bacula-5.2.1/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" 
  119.   operatorcommand = "/data/bacula-5.2.1/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r" 
  120.   mail = pengcheng.xie@ipinyou.com = all, !skipped            
  121.   operator = pengcheng.xie@ipinyou.com = mount 
  122.   console = all, !skipped, !saved 
  123.   append = "/data/bacula-5.2.1/var/bacula/working/log" = all, !skipped 
  124.   catalog = all 
  125.  
  126. Messages { 
  127.   Name = Daemon 
  128.   mailcommand = "/data/bacula-5.2.1/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r" 
  129.   mail = pengcheng.xie@ipinyou.com = all, !skipped            
  130.   console = all, !skipped, !saved 
  131.   append = "/data/bacula-5.2.1/var/bacula/working/log" = all, !skipped 
  132.  
  133. Pool { 
  134.   Name = File 
  135.   Pool Type = Backup 
  136.   Recycle = yes   
  137.   Volumes 
  138.   AutoPrune = yes   
  139.   Volume Retention = 365 days   
  140. reasonable 
  141.  
  142. Console { 
  143.   Name = backup80-mon 
  144.   Password = "PpVNZcD9+QusdjJS9Sr9/H+wMfAdzUtc8eUcBF/YbdFs" 
  145.   CommandACL = status, .status 

 

四、启动bacula

开启bacula程序有两种方式:

4.1 启动bacula所有服务。

   
   
   
   
  1. /data/bacula-5.2.1/sbin/bacula start  

4.2 单独启动bacula某一服务。

 

   
   
   
   
  1. /data/bacula-5.2.1/sbin/bacula-dir start 
  2. /data/bacula-5.2.1/sbin/bacula-sd start 
  3. /data/bacula-5.2.1/sbin/bacula-fd start

第一种开启方式开启了所有能开启的bacula服务:dir、sd和fd。但是根据实际情况,dir、sd、fd往往不在同一台服务器上,有时没有必要在一台服务器上开启所有服务。

根据本次实验的环境来说:

在192.168.144.80上需要开启bacula-sd和bacula-dir。而作为被备份的一端,192.168.144.113上只需要开启bacula-fd即可。

在192.168.144.80上执行:

 

   
   
   
   
  1. /data/bacula-5.2.1/sbin/bacula-dir start 
  2. /data/bacula-5.2.1/sbin/bacula-sd start

在192.168.144.113上执行:

   
   
   
   
  1. /usr/local/bacula-5.2.1/sbin/bacula-fd start 

查看进程和端口是否正确。如果程序没有正常开启,看一下log,进行排错。