一、例項演示bacula的完全備份功能
1.建立卷組
執行如下命令,連線到bacula控制端,執行備份恢復操作:
- [root@baculaserver opt]#/opt/bacula/sbin/bconsole
- Connecting to Director 192.168.12.188:9101
- 1000 OK: f10-64-build-dir Version: 3.0.2 (18 July 2009)
- Enter a period to cancel a command
- *label
- Automatically selected Storage: dbsd
- Enter new Volume name: cicro4 #卷組名稱,可隨意指定,指定完畢後會在
- #bacula-dir.conf檔案的指定位置生成一個cicro4檔案
- Defined Pools:
- 1: dbpool
- 2: Scratch
- Select the Pool (1-2): 1 #指定卷組的放置位置,即為SD名稱。
- #Dbpool在bacula-dir.conf中定義
- Connecting to Storage daemon dbsd at 192.168.12.188:9103 ... #由於指定SD在
- #192.168.12.188主機上,因此將卷cicro4建立到了此主機上
- Sending label command for Volume "cicro4" Slot 0 ...
- 3000 OK label. VolBytes=191 DVD=0 Volume="cicro4" Device="dbdev" (/cicro/backup2)
- Catalog record for Volume "cicro4", Slot 0 successfully created.
- Requesting to mount dbdev ...
- 3906 File device "dbdev" (/cicro/backup2) is always mounted.
2.利用run命令執行備份操作
下面繼續在bacula控制端執行備份操作:
- *run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1 #這裡的Client1 是在bacula-dir.conf中定義的一個Job執行任務
- 2: Client #這裡的Client 也是在bacula-dir.conf中定義的一個Job執行任務
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-2): 1
- Run Backup job
- JobName: Client1
- Level: Incremental
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 13:40:13
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=67
到此為止,可以開始執行備份,在bacula-dir.conf檔案中定義的Client1是一個增量備份,因此這個備份只是個增量操作。由於這是第一個備份,因此預設Client1會做一個完全備,第二次備份時,才執行增量備份。
3.檢視備份狀態
在bacula控制端利用“status”可以檢視bacula的各種狀態,這裡檢視備份時Director端的一個狀態資訊。
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 13:22, 0 Jobs run since started.
- Heap: heap=241,664 smbytes=82,242 max_bytes=82,498 bufs=245 max_bufs=250
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===============================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Running Jobs:
- Console connected at 21-Aug-09 13:37
- JobId Level Name Status
- ======================================================================
- 67 Full Client1.2009-08-21_13.40.16_07 is running
- 由此可知,備份正在進行,備份完成再次檢視備份資訊,輸出如下:
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- 由於這裡bacula將備份的儲存端(SD)和控制端(DIR)設定在一臺伺服器上,因此可以通過選項1“Director”來檢視SD的狀態,如果SD端和DIR端不在一臺伺服器上,要檢視選項2,即“Storage”。這裡選擇選項1r後輸出內容如下:
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 13:22, 1 Job run since started.
- Heap: heap=241,664 smbytes=73,891 max_bytes=84,825 bufs=212 max_bufs=250
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===============================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Running Jobs:
- Console connected at 21-Aug-09 13:42
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 58 Incr 2 46.85 M OK 19-Aug-09 16:51 Client1
- 59 Incr 2 3.908 M OK 19-Aug-09 16:51 Client1
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
這裡可以看到,JobId為67的備份是一個完全備份,備份資料的檔案數為25個,備份壓縮後的大小為145.5MB,備份完成在“21-Aug-09 13:41”,最後的Client1是備份資源的名稱。
二、例項演示bacula的增量備份功能
在上面的操作中,設定的備份資源Job本身就是一個增量備份,下面執行的備份操作與上面完全相同,不同的是,這裡是第二次備份,bacula會按照設定執行增量備份,操作如下程式碼清單如下所示。
執行增量備份
- * run
- Automatically selected Catalog: MyCatalog
- Using Catalog "MyCatalog"
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-2): 1
- Run Backup job
- JobName: Client1
- Level: Incremental
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:20:24
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=68
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 13:22, 2 Jobs run since started.
- Heap: heap=241,664 smbytes=84,576 max_bytes=97,749 bufs=218 max_bufs=252
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===============================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:19
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 59 Incr 2 3.908 M OK 19-Aug-09 16:51 Client1
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
從最後的備份列表可以看出,系統進行了增量備份,“3.908 M”就是上次備份與這次備份之間的資料增加量。而JobId =68這個備份的Level級別為Incr也說明了此次備份為增量備份。
三、例項演示bacula的差異備份功能
差異備份與增量備份的原理,前面已經介紹過了,這裡只給出具體的操作步驟。
1.開始執行備份
- *run
- Automatically selected Catalog: MyCatalog
- Using Catalog "MyCatalog"
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2 #這裡有兩個Job任務可選,名為Client1的為增量
- #備份操作,名為Client的為差異備份操作
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:31:04
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=69
- You have messages.
- 至此,開始執行差異備份,如果備份的資料量較大,可能需要一段時間才能完成備份。下面可以用“status”指令檢視備份的狀態。
- 2.檢視備份狀態
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 0 Jobs run since started.
- Heap: heap=253,952 smbytes=67,810 max_bytes=68,066 bufs=267 max_bufs=272
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- JobId Level Name Status
- ======================================================================
- 69 Full Client.2009-08-21_14.31.10_03 is running
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 59 Incr 2 3.908 M OK 19-Aug-09 16:51 Client1
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 從上面可以看到,備份還沒有完成,備份狀態為running。
- 等待幾分鐘,再次檢視備份狀態如下:
- * status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 1 Job run since started.
- Heap: heap=253,952 smbytes=65,680 max_bytes=78,853 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ==========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 60 Incr 2 8.377 K OK 19-Aug-09 16:52 Client1
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 從這裡可以看到,JobId為69的備份已經完成,並且是一個完全備份,備份檔案大小為149.4MB,而完成此差異備份的Job任務名稱是Client。
- 3.繼續執行備份操作
- 在執行下面的操作前,首先在客戶端FD需要備份的資料夾下(根據前面的配置可知,應該是/cws3)增加一個大小為3.8MB左右的檔案。
- * run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:34:25
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=70
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 2 Jobs run since started.
- Heap: heap=253,952 smbytes=67,989 max_bytes=81,162 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 61 Incr 1 0 OK 19-Aug-09 16:53 Client1
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 70 Diff 2 3.908 M OK 21-Aug-09 14:34 Client
從JobId為70的備份資訊可以看出,此備份為差異增量備份,此次進行差異備份的資料量大小剛好為3.908 MB,與前面增加的檔案大小基本相同。
為了證明是前面執行的是差異增量備份,在FD端需要備份的資料夾下再次增加一個大小為3.8MB左右的一個檔案,繼續執行以下備份操作:
- *run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:34:59
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=71
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 3 Jobs run since started.
- Heap: heap=253,952 smbytes=69,087 max_bytes=82,260 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 62 Incr 2 8.344 K OK 19-Aug-09 16:53 Client1
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 70 Diff 2 3.908 M OK 21-Aug-09 14:34 Client
- 71 Diff 3 7.817 M OK 21-Aug-09 14:35 Client
由JobId為71的備份可以看出,此次備份的大小為7.817 M,剛好是上次差異增量備份的大小與此次增加檔案的大小之和,由此證明確實為差異備份。
第三次在FD端需要備份的資料夾下增加一個大小為3.8M左右的一個檔案,繼續執行備份操作:
- *run
- A job name must be specified.
- The defined Job resources are:
- 1: Client1
- 2: Client
- 3: BackupCatalog
- 4: RestoreFiles
- Select Job resource (1-4): 2
- Run Backup job
- JobName: Client
- Level: Differential
- Client: dbfd
- FileSet: dbfs
- Pool: dbpool (From Job resource)
- Storage: dbsd (From Job resource)
- When: 2009-08-21 14:35:32
- Priority: 10
- OK to run? (yes/mod/no): yes
- Job queued. JobId=72
- *status
- Status available for:
- 1: Director
- 2: Storage
- 3: Client
- 4: All
- Select daemon type for status (1-4): 1
- f10-64-build-dir Version: 3.0.2 (18 July 2009) x86_64-unknown-linux-gnu redhat
- Daemon started 21-Aug-09 14:30, 4 Jobs run since started.
- Heap: heap=253,952 smbytes=69,087 max_bytes=82,260 bufs=240 max_bufs=274
- Scheduled Jobs:
- Level Type Pri Scheduled Name Volume
- ===========================================================================
- Incremental Backup 10 21-Aug-09 23:05 Client1 cicro4
- Incremental Backup 10 21-Aug-09 23:05 Client cicro4
- Incremental Backup 10 21-Aug-09 23:05 BackupCatalog cicro4
- Running Jobs:
- Console connected at 21-Aug-09 14:30
- No Jobs running.
- Terminated Jobs:
- JobId Level Files Bytes Status Finished Name
- ====================================================================
- 63 Incr 2 8.377 K OK 19-Aug-09 16:54 Client1
- 64 3 77.44 K OK 19-Aug-09 16:57 RestoreFiles
- 65 1 0 OK 19-Aug-09 16:58 RestoreFiles
- 66 2 38.77 K OK 19-Aug-09 16:59 RestoreFiles
- 67 Full 25 145.5 M OK 21-Aug-09 13:41 Client1
- 68 Incr 2 3.908 M OK 21-Aug-09 14:20 Client1
- 69 Full 26 149.4 M OK 21-Aug-09 14:32 Client
- 70 Diff 2 3.908 M OK 21-Aug-09 14:34 Client
- 71 Diff 3 7.817 M OK 21-Aug-09 14:35 Client
- 72 Diff 4 11.72 M OK 21-Aug-09 14:35 Client
第三次執行備份,從JobId為72的備份可以很清楚地看出差異備份與增量備份的差別。