Chinaunix首页 | 论坛 | 博客
  • 博客访问: 332009
  • 博文数量: 53
  • 博客积分: 1132
  • 博客等级: 少尉
  • 技术积分: 451
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-18 14:22
文章分类

全部博文(53)

文章存档

2014年(1)

2013年(11)

2012年(17)

2011年(16)

2010年(8)

分类: LINUX

2010-03-18 15:32:19

bacula是一款非常棒的开源备份软件,它采用服务器/客户机的模式来备份文件
 
bacula安装环境:

A.系统平台:CentOS 5.4 最小化安装
B.两台linux主机: 一台主机名为server,ip为192.168.0.5,角色为备份服务器兼存储服务器(另挂一块磁盘到/data/test/下作为存储) 。另一台主机名为client,Ip是192.168.0.6,为需要备份的主机
准备工作:在server上安装mysql和gcc环境(bacula编译需要mysql)
 # yum install mysql mysql-server mysql-devel gcc gcc-c++ make
 # server mysqld start
配置server端:
 1.# tar -zxvf bacula-5.0.1.tar.gz
   # cd bacula-5.0.1
   # ./configure --with-mysql
   # make ; make install            bacula默认安装位置在/etc/bacula
 2.# cd /etc/bacula
   # ./grant_mysql_privileges
   # ./make_mysql_tables
   # ./create_mysql_database    创建bacula需要的数据库
 3.修改配置   作为存储服务器兼控制台,现在需要依次对bacula-dir.Conf(管全局) bacula.sd.conf(管存储)和bconsole.conf(管控制台)配置文件进行修改。bacula-dir.conf是最复杂的一个文件,它一共有10个逻辑段:
 director(定义全局)                         catalog(定义日志)
 jobdefs(定义备份的默认值)                     job(定义特定操作)
 fileset(定义备份哪些区域不备份哪些区域)        schedule(定义备份时间)
 pool(定义备份介质)                          client(定义要备份的主机) 
storage(定义如何存储)                        messages(定义如何处理消息) 
 
# cat /etc/bacula/bacula-dir.conf
Director {                            # 全局的一些配置
Name = server-dir
DIRport = 9101
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/var/bacula/working"
PidDirectory = "/var/run" Maximum Concurrent Jobs = 1   # 定义一次能处理的并发作业数
Password = "123456"             # 这个地方必须与控制台所在主机上的bconsole.conf一致,这里是本机
Messages = Daemon
 }
JobDefs {     # 定义默认备份文件
Name = "DefaultJob"
Type = Backup
Level = Incremental
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File      # 备份设备名称
Messages = Standard
Pool = Default  
Priority = 10     #优先级
}
Job  {                         # 定义一个任务
Name = "Client"                # 任务的名称 后面咱们可以在bacula的控制台中看到
Client = Client                # 引用后面定义的客户端“Client”,表示此任务对名字叫client主机进行操作 JobDefs = "DefaultJob"
Write Bootstrap = "/var/bacula/working/%c.bsr" #定义备份的引导信息放在什么地方
Level = Full                   #定义备份类型为完全
FileSet = "Full Set"           #备份的范围根据后面定义的名叫“Full Set”的操作
Schedule = "WeeklyCycleAfterBackup"     #备份计划任务按"WeeklyCycleAfterBackup" 定义的执行
}
Job {
Name = "BackupCatalog" 
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
RunBeforeJob = "/etc/bacula/make_catalog_backup bacula bacula"
RunAfterJob = "/etc/bacula/delete_catalog_backup"
Write Bootstrap = "/var/bacula/working/BackupCatalog.bsr"
Priority = 11 # run after main backup
}
Job {    #  定义一个还原任务
Name = "RestoreFiles"
Type = Restore
Client=server-fd         #  这里就是指的server这台主机自己
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /bacula-restores  # 还原文件的默认位置
}
FileSet {
Name = "Full Set"
   Include {
             Options {
             signature = MD5
                      }
   File = /boot    # 备份的范围,这里我根据需要只备份了/boot分区,如果要备份其他可加入相应路径         }
    Exclude {       # 排除的,不备份的内容
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck
         }
      }
Schedule  {   #定义备份时间,级别
Name = "WeeklyCycle"
Run = Full 1st sun at 23:05
Run = Differential 2nd-5th sun at 23:05
Run = Incremental mon-sat at 23:05
}
Schedule {
Name = "WeeklyCycleAfterBackup" Run = Full sun-sat at 23:10
}
FileSet {
Name = "Catalog"
        Include {
                 Options {
      signature = MD5
          }
       File = /var/bacula/working/bacula.sql
        }
     }
Client {       # 定义客户端
Name = server-fd
Address = 192.168.0.5    # 指定了server这台主机的地址
FDPort = 9102
Catalog = MyCatalog
Password = "123456" # 要和server上bacula-fd.conf的一致
File Retention = 30 days        # 30 days
Job Retention = 6 months        # six months
AutoPrune = yes                 # Prune expired Jobs/Files
}
Client {
Name = Client                  # 前面引用过的client就是在这定义的
Address = 192.168.0.6          # 告诉服务器client在什么地方
FDPort = 9102
Catalog = MyCatalog
Password = "123456"           # 要和client上bacula-fd.conf的一致
File Retention = 30 days      # 30 days
Job Retention = 6 months      # six months
AutoPrune = yes               # Prune expired Jobs/Files
}
Storage {                      #  定义存储服务器
Name = File
Address = 192.168.0.5          # 告诉服务器数据存储在哪台机器上。这里是主机自己。
SDPort = 9103
Password = "123456"            # 要和本机bacula-sd.conf上一致
Device = FileStorage
Media Type = File              # 定义以文件方式存储
 }
Catalog {                      # 关于日志和数据库的定义
Name = MyCatalog dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
}
Messages {
 Name = Standard
mailcommand = "/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r" operatorcommand = "/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/var/bacula/working/log" = all, !skipped
}
Messages {
Name = Daemon 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
}
Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
 }
Pool {
 Name = Scratch
 Pool Type = Backup
 }
Console {
Name = server-mon
Password = "123456"
CommandACL = status, .status
 }

第二个文件bacula-sd.conf
  # cat /etc/bacula/bacula-sd.conf
Storage {        # 定义存储。本例中是自己server
Name = server-sd
SDPort = 9103 # 存储端口
WorkingDirectory = "/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
Director {
Name = server-dir
Password = "123456" # 与bacula-dir.conf中对应的Storage项一致
}
Director {
ame = server-mon
Password = "123456"
Monitor = yes
}
Device {
Name = FileStorage
Media Type = File
Archive Device = /data/backup      # 定义备份到什么地方
LabelMedia = yes;      # lets Bacula label unlabeled media 
Random Access = Yes;
AutomaticMount = yes;    # 如果设备可用,则读取
RemovableMedia = no;
AlwaysOpen = no;
}
Messages {
Name = Standard director = server-dir = all
 }

最后一个文件bconsole.conf
  # cat /etc/bacula/bconsole.conf
Director {
Name = server-dir
DIRport = 9101
address = 192.168.0.5 # 服务器位置
Password = "123456" # 与bacula-dir.conf中director中一致
}

配置 client
1.# tar -zxvf bacula-5.0.1.tar.gz
  # cd bacula-5.0.1
  # ./configure --enable-client-only
  # make ; make install           # bacula默认安装位置在/etc/bacula
 2. 改配置文件 bacula-fd.conf
  # cat /etc/bacula-fd.conf
   Director {
Name = server-dir   # 与服务器上的bacula-dir.conf中一致
Password = "123456" # 与服务器上的bacula-dir.conf中一致
}
Director {
Name = server-mon   # 与服务器上的bacula-dir.conf中一致
Password = "123456" # 与服务器上的bacula-dir.conf中一致
Monitor = yes
 }
FileDaemon {
Name = Client  # 指自己
FDport = 9102 # 监听端口
WorkingDirectory = /var/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
Messages {
Name = Standard director = Client-dir = all, !skipped, !restored
}
安装完成,在客户端和服务器端/erc/bacula目录下分别执行  ./bacula start 启动bacula主程序
在服务器端 输入 ./bconsole    --> label  --->备份储存位置文件名字,建立存储文件,就可以直接备份了
阅读(1353) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:WordPress mu邮件不能发送的解决方法

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