Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157326
  • 博文数量: 61
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 345
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-29 10:46
文章分类

全部博文(61)

文章存档

2012年(61)

我的朋友

分类:

2012-12-24 16:25:44

原文地址:实战演示bacula恢复功能 作者:exitgogo

一、实例演示bacula的完全恢复功能

1、通过差异备份进行完全恢复
操作步骤如下:
 

  1. *status  
  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. f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat   
  9. Daemon started 21-Aug-09 15:01, 1 Job run since started.  
  10.  Heap: heap=253,952 smbytes=84,808 max_bytes=85,641 bufs=266 max_bufs=279 
  11.  
  12. Scheduled Jobs:  
  13. Level          Type     Pri  Scheduled          Name               Volume 
  14. =======================================================================  
  15. Incremental    Backup    10  21-Aug-09 23:05    Client1            cicro4  
  16. Incremental    Backup    10  21-Aug-09 23:05    Client             cicro4  
  17. Incremental    Backup    10  21-Aug-09 23:05    BackupCatalog      cicro4  
  18.  
  19. Running Jobs:  
  20. Console connected at 21-Aug-09 16:32  
  21. Console connected at 21-Aug-09 16:33  
  22. No Jobs running.  
  23.  
  24. Terminated Jobs:  
  25.  JobId  Level    Files      Bytes   Status   Finished        Name   
  26. ====================================================================  
  27.     64                3    77.44 K  OK       19-Aug-09 16:57 RestoreFiles  
  28.     65                1         0   OK       19-Aug-09 16:58 RestoreFiles  
  29.     66                2    38.77 K  OK       19-Aug-09 16:59 RestoreFiles  
  30.     67  Full         25    145.5 M  OK       21-Aug-09 13:41 Client1  
  31.     68  Incr          2    3.908 M  OK       21-Aug-09 14:20 Client1  
  32.     69  Full         26    149.4 M  OK       21-Aug-09 14:32 Client  
  33.     70  Diff          2    3.908 M  OK       21-Aug-09 14:34 Client  
  34.     71  Diff          3    7.817 M  OK       21-Aug-09 14:35 Client  
  35.     72  Diff          4    11.72 M  OK       21-Aug-09 14:35 Client  
  36.     73  Incr          4    11.72 M  OK       21-Aug-09 15:34 Client1  
  37.  

从这里的备份状态可知,JobId 为69的任务是一个完全备份,而JobId 为70、71、72的3个任务是差异备份。下面进行恢复操作:
 

  1. * restore  
  2. Automatically selected Catalog: MyCatalog  
  3. Using Catalog "MyCatalog"  
  4.  
  5. First you select one or more JobIds that contain files  
  6. to be restored. You will be presented several methods  
  7. of specifying the JobIds. Then you will be allowed to  
  8. select which files from those JobIds are to be restored.  
  9.  
  10. To select the JobIds, you have the following choices:  
  11.      1: List last 20 Jobs run  
  12.      2: List Jobs where a given File is saved  
  13.      3: Enter list of comma separated JobIds to select  
  14.      4: Enter SQL list command  
  15.      5: Select the most recent backup for a client  
  16.      6: Select backup for a client before a specified time  
  17.      7: Enter a list of files to restore  
  18.      8: Enter a list of files to restore before a specified time  
  19.      9: Find the JobIds of the most recent backup for a client  
  20.     10: Find the JobIds for a backup for a client before a specified time  
  21.     11: Enter a list of directories to restore for found JobIds  
  22.     12: Select full restore to a specified JobId  
  23.     13: Cancel  
  24. Select item:  (1-13): 3  
  25. Enter JobId(s), comma separated, to restore: 69,72  
  26. You have selected the following JobIds: 69,72  
  27.  

#这里仅仅指定了差异备份的第一个全备份和差异备份的最后一个备份的JobId,
#即可完全恢复的数据
 

  1. Building directory tree for JobId(s) 69,72 ...    
  2. 26 files inserted into the tree.  
  3. You are now entering file selection mode where you add (mark) and  
  4. remove (unmark) files to be restored. No files are initially added, unless  
  5. you used the "all" keyword on the command line.  
  6. Enter "done" to leave this mode.  
  7.  
  8. cwd is: /  
  9. $ mark cicro  
  10. 29 files marked.  
  11. $ done  
  12. Bootstrap records written to /opt/bacula/var/bacula/working/f10-64-build-dir.restore.1.bsr  
  13. The job will require the following  
  14.    Volume(s)                 Storage(s)                SD Device(s)  
  15. =======================================================================  
  16.     cicro4                    dbsd                      dbdev                      
  17. Volumes marked with "*" are online.  
  18. 29 files selected to be restored.  
  19. Defined Clients:  #指定恢复到哪个FD上去  
  20.      1: dbfd  
  21.      2: dbfd1  
  22. Select the Client (1-2): 1  
  23. Run Restore job  
  24. JobName:         RestoreFiles  
  25. Bootstrap:       /opt/bacula/var/bacula/working/f10-64-build-dir.restore.1.bsr  
  26. Where:           /tmp/bacula-restores  
  27. Replace:         always  
  28. FileSet:         dbfs  
  29. Backup Client:   dbfd  
  30. Restore Client:  dbfd  
  31. Storage:         dbsd  
  32. When:            2009-08-21 16:35:07  
  33. Catalog:         MyCatalog  
  34. Priority:        10  
  35. Plugin Options:  *None*  
  36. OK to run? (yes/mod/no): mod   
  37. #选择要将数据恢复到的路径,bacula默认恢复到前面指定  
  38. #的/tmp/bacula-restores目录下,在这里,直接将数据恢复到/cicro目录下,  
  39. #因此选择“mod”  
  40. Parameters to modify:   
  41.      1: Level  
  42.      2: Storage  
  43.      3: Job  
  44.      4: FileSet  
  45.      5: Restore Client  
  46.      6: When  
  47.      7: Priority  
  48.      8: Bootstrap  
  49.      9: Where  
  50.     10: File Relocation  
  51.     11: Replace  
  52.     12: JobId  
  53.     13: Plugin Options  
  54. Select parameter to modify (1-13): 9  
  55. Please enter path prefix for restore (/ for none): /    
  56. #这里指定/即可,因为前面已经设置了一个/cicro.  
  57. Run Restore job  
  58. JobName:         RestoreFiles  
  59. Bootstrap:       /opt/bacula/var/bacula/working/f10-64-build-dir.restore.1.bsr  
  60. Where:             
  61. Replace:         always  
  62. FileSet:         dbfs  
  63. Backup Client:   dbfd  
  64. Restore Client:  dbfd  
  65. Storage:         dbsd  
  66. When:            2009-08-21 16:35:07  
  67. Catalog:         MyCatalog  
  68. Priority:        10  
  69. Plugin Options:  *None*  
  70. OK to run? (yes/mod/no): yes  
  71. Job queued. JobId=74 
  72. 这样,一个完全的恢复就通过差异备份方式完成了。可以在远程备份机器(即FD端)上看到,数据已经恢复了。  
  73.  

2、通过增量备份进行完全恢复

执行下面操作前需要先删除FD端的备份目录。
 

  1. *status  
  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. f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat   
  9. Daemon started 21-Aug-09 15:01, 2 Jobs run since started.  
  10.  Heap: heap=253,952 smbytes=100,693 max_bytes=223,457 bufs=280 max_bufs=312 
  11.  
  12. Scheduled Jobs:  
  13. Level          Type     Pri  Scheduled          Name               Volume 
  14. =======================================================================  
  15. Incremental    Backup    10  21-Aug-09 23:05    Client1            cicro4  
  16. Incremental    Backup    10  21-Aug-09 23:05    Client             cicro4  
  17. Incremental    Backup    10  21-Aug-09 23:05    BackupCatalog      cicro4  
  18.  
  19. Running Jobs:  
  20. Console connected at 21-Aug-09 16:32  
  21. Console connected at 21-Aug-09 16:50  
  22. No Jobs running.  
  23.  
  24. Terminated Jobs:  
  25.  JobId  Level    Files      Bytes   Status   Finished        Name   
  26. ====================================================================  
  27.     65                1         0   OK       19-Aug-09 16:58 RestoreFiles  
  28.     66                2    38.77 K  OK       19-Aug-09 16:59 RestoreFiles  
  29.     67  Full         25    145.5 M  OK       21-Aug-09 13:41 Client1  
  30.     68  Incr          2    3.908 M  OK       21-Aug-09 14:20 Client1  
  31.     69  Full         26    149.4 M  OK       21-Aug-09 14:32 Client  
  32.     70  Diff          2    3.908 M  OK       21-Aug-09 14:34 Client  
  33.     71  Diff          3    7.817 M  OK       21-Aug-09 14:35 Client  
  34.     72  Diff          4    11.72 M  OK       21-Aug-09 14:35 Client  
  35.     73  Incr          4    11.72 M  OK       21-Aug-09 15:34 Client1  
  36.     74               29    4.092 G  OK       21-Aug-09 16:35 RestoreFiles  
  37. *restore  
  38. Automatically selected Catalog: MyCatalog  
  39. Using Catalog "MyCatalog"  
  40.  
  41. First you select one or more JobIds that contain files  
  42. to be restored. You will be presented several methods  
  43. of specifying the JobIds. Then you will be allowed to  
  44. select which files from those JobIds are to be restored.  
  45.  
  46. To select the JobIds, you have the following choices:  
  47.      1: List last 20 Jobs run  
  48.      2: List Jobs where a given File is saved  
  49.      3: Enter list of comma separated JobIds to select  
  50.      4: Enter SQL list command  
  51.      5: Select the most recent backup for a client  
  52.      6: Select backup for a client before a specified time  
  53.      7: Enter a list of files to restore  
  54.      8: Enter a list of files to restore before a specified time  
  55.      9: Find the JobIds of the most recent backup for a client  
  56.     10: Find the JobIds for a backup for a client before a specified time  
  57.     11: Enter a list of directories to restore for found JobIds  
  58.     12: Select full restore to a specified JobId  
  59.     13: Cancel  
  60. Select item:  (1-13): 3  
  61. Enter JobId(s), comma separated, to restore: 67,68,73  
  62. You have selected the following JobIds: 67,68,73  
  63. #在这里,JobId为67的备份是一个完全备份,而JobId为68地备份为第一个增量  
  64. #备份,JobId为73的备份为第二个增量备份,如果还有其他增量备份,都要在  
  65. #这里指定,才能完全恢复  
  66. Building directory tree for JobId(s) 67,68,73 ...    
  67. 26 files inserted into the tree.  
  68.  
  69. You are now entering file selection mode where you add (mark) and  
  70. remove (unmark) files to be restored. No files are initially added, unless  
  71. you used the "all" keyword on the command line.  
  72. Enter "done" to leave this mode.  
  73. cwd is: /  
  74. $ mark cicro   #标记恢复  
  75. 29 files marked.  
  76. $ done       #确认操作  
  77. Bootstrap records written to /opt/bacula/var/bacula/working/f10-64-build-dir.restore.2.bsr  
  78. The job will require the following  
  79.    Volume(s)                 Storage(s)                SD Device(s)  
  80. =======================================================================  
  81.     cicro4                    dbsd                      dbdev                      
  82.  
  83. Volumes marked with "*" are online.  
  84. 29 files selected to be restored.  
  85.  
  86. Defined Clients:  
  87.      1: dbfd  
  88.      2: dbfd1  
  89. Select the Client (1-2): 1  
  90. Run Restore job  
  91. JobName:         RestoreFiles  
  92. Bootstrap:       /opt/bacula/var/bacula/working/f10-64-build-dir.restore.2.bsr  
  93. Where:           /tmp/bacula-restores  
  94. Replace:         always  
  95. FileSet:         dbfs  
  96. Backup Client:   dbfd  
  97. Restore Client:  dbfd  
  98. Storage:         dbsd  
  99. When:            2009-08-21 16:52:04  
  100. Catalog:         MyCatalog  
  101. Priority:        10  
  102. Plugin Options:  *None*  
  103. OK to run? (yes/mod/no): mod  
  104. Parameters to modify:  
  105.      1: Level  
  106.      2: Storage  
  107.      3: Job  
  108.      4: FileSet  
  109.      5: Restore Client  
  110.      6: When  
  111.      7: Priority  
  112.      8: Bootstrap  
  113.      9: Where  
  114.     10: File Relocation  
  115.     11: Replace  
  116.     12: JobId  
  117.     13: Plugin Options  
  118. Select parameter to modify (1-13): 9  
  119. Please enter path prefix for restore (/ for none): /  
  120. Run Restore job  
  121. JobName:         RestoreFiles  
  122. Bootstrap:       /opt/bacula/var/bacula/working/f10-64-build-dir.restore.2.bsr  
  123. Where:             
  124. Replace:         always  
  125. FileSet:         dbfs  
  126. Backup Client:   dbfd  
  127. Restore Client:  dbfd  
  128. Storage:         dbsd  
  129. When:            2009-08-21 16:52:04  
  130. Catalog:         MyCatalog  
  131. Priority:        10  
  132. Plugin Options:  *None*  
  133. OK to run? (yes/mod/no): yes  
  134. Job queued. JobId=75 
  135.  

至此,增量备份的完全恢复也完成了,由此可以看出增量备份的恢复与差异备份恢复之间的差异。

二、实例演示bacula的不完全恢复功能


不完全恢复的操作过程与完全恢复基本一致,不同的是,在指定恢复JobId时,不完全恢复只需恢复到指定的某个JobId即可可以用增量备份和差异备份来实现不完全恢复,这里以差异备份为例,操作过程如下:
 

  1. *status  
  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. f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat   
  9. Daemon started 21-Aug-09 15:01, 3 Jobs run since started.  
  10.  Heap: heap=442,368 smbytes=105,435 max_bytes=237,737 bufs=280 max_bufs=312 
  11.  
  12. Scheduled Jobs:  
  13. Level          Type     Pri  Scheduled          Name               Volume 
  14. ===============================================================================  
  15. Incremental    Backup    10  21-Aug-09 23:05    Client1            cicro4  
  16. Incremental    Backup    10  21-Aug-09 23:05    Client             cicro4  
  17. Incremental    Backup    10  21-Aug-09 23:05    BackupCatalog      cicro4  
  18.  
  19. Running Jobs:  
  20. Console connected at 21-Aug-09 16:32  
  21. Console connected at 21-Aug-09 17:19  
  22. No Jobs running.  
  23.  
  24. Terminated Jobs:  
  25.  JobId  Level    Files      Bytes   Status   Finished        Name   
  26. ====================================================================  
  27.     66                2    38.77 K  OK       19-Aug-09 16:59 RestoreFiles  
  28.     67  Full         25    145.5 M  OK       21-Aug-09 13:41 Client1  
  29.     68  Incr          2    3.908 M  OK       21-Aug-09 14:20 Client1  
  30.     69  Full         26    149.4 M  OK       21-Aug-09 14:32 Client  
  31.     70  Diff          2    3.908 M  OK       21-Aug-09 14:34 Client  
  32.     71  Diff          3    7.817 M  OK       21-Aug-09 14:35 Client  
  33.     72  Diff          4    11.72 M  OK       21-Aug-09 14:35 Client  
  34.     73  Incr          4    11.72 M  OK       21-Aug-09 15:34 Client1  
  35.     74               29    4.092 G  OK       21-Aug-09 16:35 RestoreFiles  
  36.     75               29    4.092 G  OK       21-Aug-09 16:52 RestoreFiles  
  37.  

从这里可以看出,JobId 为69到JobId为72都属于差异备份。在进行不完全恢复时,希望将数据恢复到JobId 为71的状态下,可以执行如下操作:
 

  1. *restore  
  2. Automatically selected Catalog: MyCatalog  
  3. Using Catalog "MyCatalog"  
  4.  
  5. First you select one or more JobIds that contain files  
  6. to be restored. You will be presented several methods  
  7. of specifying the JobIds. Then you will be allowed to  
  8. select which files from those JobIds are to be restored.  
  9.  
  10. To select the JobIds, you have the following choices:  
  11.      1: List last 20 Jobs run  
  12.      2: List Jobs where a given File is saved  
  13.      3: Enter list of comma separated JobIds to select  
  14.      4: Enter SQL list command  
  15.      5: Select the most recent backup for a client  
  16.      6: Select backup for a client before a specified time  
  17.      7: Enter a list of files to restore  
  18.      8: Enter a list of files to restore before a specified time  
  19.      9: Find the JobIds of the most recent backup for a client  
  20.     10: Find the JobIds for a backup for a client before a specified time  
  21.     11: Enter a list of directories to restore for found JobIds  
  22.     12: Select full restore to a specified JobId  
  23.     13: Cancel  
  24. Select item:  (1-13): 3  
  25. Enter JobId(s), comma separated, to restore: 69,71  #这里指定数据恢复到什么程度  
  26. You have selected the following JobIds: 69,71  
  27.  
  28. Building directory tree for JobId(s) 69,71 ...    
  29. 25 files inserted into the tree.  
  30.  
  31. You are now entering file selection mode where you add (mark) and  
  32. remove (unmark) files to be restored. No files are initially added, unless  
  33. you used the "all" keyword on the command line.  
  34. Enter "done" to leave this mode.  
  35.  
  36. cwd is: /  
  37. $ mark cicro  
  38. 28 files marked.  
  39. $ done  
  40. Bootstrap records written to /opt/bacula/var/bacula/working/f10-64-build-dir.restore.3.bsr  
  41. The job will require the following  
  42.    Volume(s)                 Storage(s)                SD Device(s)  
  43. ===========================================================================  
  44.     cicro4                    dbsd                      dbdev                      
  45. Volumes marked with "*" are online.  
  46. 28 files selected to be restored.  
  47.  
  48. Defined Clients:  
  49.      1: dbfd  
  50.      2: dbfd1  
  51. Select the Client (1-2): 1  
  52. Run Restore job  
  53. JobName:         RestoreFiles  
  54. Bootstrap:       /opt/bacula/var/bacula/working/f10-64-build-dir.restore.3.bsr  
  55. Where:           /tmp/bacula-restores  
  56. Replace:         always  
  57. FileSet:         dbfs  
  58. Backup Client:   dbfd  
  59. Restore Client:  dbfd  
  60. Storage:         dbsd  
  61. When:            2009-08-21 17:21:16  
  62. Catalog:         MyCatalog  
  63. Priority:        10  
  64. Plugin Options:  *None*  
  65. OK to run? (yes/mod/no): mod  
  66. Parameters to modify:  
  67.      1: Level  
  68.      2: Storage  
  69.      3: Job  
  70.      4: FileSet  
  71.      5: Restore Client  
  72.      6: When  
  73.      7: Priority  
  74.      8: Bootstrap  
  75.      9: Where  
  76.     10: File Relocation  
  77.     11: Replace  
  78.     12: JobId  
  79.     13: Plugin Options  
  80. Select parameter to modify (1-13): 9  
  81. Please enter path prefix for restore (/ for none): /  
  82. Run Restore job  
  83. JobName:         RestoreFiles  
  84. Bootstrap:       /opt/bacula/var/bacula/working/f10-64-build-dir.restore.3.bsr  
  85. Where:             
  86. Replace:         always  
  87. FileSet:         dbfs  
  88. Backup Client:   dbfd  
  89. Restore Client:  dbfd  
  90. Storage:         dbsd  
  91. When:            2009-08-21 17:21:16  
  92. Catalog:         MyCatalog  
  93. Priority:        10  
  94. Plugin Options:  *None*  
  95. OK to run? (yes/mod/no): yes  
  96. Job queued. JobId=76 

最后,查看恢复的路径可以发现,已经将数据恢复到了指定的时间段内,不完全恢复工作完成。
至此,bacula的安装、配置和使用已经介绍完毕。

阅读(618) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~