开源备份软件bacula安装记录--含备份-恢复演练

来源:互联网 发布:如何注册io域名 编辑:程序博客网 时间:2024/06/01 10:05

公司原来的备份机器用的是oracle-linux 5.7 运行的不是很稳定,经常出现死机,新装了一个centos6.5, 准备使用bacula来对数据进行备份,在这里记录一下安装过错,备忘.


操作系统:centos6.5


1、安装mysql

用yum安装

yum install mysql mysql-server mysql-devel

这里要注意的是一定要安装mysql-devel,否则在等下configure bacula的时候会报找不到mysql.h文件--这里折腾了我好久,差点想去编译安装mysql


2、安装bacula-server端

解压

./configure --prefix=/opt/bacula --with-mysql                      #这里只要指定mysql就可以,不需要指定路径,因为bacula会去默认的路径去找mysql

make

make install


3、初始化数据库

初始化的时候要保证mysql的root密码为空。。。。

进入bacula/etc 目录,执行以下命令

[javascript] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. ./grant_mysql_privileges  
  2. ./create_mysql_database  
  3. ./make_mysql_tables   

4、配置bacula Director端\SD端

这里需要配置一个job  一个fileset 一个client 其他用默认的配置即可满足一般要求

下面贴一下我的配置

[javascript] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. Job{                                                          #job的作用是定义一个备份任务,一些参数像差异备份啦 备份周期啦 日志啦等等  
  2.   Name="7.17"  
  3.   Type = Backup  
  4.   Level = Incremental  
  5.   Client = 7.17  
  6.   FileSet = "7.17"  
  7.   Schedule = "WeeklyCycle"  
  8.   Storage = File  
  9.   Messages = Standard  
  10.   Pool = File  
  11.   Priority = 10  
  12.   Write Bootstrap = "/opt/bacula/var/bacula/working/%c.bsr"  
  13. }  
  14.   
  15. FileSet {                                                    #在fileset里面定义客户端要备份的文件或者目录  
  16.   Name = "7.17"  
  17.   Include {  
  18.     Options {  
  19.       signature = MD5  
  20.     }  
  21.     File = "/opt/jdk"  
  22.   }  
  23.   
  24. Client {                                                    #定义客户端的一些参数,比如ip 端口 等  
  25.   Name = 7.17  
  26.   Address = 192.168.7.17  
  27.   FDPort = 9102  
  28.   Catalog = MyCatalog  
  29.   Password = "24H/a2pSWjFxWituyFuB8LpParvcDKgEMywQlxEgxxxx2"          # password for FileDaemon  
  30.   File Retention = 30 days            # 30 days  
  31.   Job Retention = 6 months            # six months  
  32.   AutoPrune = yes                     # Prune expired Jobs/Files  
  33. }  

SD端使用默认配置即可

5、配置FD端--备份客户端

直接上配置,要点就是director的名字和密码要和dir的配置对上!

[javascript] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. Director {  
  2.   Name = Bacula200-dir  
  3.   Password = "24H/a2pSWjFxWituyFuB8LpParvcDKgEMywQlxEgRldd2"  
  4. }  
  5.  
  6. #  
  7. # Restricted Director, used by tray-monitor to get the  
  8. #   status of the file daemon  
  9. #  
  10. Director {  
  11.   Name = Bacula200-mon  
  12.   Password="24H/a2pSWjFxWituyFuB8LpParvcDKgEMywQlxEgRldd2"  
  13.   Monitor = yes  
  14. }  
  15.  
  16. #  
  17. # "Global" File daemon configuration specifications  
  18. #  
  19. FileDaemon {                          # this is me  
  20.   Name = centos-003-fd  
  21.   FDport = 9102                  # where we listen for the director  
  22.   WorkingDirectory = /opt/bacula/var/bacula/working  
  23.   Pid Directory = /var/run  
  24.   Maximum Concurrent Jobs = 20  
  25. }  
  26.  
  27. # Send all messages except skipped files back to Director  
  28. Messages {  
  29.   Name = Standard  
  30.   director = centos-003-dir = all, !skipped, !restored  
  31. }  

6、开始备份、恢复过程

备份首先要创建卷组

在环境变量里面加上 bacula的sbin路径

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. PATH=$PATH:$HOME/bin:/opt/bacula/sbin  
然后使用bconsole进入控制台

然后就可以通过命令控制备份程序了

首先通过label欻关键卷组

然后使用run命令开始操作

备份

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. *run                                                             #开始任务使用run选择刚才创建的任务  
  2. Automatically selected Catalog: MyCatalog  
  3. Using Catalog "MyCatalog"  
  4. A job name must be specified.  
  5. The defined Job resources are:  
  6.      1: BackupClient1  
  7.      2: xxxxxx  
  8.      3: xxxxxx  
  9.      4: BackupCatalog  
  10.      5: RestoreFiles  
  11. Select Job resource (1-5): 1    
  12. Run Backup job  
  13. JobName:  BackupClient1  
  14. Level:    Incremental  
  15. Client:   Bacula200-fd  
  16. FileSet:  Full Set  
  17. Pool:     File (From Job resource)  
  18. Storage:  File (From Job resource)  
  19. When:     2014-07-07 22:32:21  
  20. Priority: 10  
  21. OK to run? (yes/mod/no): yes  
  22. Job queued. JobId=1  
  23. You have messages.  

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. *s                                                                               #使用s查看director来查看任务执行情况  
  2. Status available for:  
  3.      1: Director  
  4.      2: Storage  
  5.      3: Client  
  6.      4: All  
  7. Select daemon type for status (1-4): 1  
  8. Bacula200-dir Version: 5.2.6 (21 February 2012) x86_64-unknown-linux-gnu redhat   
  9. Daemon started 07-Jul-14 22:22. Jobs: run=1running=0 mode=0,0  
  10.  Heap: heap=274,432 smbytes=81,718 max_bytes=95,201 bufs=292 max_bufs=330  
  11.   
  12. Scheduled Jobs:  
  13. Level          Type     Pri  Scheduled          Name               Volume  
  14. ===================================================================================  
  15. Incremental    Backup    10  07-Jul-14 23:05    BackupClient1      20140708  
  16. Incremental    Backup    10  07-Jul-14 23:05    xxxxx              20140708  
  17. Incremental    Backup    10  07-Jul-14 23:05    xxxxx              20140708  
  18. Full           Backup    11  07-Jul-14 23:10    BackupCatalog      20140708  
  19. ====  
  20.   
  21. Running Jobs:  
  22. Console connected at 07-Jul-14 22:30  
  23. No Jobs running.  
  24. ====  
  25.   
  26. Terminated Jobs:  
  27.  JobId  Level    Files      Bytes   Status   Finished        Name   
  28. ====================================================================  
  29.      1  Full         16    10.98 M  OK       07-Jul-14 22:32 BackupClient1  


[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. #任务完成后,如果你登陆控制台,他会给你发下面备份成功的消息,如果失败也会发消息告诉你原因  
  2. Build OS:               x86_64-unknown-linux-gnu redhat                      
  3. JobId:                  1  
  4. Job:                    BackupClient1.2014-07-07_22.32.27_03  
  5. Backup Level:           Full (upgraded from Incremental)  
  6. Client:                 "Bacula200-fd" 5.2.6 (21Feb12) x86_64-unknown-linux-gnu,redhat,  
  7. FileSet:                "Full Set" 2014-07-07 22:32:27  
  8. Pool:                   "File" (From Job resource)  
  9. Catalog:                "MyCatalog" (From Client resource)  
  10. Storage:                "File" (From Job resource)  
  11. Scheduled time:         07-Jul-2014 22:32:21  
  12. Start time:             07-Jul-2014 22:32:29  
  13. End time:               07-Jul-2014 22:32:30  
  14. Elapsed time:           1 sec  
  15. Priority:               10  
  16. FD Files Written:       16  
  17. SD Files Written:       16  
  18. FD Bytes Written:       10,988,458 (10.98 MB)  
  19. SD Bytes Written:       10,990,169 (10.99 MB)  
  20. Rate:                   10988.5 KB/s  
  21. Software Compression:   None  
  22. VSS:                    no  
  23. Encryption:             no  
  24. Accurate:               no  
  25. Volume name(s):         20140708  
  26. Volume Session Id:      1  
  27. Volume Session Time:    1404786153  
  28. Last Volume Bytes:      10,999,377 (10.99 MB)  
  29. Non-fatal FD errors:    0  
  30. SD Errors:              0  
  31. FD termination status:  OK  
  32. SD termination status:  OK  
  33. Termination:            Backup OK  
恢复

[javascript] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. *run                                                            #还是使用run开始  
  2. A job name must be specified.  
  3. The defined Job resources are:  
  4.      1: BackupClient1  
  5.      2: xmygc  
  6.      3: xm214  
  7.      4: BackupCatalog  
  8.      5: RestoreFiles  
  9. Select Job resource (1-5): 5  
  10. Please enter a JobId for restore: 1                            #jobid 可以通过s- dirctory 来查看  
  11. Run Restore job  
  12. JobName:    RestoreFiles  
  13. Bootstrap:  *None*  
  14. Where:      /tmp/bacula-restores  
  15. Replace:         always  
  16. Client:          Bacula200-fd  
  17. Storage:         File  
  18. JobId:           1  
  19. When:            2014-07-08 11:00:35  
  20. Catalog:         MyCatalog  
  21. Priority:        10  
  22. Plugin Options:  *None*  
  23. OK to run? (yes/mod/no): mod                                    #可以选择修改恢复的一些参数,这里选择更改恢复目的地  
  24. Parameters to modify:  
  25.      1: Level  
  26.      2: Storage  
  27.      3: Job  
  28.      4: FileSet  
  29.      5: Restore Client  
  30.      6: When  
  31.      7: Priority  
  32.      8: Bootstrap  
  33.      9: Where  
  34.     10: File Relocation  
  35.     11: Replace  
  36.     12: JobId  
  37.     13: Plugin Options  
  38. Select parameter to modify (1-13): 9  
  39. Please enter path prefix for restore (/ for none): /root/test  
  40. Run Restore job  
  41. JobName:    RestoreFiles  
  42. Bootstrap:  *None*  
  43. Where:      /root/test  
  44. Replace:         always  
  45. Client:          Bacula200-fd  
  46. Storage:         File  
  47. JobId:           1  
  48. When:            2014-07-08 11:00:35  
  49. Catalog:         MyCatalog  
  50. Priority:        10  
  51. Plugin Options:  *None*  
  52. OK to run? (yes/mod/no): yes  
  53. Job queued. JobId=2  

[html] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. #报告恢复完成  
  2. 08-Jul 11:11 Bacula200-dir JobId 4: Start Restore Job RestoreFiles.2014-07-08_11.10.59_11  
  3. 08-Jul 11:11 Bacula200-dir JobId 4: Using Device "FileStorage"  
  4. 08-Jul 11:11 Bacula200-sd JobId 4: Ready to read from volume "20140708" on device "FileStorage" (/home/bak).  
  5. 08-Jul 11:11 Bacula200-sd JobId 4: Forward spacing Volume "20140708" to file:block 0:198.  
  6. 08-Jul 11:11 Bacula200-sd JobId 4: End of Volume at file 0 on device "FileStorage" (/home/bak), Volume "20140708"  
  7. 08-Jul 11:11 Bacula200-sd JobId 4: End of all volumes.  
  8. 08-Jul 11:11 Bacula200-dir JobId 4: Bacula Bacula200-dir 5.2.6 (21Feb12):  
  9.   Build OS:               x86_64-unknown-linux-gnu redhat   
  10.   JobId:                  4  
  11.   Job:                    RestoreFiles.2014-07-08_11.10.59_11  
  12.   Restore Client:         Bacula200-fd  
  13.   Start time:             08-Jul-2014 11:11:01  
  14.   End time:               08-Jul-2014 11:11:01  
  15.   Files Expected:         0  
  16.   Files Restored:         16  
  17.   Bytes Restored:         10,988,458  
  18.   Rate:                   0.0 KB/s  
  19.   FD Errors:              0  
  20.   FD termination status:  OK  
  21.   SD termination status:  OK  
  22.   Termination:            Restore OK  

0 0
原创粉丝点击