開源網絡備份軟件bacula數據恢復(二)

一、bacula的備份恢復過程之完全備份。
1.創建卷組

連接到bacula的控制端,執行備份恢復操作
[root@baculaserver etc]# /usr/local/bacula/sbin/bconsole
Connecting to Director 192.168.137.194:9101
1000 OK: baculaserver.test.com-dir Version: 5.2.6 (21 February 2012)
Enter a period to cancel a command.
*label
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Automatically selected Storage: dbsd
Enter new Volume name: cicro4
Automatically selected Pool: dbpool
Connecting to Storage daemon dbsd at 192.168.137.194:9103 ...
Sending label command for Volume "cicro4" Slot 0 ...
3000 OK label. VolBytes=222 DVD=0 Volume="cicro4" Device="dbdev" (/data/webdata)
Catalog record for Volume "cicro4", Slot 0  successfully created.
Requesting to mount dbdev ...
3906 File device ""dbdev" (/data/webdata)" is always mounted.


2.利用run命令執行備份操作
*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): 1
Run Backup job
JobName:  Client1
Level:    Incremental
Client:   dbfd
FileSet:  dbfs
Pool:     dbpool (From Job resource)
Storage:  dbsd (From Job resource)
When:     2013-04-14 14:37:01
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=1

到此爲止,可以開始備份,bacula-dir.conf配置文件中定義的Client1是一個增量備份,但是由於是第一次備份所以會做一個完全備份,第二次纔會增量備份。

3.查看備份狀態
*status
Status available for:
     1: Director
     2: Storage
     3: Client
     4: All
Select daemon type for status (1-4): 1
baculaserver.test.com-dir Version: 5.2.6 (21 February 2012) x86_64-unknown-linux-gnu redhat
Daemon started 14-Apr-13 14:33. Jobs: run=1, running=0 mode=0,0
 Heap: heap=278,528 smbytes=77,452 max_bytes=91,121 bufs=251 max_bufs=287

Scheduled Jobs:
Level          Type     Pri  Scheduled          Name               Volume
===================================================================================
Differential   Backup    10  14-Apr-13 23:05    Client1            cicro4
Differential   Backup    10  14-Apr-13 23:05    Client             cicro4
Differential   Backup    10  14-Apr-13 23:05    BackupCatalog      cicro4
====

Running Jobs:
Console connected at 14-Apr-13 14:34
No Jobs running.
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
     1  Full          3    4.035 M  OK       14-Apr-13 14:37 Client1

====

由於這裏bacula將備份SD和控制端(DIR)在同一臺服務器上,因此可以用過選項1來查看SD的狀態
如果SD和控制端(DIR)不在同一臺服務器上,要使用選項2來查看

到這裏可以看出JobId 爲1的 備份是一個完全備份,備份的數據文件有3個,大小爲4.035M
備份完成時間爲14-Apr-13 14:37。還可以通過Scheduled Jobs: 看出會在今天晚上23:05分做一次
增量備份。

如果利用run命令再次運行一次備份的話 我們查看狀態,
*status
Status available for:
     1: Director
     2: Storage
     3: Client
     4: All
Select daemon type for status (1-4): 1
baculaserver.test.com-dir Version: 5.2.6 (21 February 2012) x86_64-unknown-linux-gnu redhat
Daemon started 14-Apr-13 14:33. Jobs: run=2, running=0 mode=0,0
 Heap: heap=278,528 smbytes=79,966 max_bytes=93,635 bufs=252 max_bufs=288

Scheduled Jobs:
Level          Type     Pri  Scheduled          Name               Volume
===================================================================================
Differential   Backup    10  14-Apr-13 23:05    Client1            cicro4
Differential   Backup    10  14-Apr-13 23:05    Client             cicro4
Differential   Backup    10  14-Apr-13 23:05    BackupCatalog      cicro4
====

Running Jobs:
Console connected at 14-Apr-13 14:34
No Jobs running.
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
     1  Full          3    4.035 M  OK       14-Apr-13 14:37 Client1
     2  Incr      1,882    7.625 M  OK       14-Apr-13 14:49 Client1

====

我們發現JobId爲2的備份爲一次增量備份。

4.差異備份功能
 執行備份,Client爲我們在bucala-dir.conf中定義的。
*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:     2013-04-14 14:55:48
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=3
You have messages.

查看備份狀態。
*status
Status available for:
     1: Director
     2: Storage
     3: Client
     4: All
Select daemon type for status (1-4): 1
baculaserver.test.com-dir Version: 5.2.6 (21 February 2012) x86_64-unknown-linux-gnu                                                                                    redhat
Daemon started 14-Apr-13 14:33. Jobs: run=3, running=0 mode=0,0
 Heap: heap=278,528 smbytes=87,502 max_bytes=96,019 bufs=264 max_bufs=289

Scheduled Jobs:
Level          Type     Pri  Scheduled          Name               Volume
===================================================================================
Differential   Backup    10  14-Apr-13 23:05    Client1            cicro4
Differential   Backup    10  14-Apr-13 23:05    Client             cicro4
Differential   Backup    10  14-Apr-13 23:05    BackupCatalog      cicro4
====

Running Jobs:
Console connected at 14-Apr-13 14:34
Console connected at 14-Apr-13 14:56
No Jobs running.
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
     1  Full          3    4.035 M  OK       14-Apr-13 14:37 Client1
     2  Incr      1,882    7.625 M  OK       14-Apr-13 14:49 Client1
     3  Full      1,885    15.69 M  OK       14-Apr-13 14:55 Client

====
可以看到JobId爲3的備份任務名字爲Client,是一個完全備份。

在執行以下操作前我們在FD客戶端需要備份的目錄下增加一個文件。

再次運行備份

*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:     2013-04-14 14:58:43
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=4
You have messages.

查看狀態

*status
Status available for:
     1: Director
     2: Storage
     3: Client
     4: All
Select daemon type for status (1-4): 1
baculaserver.test.com-dir Version: 5.2.6 (21 February 2012) x86_64-unknown-linux-gnu redhat
Daemon started 14-Apr-13 14:33. Jobs: run=4, running=0 mode=0,0
 Heap: heap=278,528 smbytes=100,173 max_bytes=113,842 bufs=277 max_bufs=313

Scheduled Jobs:
Level          Type     Pri  Scheduled          Name               Volume
===================================================================================
Differential   Backup    10  14-Apr-13 23:05    Client1            cicro4
Differential   Backup    10  14-Apr-13 23:05    Client             cicro4
Differential   Backup    10  14-Apr-13 23:05    BackupCatalog      cicro4
====

Running Jobs:
Console connected at 14-Apr-13 14:34
Console connected at 14-Apr-13 14:56
No Jobs running.
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
====================================================================
     1  Full          3    4.035 M  OK       14-Apr-13 14:37 Client1
     2  Incr      1,882    7.625 M  OK       14-Apr-13 14:49 Client1
     3  Full      1,885    15.69 M  OK       14-Apr-13 14:55 Client
     4  Diff          2    4.035 M  OK       14-Apr-13 14:58 Client

====

可以看到JobId爲4,名字爲Client的任務是一個差異備份。


5.bacula的完全備份數據恢復

我們通過上面的狀態可以知道JobId爲3的任務是一個完全備份
*restore

First you select one or more JobIds that contain files
to be restored. You will be presented several methods
of specifying the JobIds. Then you will be allowed to
select which files from those JobIds are to be restored.

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: Select full restore to a specified Job date
    13: Cancel
Select item:  (1-13): 3
Enter JobId(s), comma separated, to restore: 3,4
You have selected the following JobIds: 3,4
#這裏僅僅指定 差異備份的一個完全備份和差異備份的JobId就可以恢復數據
Building directory tree for JobId(s) 3,4 ...  +++++++++++++++++++++++++++++++++++++++++++++
1,745 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 *
1,886 files marked.
$ done
Bootstrap records written to /usr/local/bacula/var/bacula/working/baculaserver.test.com-dir.restore.1.bsr

The job will require the following
   Volume(s)                 Storage(s)                SD Device(s)
===========================================================================

    cicro4                    dbsd                      dbdev

Volumes marked with "*" are online.


1,886 files selected to be restored.

Defined Clients:  #指定恢復到那個FD上去
     1: dbfd
     2: dbfs1
Select the Client (1-2): 1
Run Restore job
JobName:         RestoreFiles
Bootstrap:       /usr/local/bacula/var/bacula/working/baculaserver.test.com-dir.restore.1.bsr
Where:           /data/bacula-Restores
Replace:         always
FileSet:         dbfs
Backup Client:   dbfd
Restore Client:  dbfd
Storage:         dbsd
When:            2013-04-14 15:10:41
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
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
    13: Plugin Options
Select parameter to modify (1-13): 9
Please enter path prefix for restore (/ for none): /
Run Restore job
JobName:         RestoreFiles
Bootstrap:       /usr/local/bacula/var/bacula/working/baculaserver.test.com-dir.restore.1.bsr
Where:
Replace:         always
FileSet:         dbfs
Backup Client:   dbfd
Restore Client:  dbfd
Storage:         dbsd
When:            2013-04-14 15:10:41
Catalog:         MyCatalog
Priority:        10
Plugin Options:  *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=5
*

6.增量備份恢復,增量備份的恢復我們只需要在Enter JobId(s), comma separated, to restore: 這一行
填入我們第一次完全備份的JobId號後後面每次增量備份的JobId號即可。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章