bacula 网络备份

bacula 的工作原理
一个完整的bacula备份系统由5个部分组成
Director Daemon
负责监听所有备份,恢复,验证,存档事务,以及定制备份和恢复文件计划等,并将整个系统运行状态,记录在一个数据库中,
storage Daemon
在备份数据时用来指定备份和恢复数据的存储介质
file Daemon
一个安装在需要备份数据的机器上的守护进程,在备份数据时候她负责把文件传出,在恢复数据时,她负责接手数据并且恢复操作,配置文件为bacula-fd.conf
console
一个管理控制台,用户可以通过这个控制台连接到director daemon上进行管理备份,与恢复操作,有3种管理方式基于文本的控制台界面,gnome的界面和wxwidgets的图形界面,其配置文件是bconsole.conf
Monitor
一个进程监控端,负责监控director daemon ,storage daemon 和file Daemon 的守护进程

bacula的几种网络拓扑
1:director与SD以及console在一台机器上,客户端fd在另外一台机器上,或者多台机器上
2:director与console在一台机器上,sd在一台机器上,客户端fd在另外一台机器上或者多台机器上
3:diretcor fd ,sd ,console都在一台机器上,相当于自己备份自己的数据

编译安装bacula
环境
baculaserver 192.168.3.128
baculaclient 192.168.3.129

1)
在128上安装baculaserver
wget http://sourceforge.net/projects/bacula/files/bacula/5.0.2/bacula-5.0.2.tar.gz/download
tar -xf bacula-5.0.2.tar.gz
cd bacula-5.0.2
./configure --prefix=/opt/ --with-mysql
如果提示找不到mysql.h安装mysqldevel包
make
make install

2)
在129上安装baculaclient

    6  tar -xf bacula-5.0.2.tar.gz
    7  cd bacula-5.0.2
    8  ls
    9  ./configure --prefix=/opt/ --enable-client-only
   10  make
   11  make install

3)
初始化mysql数据库,穿件bacula对应的mysql数据库以及访问数据库权限,bacula准备了相应的脚本
./grant_mysql_privileges
./create_mysql_database
./make_mysql_tables
!!!!!!!
默认mysql的root密码为空,请确保
mysql上验证
 use bacula;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables
    -> ;
+------------------+
| Tables_in_bacula |
+------------------+
| BaseFiles        |
| CDImages         |
| Client           |
| Counters         |
| Device           |
| File             |
| FileSet          |
| Filename         |
| Job              |
| JobHisto         |
| JobMedia         |
| Location         |
| LocationLog      |
| Log              |
| Media            |
| MediaType        |
| Path             |
| PathHierarchy    |
| PathVisibility   |
| Pool             |
| Status           |
| Storage          |
| UnsavedFiles     |
| Version          |
+------------------+


4)
配置一个bacula备份系统
4.1)
配置bacula的console端
[root@128 etc]# cat bconsole.conf

  
  
  
  
  1. # Bacula User Agent (or Console) Configuration File 
  2.  
  3. Director { 
  4.   Name = 128-dir #控制端名字,会被bacula-dir.conf and bacula-sd.conf会被引用到 
  5.   DIRport = 9101 #控制端服务器的端口 
  6.   address = 192.168.3.128 控制端服务器的ip地址 
  7.   Password = "e64OrwNyOBFzyPtQd6fBzPQJtM4Uz6a4whX6irzmQUlO" #控制端密码文件 
  8. 4.2) 
  9. 配置bacula的dirctor端 
  10. [root@128 etc]# cat bacula-dir.conf 
  11.  
  12. Director {         #定义bacula的全局配置                   # define myself 
  13.   Name = 128-dir 
  14.   DIRport = 9101                # where we listen for UA connections 
  15.   QueryFile = "/opt//etc/query.sql" 
  16.   WorkingDirectory = "/opt//var/bacula/working" 
  17.   PidDirectory = "/var/run" 
  18.   Maximum Concurrent Jobs = 1 #定义一次能处理的最大并发数 
  19.   Password = "e64OrwNyOBFzyPtQd6fBzPQJtM4Uz6a4whX6irzmQUlO"         # Console password 
  20.   Messages = Daemon 
  21. ######################################################################################################## 
  22. Job { #定义增量备份的任务 
  23.   Name = "client1" 
  24.   Type = Backup 
  25.   Level = Incremental #定义备份级别为增量备份,levle的取值范围为 Incremental,Full完全,Differential差异备份 
  26.   Client = testfd #指定备份的客户端主机,在后面client逻辑段中进行定义 
  27.   FileSet = testfs #要指定备份的客户端数据在后面的FileSet逻辑段中进行定义 
  28.   Schedule = testscd #指定这个备份任务的执行时间策略,在后面的schendule逻辑段中进行定义 
  29.   Storage = testsd #指定备份数据的存储路径与介质,在后面的storage逻辑端中进行定义 
  30.   Messages = Standard 
  31.   Pool = testpool  #指定备份使用的pool属性,在后面的pool中指定 
  32.   Priority = 10 
  33.   Write Bootstrap = "/opt//var/bacula/working/client1.bsr" #指定备份引导信息路径 
  34.  
  35. ########################################################################################################## 
  36. Job {           #差异备份 
  37.   Name = "client" 
  38.   Type = Backup 
  39.   FileSet = testfs 
  40.   Schedule = testscd 
  41.   Storage = testsd 
  42.   Messages = Standard 
  43.   Pool = testpool 
  44.   Client = testfd 
  45.   Level = Differential 
  46.   Write Bootstrap = "/opt//var/bacula/working/client.bsr" 
  47.   
  48.  
  49. ########################################################################################################## 
  50. Job {           #完全备份 
  51.   Name = "full" 
  52.   Type = Backup 
  53.   Client = testfd 
  54.   Level = Full 
  55.   FileSet="testfs" 
  56.   Schedule = "testscd" 
  57.   Pool = testpool 
  58.   Storage = testsd 
  59.   Messages = Standard 
  60.   RunBeforeJob = "/opt//etc/make_catalog_backup bacula bacula" 
  61.   RunAfterJob  = "/opt//etc/delete_catalog_backup" 
  62.   Write Bootstrap = "/opt//var/bacula/working/full.bsr" 
  63.  
  64. ########################################################################################################## 
  65. Job {           #还原任务 
  66.   Name = "RestoreFiles" 
  67.   Type = Restore 
  68.   Clienttestfd                 
  69.   FileSet=testfs                  
  70.   Storage = testsd                      
  71.   Pool = testpool 
  72.   Messages = Standard 
  73.   Where = /tmp/bacula-restores #指定默认恢复数据到这个路径 
  74.  
  75.  
  76. ########################################################################################################## 
  77. FileSet {  #定义一个为testfs的备份资源,指定需要备份哪些数据,需要排除哪些数据,可以指定多个fileset 
  78.   Name = "testfs" 
  79.   Include { 
  80.     Options { 
  81.       signature = MD5Compression=GZIP
  82.     } 
  83.     File = /mnt 
  84.   } 
  85.  
  86.   Exclude {  #通过exclude排除不需要备份的文件或者目录,可根据具体情况修改 
  87.     File = /opt//var/bacula/working 
  88.     File = /tmp 
  89.     File = /proc 
  90.     File = /tmp 
  91.     File = /.journal 
  92.     File = /.fsck 
  93.   } 
  94.  
  95. ########################################################################################################## 
  96. Schedule { #定义一个名为testscd的任务调度策略 
  97.   Name = "testscd" 
  98.   Run = Full 1st sun at 23:05 #第一周的星期天晚上23:05进行完全备份 
  99.   Run = Differential 2nd-5th sun at 23:05 #第2-5周的星期日晚上23:05进行差异备份 
  100.   Run = Incremental mon-sat at 23:05 #所有星期一到星期六晚上23:05进行增量备份 
  101.  
  102.  
  103. FileSet { 
  104.   Name = "Catalog" 
  105.   Include { 
  106.     Options { 
  107.       signature = MD5 
  108.     } 
  109.     File = "/opt//var/bacula/working/bacula.sql" 
  110.   } 
  111. ########################################################################################################## 
  112. Client {        #client段用来定义哪个客户端fd的数据 
  113.   Name = testfd 
  114.   Address = 192.168.3.129 
  115.   FDPort = 9102 
  116.   Catalog = MyCatalog #使用哪个数据库存储信息,mycatalog在后面的mycatalog逻辑段中进行定义 
  117.   Password = "LFsHH7nr8h2w0NCaRls8D9VAwKNxhY9++/VO5JgMT8mN"          #director段与客户端的FD验证密码,这个值必须与客户端FD配置文件bacula-fd.conf中密码相同 
  118.   File Retention = 30 days            # 30 days 
  119.   Job Retention = 6 months            # six months 
  120.   AutoPrune = yes                     # Prune expired Jobs/Files 
  121.  
  122. ################################################################################## 
  123.  
  124. Storage {               #用来定义将客户端的数据备份到哪个存储设备上 
  125.   Name = testsd 
  126.   Address = 192.168.3.128                
  127.   SDPort = 9103 
  128.   Password = "2gBQMeX33WVnxRnlapcVV775lmiBrAe6LEr+/3o+BKg/" 
  129.   Device = testdev 
  130.   Media Type = File 
  131. ################################################################################### 
  132. Catalog { 
  133.   Name = MyCatalog 
  134.   dbname = "bacula"dbuser = "bacula"dbpassword = "" 
  135.  
  136. Messages { 
  137.   Name = Standard 
  138.   mailcommand = "/opt//sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" 
  139.   operatorcommand = "/opt//sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r" 
  140.   mail = root@localhost = all, !skipped            
  141.   operator = root@localhost = mount 
  142.   console = all, !skipped, !saved 
  143.   append = "/opt//var/bacula/working/log" = all, !skipped 
  144.   catalog = all 
  145.  
  146. Messages { 
  147.   Name = Daemon 
  148.   mailcommand = "/opt//sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r" 
  149.   mail = root@localhost = all, !skipped            
  150.   console = all, !skipped, !saved 
  151.   append = "/opt//var/bacula/working/log" = all, !skipped 
  152.  
  153. ##################################################################################### 
  154. Pool {          #定义供job任务使用的池属性信息,例如设定备份文件过期时间,是否覆盖过期的备份数据,是否自动清除过期备份等 
  155.   Name = testpool 
  156.   Pool Type = Backup 
  157.   Recycle = yes                       # Bacula can automatically recycle Volumes 
  158.   AutoPrune = yes                     # Prune expired volumes 
  159.   Volume Retention = 7 days 
  160.   Label Format = "db-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}" 
  161.   Maximum Volumes = 7 
  162.   Recycle Current Volume = yes 
  163.   Maximum Volume Jobs = 1 
  164.  
  165.  
  166. ################################################################################# 
  167. Console { 
  168.   Name = 128-mon 
  169.   Password = "VwKvb8Up/nOIpWjHkCDuiRi8vyd+Jf/kZi9bl1oxxw+O" 
  170.   CommandACL = status, .status 


[root@128 etc]#

4.3)
配置bacula的SD
[root@128 etc]# cat bacula-sd.conf

  
  
  
  
  1. Storage {                             # definition of myself 
  2.   Name = 128-sd 
  3.   SDPort = 9103                  # Director's port      
  4.   WorkingDirectory = "/opt//var/bacula/working" 
  5.   Pid Directory = "/var/run" 
  6.   Maximum Concurrent Jobs = 20 
  7.  
  8. Director { 
  9.   Name = 128-dir 
  10.   Password = "2gBQMeX33WVnxRnlapcVV775lmiBrAe6LEr+/3o+BKg/" 
  11.  
  12. Director { 
  13.   Name = 128-mon 
  14.   Password = "VwKvb8Up/nOIpWjHkCDuiRi8vyd+Jf/kZi9bl1oxxw+O" 
  15.   Monitor = yes 
  16.  
  17. Device { 
  18.   Name = testdev 
  19.   Media Type = File 
  20.   Archive Device = /mnt 
  21.   LabelMedia = yes;                   #通过label命令来建立卷文件 
  22.   Random Access = Yes
  23.   AutomaticMount = yes;               # when device opened, read it 
  24.   RemovableMedia = no
  25.   AlwaysOpen = no
  26.  
  27. Messages { 
  28.   Name = Standard 
  29.   director = 128-dir = all 


[root@128 etc]#

4.4)
配置bacula的fd段
[root@129 etc]# cat bacula-fd.conf

  
  
  
  
  1. Director { 
  2.   Name = 128-dir 
  3.   Password = "LFsHH7nr8h2w0NCaRls8D9VAwKNxhY9++/VO5JgMT8mN" 
  4. Director { 
  5.   Name = 128-mon 
  6.   Password = "VwKvb8Up/nOIpWjHkCDuiRi8vyd+Jf/kZi9bl1oxxw+O" 
  7.   Monitor = yes 
  8. FileDaemon {                          # this is me 
  9.   Name = localhost.localdomain-fd 
  10.   FDport = 9102                  # where we listen for the director 
  11.   WorkingDirectory = /opt//var/bacula/working 
  12.   Pid Directory = /var/run 
  13.   Maximum Concurrent Jobs = 20 
  14. Messages { 
  15.   Name = Standard 
  16.   director = 129-dir = all, !skipped, !restored 


[root@129 etc]#

启动和关闭bacula[root@128 etc]# /opt/sbin/bacula stop
Stopping the Bacula File daemon
Stopping the Bacula Storage daemon
Stopping the Bacula Director daemon
[root@128 etc]# /opt/sbin/bacula start
Starting the Bacula Storage daemon
Starting the Bacula File daemon
Starting the Bacula Director daemon
[root@128 etc]#
或者[root@128 etc]# /opt/etc/bacula-ctl-
bacula-ctl-dir  bacula-ctl-fd   bacula-ctl-sd 
{start|stop|restart}依次启动或者关闭服务
查看端口监听
[root@128 etc]# netstat -lantp | grep bacula
tcp        0      0 0.0.0.0:9101                0.0.0.0:*                   LISTEN      15105/bacula-dir   
tcp        0      0 0.0.0.0:9102                0.0.0.0:*                   LISTEN      15097/bacula-fd    
tcp        0      0 0.0.0.0:9103                0.0.0.0:*                   LISTEN      15087/bacula-sd 
[root@128 etc]# /opt/sbin/bconsole
Connecting to Director 192.168.3.128:9101
1000 OK: 128-dir Version: 5.0.2 (28 April 2010)
Enter a period to cancel a command.

客户端上启动file daemon

[root@129 etc]# /opt/sbin/bacula start
Starting the Bacula File daemon
[root@129 etc]# netstat -lantp | grep bacula
tcp        0      0 0.0.0.0:9102                0.0.0.0:*                   LISTEN      27904/bacula-fd
 

本文出自 “风光坏家伙” 博客,转载请与作者联系!

你可能感兴趣的:(职场,bacula,休闲,网络备份)