Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9350751
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类: LINUX

2012-07-18 09:47:02

关于bacula网络备份软件的安装以及配置1  

2011-04-05 13:21:26|  分类: rsync数据同步 |  标签:bacula  job  client  备份  storage   |字号 

最近在网上看到有一个强大的网络备份软件bacula,于是就找了一些资料来看,发现网上的资料寥寥无几啊,凭着自己的理解就在本地环境下面进行了测试,最后终于实现了网络的备份以及还原功能,当然此文章也有不足之处,之后会进行其他方面的一些更新.
 
       网络备份工具bacula配置
简介: Bacula,被誉为开源软件中最好的备份还原软件,它提供了企业级的客户机/服务器的备份解决方案,能够通过网络来管理文件的备份,恢复和核实工作.既有windows版本的,也有LinuxUnix.
 
关于bacula的组建介绍:
Directory:管理所有备份,恢复,验证,和存档事务,定制备份和恢复文件的计划.
 
Storge:指定进行存储和恢复文件属性和数据的物理备份媒介.
 
File:安装在被备份机器上的程序,将被directory调用时候,它提供
      关于自己的操作系统、文件属性、数据等资料.
 
Console:directory进行通讯.
 
Catalog:负责维护所有备份文件的索引和数据库.
 
Monitor:监控directoryfilestorage的守护进程.
试验环境:
  使用2台服务器来做这个网络备份的测试环境,环境如下:
   10.10.2.226          作为directorystoragecatalog.
   10.10.2.162          作为file.
关于bacula的结构图:  关于bacula网络备份软件的安装以及配置1 - zhuzhu - 五事九思
 
一.    Baculaserver上的安装以及配置 1.Baculaserver上的安装
bacula的安装不是很复杂,我这里安装的是bacula2.4.3版本的.
#tar zxvf  bacula-2.4.3.tar.gz
#./configure  --with-mysql
#make&&make intall
默认情况下,bacula的安装路径为/etc/bacula.
2.创建mysql脚本
#./grant_mysql_privileges
#./ create_mysql_database
#./ make_mysql_tables
 
3.bacula的配置
在这里说明下,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
}
 
//directoryjob配置
Job {
  Name =dbjob          //job的名字,这个可以随便起,在后面的备份操作
                         的时候可以看到
  Client=dbfd         //这里要和后面的clientname名字要一样
  Type=backup         //可用类型有backup,restore,verify,admin
  FileSet=dbfs        //这个要和后面的filesetname名字要一样
  Messages=Daemon     //这个要与后面的messagename名字要一样
  Pool=dbpool         //这个要与后面的poolname名字要一样
  Storage=dbsd        //这个要与后面的storagename名字要一样
  Write Bootstrap = "/var/bacula/working/Client1.bsr"
  Level=Full      //这里是备份类型,可用的值是FULL(完全备份),incremental(增量备份),differential(差异备份)
  schedule=dbscd     //这里要与后面的schedulename名字要一样
}
 
//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"    //要与SDpassword一样
  Device =dbdev          //要与SD配置文件的devicename相同
  Media Type = File       //要与SD配置文件deviceMedia 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配置文件的storagename一样
  SDAddress=10.10.2.226   //这里是SDIP
  SDPort = 9103                  
  WorkingDirectory = "/var/bacula/working"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20   //job的最大连接数
}
 
Director {
  Name =linux-0fdr-dir     //这里要与directoryname相同
  Password = "5jipKA7pekDel6BUjgIwD3LkPPBgxcecbLpLfl9puj0c "  //这里与directorystoragepassword相同
}
 
Director {                //这个是做监控的配置
  Name = linux-0fdr-dir 
  Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
  Monitor = yes
 
Device {
  Name =dbdev         //这里要与directorystoragedevice一样
  Media Type = File   //这里要与diretorystorageMedia 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     //这里要与directoryname相 同                            
  DIRport = 9101
  address = 10.10.2.226     //console端的IP
  Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7" 
             //这个密码要与directorypassword一样                                                          
}
 
4.启动bacula的进程
server,只启动directorystorage的进程,启动命令如下:
#./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.
 
注意:上面黄色底红色字的为要输入的内容.
 
二.    baculaclient服务器上的安装和配置 1.安装bacula
#tar zxvf  bacula-2.4.3.tar.gz
# cd bacula-2.4.3
#./configure --enable-client-only
#make&&make install
默认安装在/etc/bacula/目录下
 
2.bacula的配置
#more bacula-fd.conf
 
#####################################################################
 
FD配置:
 
Director
  Name = linux-0fdr-dir     //这里要与directoryname相同
  Password = "Nd+Yuqe+Kd5wBc1S9uMTEGTNqNIe1cupnfuOdwboej6Z"//这里与directoryclientpassword相同
 
}
 
Director {                //这个是做监控的配置
  Name = linux-0fdr-mon
  Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
  Monitor = yes
}
 
FileDaemon {                        
  Name = dbfd            //这里要与diretory job里的client相同
  FDport = 9102
  FDAddress=10.10.2.162   //被备份服务器的IP               
  WorkingDirectory = /var/bacula/working
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
}
 
3.启动baculafd进程
   #bacula-ctl-fd start
 
.备份以及还原过程.
经过艰辛万苦终于走到了这一步,不容易啊,好现在备份下10.10.2.162/home/bacula这个目录,操作如下:
#./bacula
 
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.
*run
Automatically selected Catalog: dbcatalog
Using Catalog "dbcatalog"
A job name must be specified.
The defined Job resources are:
     1: dbjob
     2: restrory
Select Job resource (1-2): 1
Run Backup job
JobName:  dbjob
Level:    Full
Client:   dbfd
FileSet:  dbfs
Pool:     dbpool (From Job resource)
Storage:  dbsd (From Job resource)
When:     2009-08-25 15:23:14
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=54
*list jobs
54 | dbjob    | 2009-08-25 15:23:18 | B    | F     |        0 |          0 | R         |      //这里会出现一个列表,我当前只复制
                             最新的一个JOBID,这里注意红色的R表示已
                             经在运行了,要是E或者C就是有问题了,要
                             是T就表示复制完成了.
*status
Status available for:
     1: Director
     2: Storage
     3: Client
     4: All
Select daemon type for status (1-4): 3
Automatically selected Client: dbfd
Connecting to Client dbfd at 10.10.2.162:9102
………………………………………………………  //这里省略一部分输出信息
 
54  Full      1,628    9.773 M  OK       25- 8?009 15:27 dbjob
                              //看到这里已经显示OK,表示备份成功
现在去看看备份路径下面是否生成了备份文件
 
# du -sh *
9.7M    woyun
可以看到这个卷有9.4M的大小了,原来是4K的文件,再次证明了备份成功了.
 
下面做还原的操作,我们把client端的被备份目录下面文件进行删除
 
[root@localhost bacula]# rm -rf *
[root@localhost bacula]# ls
 
 然后我们到directory端进行还原
 
# ./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.
*restore
Automatically selected Catalog: dbcatalog
Using Catalog "dbcatalog"
 
To select the JobIds, you have the following choices:
     1: List last 20 Jobs run
     2: List Jobs where a given File is saved
     3: Enter list of comma separated JobIds to select
     4: Enter SQL list command
     5: Select the most recent backup for a client
     6: Select backup for a client before a specified time
     7: Enter a list of files to restore
     8: Enter a list of files to restore before a specified time
     9: Find the JobIds of the most recent backup for a client
    10: Find the JobIds for a backup for a client before a specified time
    11: Enter a list of directories to restore for found JobIds
    12: Cancel
Select item:  (1-12): 5
Automatically selected Client: dbfd
Automatically selected FileSet: dbfs
+-------+-------+----------+-----------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes  | StartTime           | VolumeName |
+-------+-------+----------+-----------+---------------------+------------+
|    54 | F     |    1,628 | 9,773,751 | 2009-08-25 15:23:18 | woyun      |
+-------+-------+----------+-----------+---------------------+------------+
You have selected the following JobId: 54
 
Building directory tree for JobId 54 ...  +++++++++++++++++++++++++++++++++++++++++++++++++
1 Job, 1,621 files inserted into the tree.
 
You are now entering file selection mode where you add (mark) and
remove (unmark) files to be restored. No files are initially added, unless
you used the "all" keyword on the command line.
Enter "done" to leave this mode.
 
cwd is: /
$ mark home
1,628 files marked.
$ done
Bootstrap records written to /var/bacula/working/linux-0fdr-dir.restore.1.bsr
 
The job will require the following
   Volume(s)                 Storage(s)                SD Device(s)
===========================================================================
  
   woyun                     dbsd                      dbdev                   
 
 
1,628 files selected to be restored.
 
Run Restore job
JobName:         restrory
Bootstrap:       /var/bacula/working/linux-0fdr-dir.restore.1.bsr
Where:           /home/bacula/
Replace:         always
FileSet:         dbfs
Backup Client:   dbfd
Restore Client:  dbfd
Storage:         dbsd
When:            2009-08-25 16:09:03
Catalog:         dbcatalog
Priority:        10
OK to run? (yes/mod/no): mod
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Restore Client
     6: When
     7: Priority
     8: Bootstrap
     9: Where
    10: File Relocation
    11: Replace
    12: JobId
Select parameter to modify (1-12): 9
Please enter path prefix for restore (/ for none): /home/bacula
Run Restore job
JobName:         restrory
Bootstrap:       /var/bacula/working/linux-0fdr-dir.restore.1.bsr
Where:           /home/bacula
Replace:         always
FileSet:         dbfs
Backup Client:   dbfd
Restore Client:  dbfd
Storage:         dbsd
When:            2009-08-25 16:09:03
Catalog:         dbcatalog
Priority:        10
OK to run? (yes/mod/no): yes
Job queued. JobId=55
*exit
 
OK还原完成,我们现在到client端看看有什么还原回来
[root@localhost bacula]# ls
bacula-2.4.3    bacula-2.4.3.tar.gz
 
看到了已经还原回来了,说明我们的还原操作已经实现了.
阅读(1292) | 评论(0) | 转发(1) |
0

上一篇:开源之备份

下一篇:ubuntu默认root密码

给主人留下些什么吧!~~