天天看點

Centos 6.3 部署Bacula實作遠端備份還原

Bacula是一款開源的跨平台網絡備份工具,提供基于企業級的CS的備份解決方案。可以對資料進行備份、恢複、以及完整性校驗。 功能特點: 支援完全備份,增量備份,差異備份。 支援多種恢複方式 支援多種檔案系統下的備份恢複(ext3、ext2、reiserfs、xfs、jfs、smbfs、iso9660、ntfs等) 支援各種備份媒體 支援多種作業系統 強大的内部功能 一個完整的bacula備份系統,由下面5個部分組成 Director Daemon:負責監聽所有的備份、恢複、驗證、存檔事務,以及定制備份和恢複檔案計劃等,并将整個系統運作狀況記錄在一個資料庫檔案中。其配置檔案為bacula-dir.conf。 Storage Daemon(SD):主要負責将資料備份到存儲媒體上,而在資料恢複時,負責将資料從存儲媒體中傳送出去。其配置檔案為bacula-sd.conf。 File Daemon(FD):安裝在需要備份資料的機器上的守護程序,在備份資料時,它負責把檔案傳出,在恢複資料時負責接收資料并執行恢複操作。配置檔案為bacula-fd.conf。 Console:管理控制台。可以通過這個控制台連接配接到Director Daemon進行管理備份與恢複操作。 Monitor:程序監控端。 工作流程: 1、通過console連接配接到Director端,備份恢複操作開始。 2、Director端從自己的資料庫中調出記錄資訊,對存儲端SD與用戶端FD的任務進行協調。 3、用戶端FD負責驗證Director的操作許可,如果驗證通過,則允許連接配接到存儲端SD 4、用戶端FD根據Director發出的請求去連接配接SD,将FD端的資料備份到存SD指定的存儲媒體上,或者将SD端存儲媒體中的資料傳回到用戶端FD指定的位置上,完成備份恢複過程。

個人感覺Bacula在國内生産環境中似乎用的很少,也不知道有多少人用過這款備份工具,不過我個人還是覺得該備份工具還是很優秀的,望同樣喜歡Bacula 或者 研究Bacula的朋友可以聯系我,一起來深入了解這款備份工具!

1. Bacula 主要端安裝

1.1. 介紹

本文檔将介紹基于Centos 6.3系統平台的操作指南,試圖讓你使用簡單指令快速從源程式安裝Bacula。

如果你使用系統是Fedroa、Redhat或Centos 的其他Linux發行版,也可參照此文檔。指令名、路徑等可能因不同的發行包或作業系統而不同,因而這時你可能需要些努力來搞一下安裝文檔裡的東西。

<a href="http://www.itchenyi.com/wp-content/uploads/2013/01/baculalg.jpg"></a>

注:本過程均架構在Centos6.3 其使用的Bacula版本問5.2.6。在文中深藍色加粗字型均為注視,斜體為問題解決方式,紅色加粗為我在操作中輸入的部分。本文章出自www.itchenyi.com,允許轉載,但請保留原文連接配接。

1.2. 準備軟體包

在做安裝之前确認要對該機器擁有root權限。

确認你安裝好的系統上已經安裝如下軟體包再繼續。

資料庫使用Mysql

Mysql

GCC編譯器

驗證一下

[root@chenyi ~]# rpm -qa gcc gcc-c++ mysql mysql-devel mysql-server        #由于我用的一個mini版,是以都沒有裝

這裡可以使用yum指令完成安裝。

[root@chenyi ~]# mount /dev/cdrom /media          #挂載CD光牒

mount: block device /dev/sr0 is write-protected, mounting read-only

[root@chenyi ~]# vi /etc/yum.repos.d/CentOS-Media.repo          #配置yum檔案

[root@chenyi ~]# yum install gcc gcc-c++                          #安裝gcc gcc-c++

[root@chenyi ~]# yum install mysql mysql-devel mysql-server       #安裝mysql

1.3 現在最新版本 bacula  

1.4. 部署操作過程

1.4.1. 下載下傳源程式包

[chenyi@chenyi ~]$ su -l                           #切換為root使用者

建立存儲下載下傳檔案的目錄,下載下傳Bacula源程式,程式版本為5.2.6。

[root@chenyi ~]# mkdir /opt/bacula

[root@chenyi ~]# cd /opt/bacula

[root@chenyibacula]# wget http://nchc.dl.sourceforge.net/project/bacula/bacula/5.2.6/bacula-5.2.6.tar.gz

1.4.2. 編譯并安裝Bacula

解壓縮Bacula源程式包

[root@chenyi bacula]# tar zxf bacula-5.2.6.tar.gz

[root@chenyi bacula]# cd bacula-5.2.6

設定環境變量,将$HOME設定為/usr/local

[root@chenyi bacula-5.2.6]# HOME=/usr/local/

[root@chenyi bacula-5.2.6]# CFLAGS="-g -Wall"

運作Bacula配置腳本,這裡介紹下configure的常用參數,更詳細的說明可檢視官方文檔。

-prefix=&lt;patch&gt;              #指定Bacula安裝目錄;

-sbindir=&lt;binary-path&gt;                 #指定可執行檔案存放目錄;

-sysconfdir=&lt;config-path&gt;           #指定配置檔案存放目錄;

-enable-smartalloc                         #強烈建議啟用此選項。有助于檢測記憶體洩漏;

-enable-bat                                    # 啟用Bacula圖形化管理工具BAT(Bacula Admin Tool)。依賴Qt4 &gt;= 4.3.4,在開源站點Sourceforge的Bacula項目中下載下傳此程式安裝包(depkgs-qt)。Qt4必須在安裝Bacula之前安裝完 成。詳細說明可檢視官方文檔Dependency Packages。Bacua Client for Windows的版本中已包含此程式,安裝簡單而且很友好,界面及功能和Linux平台下的一樣;

-enable-bwx-console              #啟用基于wxWidgets的圖像界面控制台。詳細說明可檢視官方文檔Dependency Packages;

-enable-tray-monitor              #啟用托盤監控工具。它需要不高于2.2版本的GNOME,不低于3.1版本的KDE,或者支援FreeDesktop系統托盤的任何标準視窗管理器;基于GTK &gt;=2.10;

-enable-client-only                  #啟用該選項表示隻安裝Bacula用戶端;

with-sqlite3=&lt;sqlite3-path&gt;      #啟用該選項表示Bacula使用SQLite3資料庫。在開源站點Sourceforge的Bacula項目中可以下載下傳SQLite3資料庫安裝包(depkgs),需要了解詳細操作可檢視官方文檔Dependency Packages;

-with-mysql=&lt;mysql-path&gt;       #啟用該選項表示Bacula使用MySQL資料庫;

-with-postgresql=&lt;path&gt;           #啟用該選項表示Bacula使用PostgreSQL資料庫;

-enable-conio                             #這個地方水準不夠,是以沒能翻譯過來,如有高手還望指點我一番,Tells Bacula to enable building the small, light weight readline replacement routine. It is generally much easier to configure than readline, although, like readline, it needs either the termcap or ncurses library;

-with-working-dir=&lt;working-directory-path&gt;    #此選項是強制的。指定Bacula運作時的檔案存儲目錄;

-with-pid-dir=&lt;PATH&gt;               #指定Bacula程序ID檔案存放目錄。預設目錄為/var/run。此目錄必須手工建立;

-with-subsys-dir=&lt;PATH&gt;        指定Bacula運作時subsystem加鎖檔案存放目錄。預設目錄為/var/lock/subsys。此目錄必須手工建立。

預配置

以下為執行結果

安裝Bacula之後相關的檔案存儲目錄會按照此結果儲存,可記錄下來日後友善查詢

編譯并安裝Bacula

[root@chenyi bacula-5.2.6]# make

[root@chenyi bacula-5.2.6]# make install

[root@chenyi bacula-5.2.6]# make install-autostart     #添加自動啟動守護程序

[root@chenyi bacula-5.2.6]# ls /etc/rc.d/init.d/ | grep bacula     #檢視是否成功

bacula-dir

bacula-fd

bacula-sd

1.4.3. 建立Bacula用的資料庫

啟動MySQL并添加至随系統自動啟動

[root@chenyi bacula-5.2.6]# service mysqld start

[root@chenyi bacula-5.2.6]# chkconfig --level 2345 mysqld on

進入Bacula可執行檔案目錄并建立資料庫Bacula使用者權限

[root@chenyi bacula-5.2.6]# cd src/cats/

[root@chenyi cats]# ./grant_mysql_privileges -p

建立Bacula 資料庫

[root@chenyi cats]# ./create_mysql_database -p

Enter password:

Creation of bacula database succeeded.

建立Bacula使用的表

[root@chenyi cats]# ./make_mysql_tables -p

Creation of Bacula MySQL tables succeeded.

到此,Bacula主要端就安裝完成了,還需要對Bacula進行配置。

作為存儲伺服器兼控制台,現在需要依次對bacula-dir.Conf(全局)  bacula.sd.conf(存儲)和bconsole.conf(控制台)配置檔案進行修改。

1 配置bacula的Console端

Director {

Name = chenyi-dir            #控制端名稱,在下面的bacula-dir.conf和bacula-sd.conf檔案中會陸續的被引用

DIRport = 9101                                            #控制端伺服器端口

address = 192.168.1.220                          #控制端伺服器IP

Password = "kl1h6gcOxkzFAWFUb1bl7bvtyiwW702QsypPHPgcuTdK" #控制端伺服器密碼檔案

}

2 配置bacula的Director端

         bacula-dir.conf是Director端的配置檔案,也是bacula的核心配置檔案,這個檔案非常複雜,共分為10個邏輯段,分别是:

1、Director,定義全局設定

2、Catalog,定義背景資料庫

3、Jobdefs,定義預設執行任務

4、Job,自定義一個備份或者恢複任務

5、Fileset,定義備份哪些資料,不備份哪些資料

6、Schedule,定義備份時間政策

7、Pool,定義供Job使用的池屬性

8、Client,定義要備份的主機位址

9、Storage,定義資料的存儲方式

10、Messages,定義發送日志報告和記錄日志的位置

下面為一個配置好的檔案,其中#号後面的内容為注視。(其中部分地方Bacula有英文注釋,恰好我英文也不咋滴)

Director {             #定義Bacula的全局配置       

Name = chenyi-dir

DIRport = 9101

QueryFile = "/usr/local//bacula/bin/query.sql"

WorkingDirectory = "/usr/local//bacula/bin/working"

PidDirectory = "/usr/local//bacula/bin/working"

Maximum Concurrent Jobs = 1        #定義一次能處理的最大并發數

         #驗證密碼,這個密碼必須與bconsole.conf檔案中對應的Director邏輯段密碼相同

Password = "kl1h6gcOxkzFAWFUb1bl7bvtyiwW702QsypPHPgcuTdK"

         #定義日志輸出方式,“Daemon”在下面的Messages邏輯段中進行了定義

Messages = Daemon

JobDefs {

Name = "Client1"

Type = Backup

Level = Incremental

Client = dbfd                  # 如果本機也需備份就在後面去定義dbfd為本機

FileSet = "dbfs"

Schedule = "dbscd"

Storage = dbsd

Messages = Standard

Pool = dbpool

Priority = 10

Write Bootstrap = "/usr/local//bacula/bin/working/%c.bsr"

Job {                                              #自定義一個備份任務

Name = "wanquanbeifen"       #備份任務名稱

Client = dbfd1                              #指定要備份的用戶端主機,“dbfd”在後面Client邏輯段中進行定義

Level = Full                                  #定義備份的級别,Incremental為增量備份。Level的取值#可為Full(完全備份)、Incremental(增量備份)和Differential(差異備份),如果第一#次沒做完全備份,則先進&gt;行完全備份後再執行Incremental

Type = Backup                            #定義Job的類型,“backup”為備份任務,可選的類型還有restore和verify等

FileSet = "dbfs"                          #指定要備份的用戶端資料,“dbfs”在後面FileSet邏輯段中進行定義

Schedule = "dbscd"                    #指定這個備份任務的執行時間政策,“dbscd”在後面的Schedule邏輯段中行了定義

Storage = dbsd                           #指定備份資料的存儲路徑與媒體,“dbsd” 在後面的Storage邏輯段中進行定

Pool = dbpool                    #指定備份使用的pool屬性,“dbpool”在後面的Pool邏輯段中進行定義。

Write Bootstrap = "/usr/local//bacula/working/Client2.bsr" #指定備份的引導資訊路徑

Job {

Client = dbfd

Write Bootstrap = "/usr/local//bacula/working/Client2.bsr"

Job {                           #定義一個名為Client的差異備份的任務

Name = "Client"

Level = Differential           #指定備份級别為差異備份

Write Bootstrap = "/usr/local//bacula/working/Client1.bsr"

Job {                                     #定義一個還原任務

Name = "RestoreFiles"

Type = Restore                 #定義Job的類型為“Restore ”,即恢複資料

Client=dbfd1

FileSet=dbfs

Where = /tmp/bacula-restores        #指定預設恢複資料到這個路徑

FileSet {                                                   #定義一個名為dbfs的備份資源,也就是指定需要備份哪些資料,需要排除哪些資料等,可以指定多個FileSet

Name = "dbfs"

Include {

Options {

signature = MD5; Compression=GZIP; }         #表示使用MD5簽名并壓縮

File = /boot                                                              #指定用戶端FD需要備份的檔案目錄

Exclude {                                                                   #通過Exclude排除不需要備份的檔案或者目錄,可根據具體情況修改

File = /usr/local//bacula/working

File = /tmp

File = /proc

File = /.journal

File = /.fsck

Schedule {                                                                 #定義一個名為dbscd的備份任務排程政策

Name = dbscd

Run = Full 1st sun at 23:05                                 #第一周的周日晚23:05分進行完全備份

Run = Differential 2nd-5th sun at 23:05          #第2~5周的周日晚23:05進行差異備份

Run = Incremental mon-sat at 23:05               #所有周一至周六晚23:05分進行增量備份

FileSet {

Name = "Catalog"

signature = MD5

File = /usr/local//bacula/bin/working/bacula.sql

Client {                                                            #Client用來定義備份哪個用戶端FD的資料

Name = dbfd                                                 #Clinet的名稱,可以在前面的Job中調用

Address = 192.168.1.210                            #要備份的用戶端FD主機的IP位址

FDPort = 9102                                               #與用戶端FD通信的端口

Catalog = MyCatalog                                 #使用哪個資料庫存儲資訊,“MyCatalog”在後面的MyCatalog邏輯段中進定義

Password = "XqJ0aC66ZHt3REH1sFj6wfnTZGdQSd8oqOv+W9cJ+zkh" #Director端與用戶端FD的驗證密碼,這個值必須與用戶端FD配置檔案bacula-fd.conf中密碼相同

File Retention = 30 days                             #指定儲存在資料庫中的記錄多久循環一次,這裡是30天,隻影響數&gt;據庫中的記錄不影響備份的檔案

Job Retention = 6 months                           #指定Job的保持周期,應該大于File Retention指定的值

AutoPrune = yes                                           #當達到指定的保持周期時,是否自動删除資料庫中的記錄,yes表示自動清除&gt;過期的Job

Client {

Name = dbfd1

Address = 192.168.1.210

FDPort = 9102

Catalog = MyCatalog

Password = "XqJ0aC66ZHt3REH1sFj6wfnTZGdQSd8oqOv+W9cJ+zkh2"

File Retention = 30 days

Job Retention = 6 months

AutoPrune = yes

Storage {                                                # Storage用來定義将用戶端的資料備份到哪個儲存設備上

Name = dbsd

Address = 192.168.1.220                 #指定存儲端SD的IP位址

SDPort = 9103                                     #指定存儲端SD通信的端口

Password = "U1NXyNwriNYIH7SulVmKp/uGTYiy2C5OY7wnSqkz2voU" #Director端與存儲端SD的驗證密碼,這個值必須與存儲端SD配置檔案bacula-sd.conf中Director邏輯段密碼相同

Device = FileStorage                           #指定資料備份的存儲媒體,必須與存儲端(這裡是192.168.1.220)的bacula-sd.conf配置檔案中的“Device” 邏輯段的“Name”項名稱相同

Media Type = File                                #指定存儲媒體的類别,必須與存儲端SD(這裡是192.168.1.220)的bacula-sd.conf配置檔案中的“Device” 邏輯段的“Media Type”項名稱相同

Catalog {                                               # Catalog邏輯段用來定義關于日志和資料庫設定

Name = MyCatalog

dbname = "bacula"; dbuser = "bacula"; dbpassword = "" #指定庫名、使用者名和密碼

Messages {                                          # Messages邏輯段用來設定Director端如何儲存日志,以及日志的儲存格式,可以将日志資訊發送到管理者郵箱,前提是必須開啟sendmail服務

Name = Standard

mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \&lt;%r\&gt;\" -s \"Bacula: %t %e of %c %l\" %r"

operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \&lt;%r\&gt;\" -s \"Bacula: Intervention needed for %j\" %r"

mail = [email protected] = all, !skipped

operator = [email protected] = mount

console = all, !skipped, !saved

append = "/usr/local//bacula/bin/working/log" = all, !skipped #定義bacula的運作日志

append ="/usr/local//bacula/log/bacula.err.log" = error,warning, fatal #定義bacula的&gt;錯誤日志

catalog = all

Messages {                                          #定義了一個名為Daemon的Messages邏輯段,“Daemon”已經在前面進行了引用

Name = Daemon

mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \&lt;%r\&gt;\" -s \"Bacula daemon message\" %r"

mail = [email protected] = all, !skipped

append = "/usr/local//bacula/log/bacula_demo.log" = all, !skipped

Pool {                                                      #定義供Job任務使用的池屬性資訊,例如,設定備份檔案過期時間、是否覆寫過期的備份資料、是否自動清除過期備份等

Name = dbpool

Pool Type = Backup

Recycle = yes                                       #重複使用

AutoPrune = yes                                   #表示自動清除過期備份檔案

Volume Retention = 7 days              #指定備份檔案保留的時間

Label Format ="db-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}" #設定備份檔案的

命名格式,這個設定格式會産生的命名檔案為:db-2013-01-27-xxx

Maximum Volumes = 7                     #設定最多儲存多少個備份檔案

Recycle Current Volume = yes        #表示可以使用最近過期的備份檔案來存儲新備份

Maximum Volume Jobs = 1              #表示每次執行備份任務建立一個備份檔案

Console {                                               #限定Console利用tray-monitor獲得Director的狀态資訊

Name = chenyi-mon

Password = "/I9QK/9tvB63eOHT2TGJuO7KMzOkrNGi8UtOMGq9LHga"

CommandACL = status, .status

3 配置bacula的SD

         SD可以是一台單獨的伺服器,也可以和Director在一台機器上,本例就将SD和Director端放在一起進行配置,SD的配置檔案是bacula-sd.conf

Storage {                        #定義存儲,本例中是chenyi-sd

Name = chenyi-sd               #定義存儲名稱

SDPort = 9103                  #監聽端口    

Pid Directory = "/usr/local//bacula/bin/working"

Maximum Concurrent Jobs = 20

Director {                        #定義一個控制StorageDaemon的Director

Name = chenyi-dir                    #這裡的“Name”值必須和Director端配置檔案bacula-dironf中Director邏輯段名稱相同

Password = "U1NXyNwriNYIH7SulVmKp/uGTYiy2C5OY7wnSqkz2voU"     #這裡的“Password”值須和Director端配置檔案bacula-dir.conf中Storage邏輯段密碼相同

Director {                         #定義一個監控端的Director

Name = chenyi-mon           #這裡的“Name”值必須和Director端配置檔案bacula-diconf中Console邏輯段名稱相同

Password = "/I9QK/9tvB63eOHT2TGJuO7KMzOkrNGi8UtOMGq9LHga"  #這裡的“Password”值必和Director端配置檔案bacula-dir.conf中Console邏輯段密碼相同

Monitor = yes

Device {                              #定義Device

Name = FileStorage                  #定義Device的名稱,這個名稱在Director端配置檔案bacula-dir.conf中的Storage邏輯段Device項中被引用

Media Type = File                   #指定存儲媒體的類型,File表示使用檔案系統存儲

Archive Device = /tmp/backup        #Archive Device用來指定備份存儲的媒體,可以是cd、dvd、tap等,這裡是将備份的檔案儲存的/tmp/backup目錄下

LabelMedia = yes;                   #通過Label指令來建立卷檔案

Random Access = Yes;                #設定是否采用随機通路存儲媒體,這裡選擇yes

AutomaticMount = yes;               #表示當儲存設備打開時,是否自動使用它,這選擇yes

RemovableMedia = no;                #是否支援可移動的裝置,如tap或cd,這裡選擇no

AlwaysOpen = no;                    #是否確定tap裝置總是可用,這裡沒有使用tap裝置,是以設定為no

Messages {                                                         #為存儲端SD定義一個日志或消息處理機制

director = chenyi-dir = all

到這裡,Bacula的主要端大緻就配置完畢了,接下來就要啟動Bacula的程序了[本文出自www.itchenyi.com 允許轉載,但你必須保留原文連結]

啟動Bacula程序

[root@chenyi bin]# ./bacula start

Starting the Bacula Storage daemon

Starting the Bacula File daemon

Starting the Bacula Director daemon

終于配置完畢,但還有關鍵的一步,添加存儲媒體

[root@chenyi bin]# ./bconsole

Connecting to Director 192.168.1.220:9101

1000 OK: chenyi-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: File

Enter new Volume name: backup

Defined Pools:

1: Default

2: File

3: Scratch

Select the Pool (1-3): 1

Connecting to Storage daemon File at 192.168.1.220:9103 ...

Sending label command for Volume "backup" Slot 0 ...

3000 OK label. VolBytes=193 DVD=0 Volume="backup" Device="FileStorage" (/tmp/backup)

Catalog record for Volume "backup", Slot 0  successfully created.

Requesting to mount FileStorage ...

3906 File device ""FileStorage" (/tmp/backup)" is always mounted.

*

配置客戶機(為需要備份的Client)

1.編譯安裝Bacula

運作Bacula配置腳本。關于configure選項已經在&lt;安裝Bacula主要端&gt;部分做了介紹,這裡不再做說明。以下是個範例:

[root@chenyi ~]# tar zxf bacula-5.2.6.tar.gz

[root@chenyi ~]# cd bacula-5.2.6

[root@chenyi bacula-5.2.6]# ./configure --prefix=/usr/local/bacula/ --enable-client-only

以下是執行結果:

你可能在make的過程中出現libtool: link: cannot find the library `/lib/libattr.la' or unhandled argument `/lib/libattr.la'錯誤,可以可以通過建立/usr/lib/libattr.la的軟連接配接,解決此故障。

ln -s /usr/lib/libattr.la /lib/libattr.la

[root@chenyi bacula-5.2.6]# make install-autostart-fd             #添加自動啟動守護程序

[root@chenyi bacula-5.2.6]# ls /etc/rc.d/init.d/ | grep bacula   #驗證結果

到此,Centos系統的用戶端就安裝完成了,還需要對Bacula-fd進行配置之後再啟動Bacula。

Director {              #定義一個允許連接配接FD的控制端

Name = chenyi-dir     #這裡的“Name”值必須和Director端配置檔案bacula-dir.conf中

Director邏輯段名稱相同

Password = "XqJ0aC66ZHt3REH1sFj6wfnTZGdQSd8oqOv+W9cJ+zkh2"    #這裡的“Password”值必須和Director端配置檔案bacula-dir.conf中Client邏輯段密碼相同

Director {              #定義一個允許連接配接FD的監控端

Name = chenyi.2-mon   #chenyi.2-mon

Password = "xjcWMuoZPw68Vrs//P9BsbLME6lh4mtOFYwhTxZPmNUe"

FileDaemon {                     #定義一個允許連接配接FD的監控端

Name = chenyi.2-fd

FDport = 9102                  #監控端口

WorkingDirectory = /usr/local/bacula/var/bacula/working

Pid Directory = /var/run

Maximum Concurrent Jobs = 20   #定義一次能處理的并發作業數

Messages {                      #定義一個用于FD端的Messages

director = chenyi.2-dir = all, !skipped, !restored

用戶端配置相對來說較簡單,隻需改這個檔案即可

[root@chenyi bin]# ./bacula start     #啟動程序

驗證在server上

*run

A job name must be specified.

The defined Job resources are:

1: wanquanbeifen

2: Client1

3: Client

4: RestoreFiles

Select Job resource (1-4): 1

Run Backup job

JobName:  wanquanbeifen

Level:    Full

Client:   dbfd1

FileSet:  dbfs

Pool:     dbpool (From Job resource)

Storage:  dbsd (From Job resource)

When:     2013-01-27 19:20:41

Priority: 10

OK to run? (yes/mod/no): yes

Job queued. JobId=14

*status

Status available for:

1: Director

2: Storage

4: All

Select daemon type for status (1-4): 3

The defined Client resources are:

1: dbfd

2: dbfd1

Select Client (File daemon) resource (1-2): 2

Connecting to Client dbfd1 at 192.168.1.210:9102

chenyi.2-fd Version: 5.2.6 (21 February 2012)  i686-pc-linux-gnu redhat

Daemon started 27- 1暲013 19:14. Jobs: run=1 running=0.

Heap: heap=0 smbytes=90,848 max_bytes=171,749 bufs=60 max_bufs=109

Sizeof: boffset_t=8 size_t=4 debug=0 trace=0

Running Jobs:

Director connected at: 27- 1暲013 19:20

No Jobs running.

You have messages.

此時ls 檢視之前定義的備份路徑

[root@chenyi bin]# ls -lh /tmp/backup/

總用量 19M

-rw-r-----. 1 root root 193 12月  6 10:08 backup

-rw-r-----. 1 root root 19M 1月  27 19:20 db-2013-01-27-id14

接下來開始嘗試還原,首先删除Client上Boot中的所有檔案。

<a href="http://www.itchenyi.com/wp-content/uploads/2013/01/bacularm.jpg"></a>

此時回到Server上(操作控制台) 下面用紅色加粗的指令均為我輸入的指令,

*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): 5

Defined Clients:

1: chenyi-fd

2: dbfd

3: dbfd1

Select the Client (1-3): 3

Automatically selected FileSet: dbfs

You have selected the following JobId: 14

Building directory tree for JobId(s) 14 ...

24 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 boot

29 files marked.

$ done

Bootstrap records written to /usr/local//bacula/bin/working/chenyi-dir.restore.1.bsr

The job will require the following

Volume(s)                 Storage(s)                SD Device(s)

===========================================================================

db-2013-01-27-id14        dbsd                      FileStorage

Volumes marked with "*" are online.

29 files selected to be restored.

Run Restore job

JobName:         RestoreFiles

Bootstrap:       /usr/local//bacula/bin/working/chenyi-dir.restore.1.bsr

Where:           /tmp/bacula-restores

Replace:         always

FileSet:         dbfs

Backup Client:   dbfd1

Restore Client:  dbfd1

Storage:         dbsd

When:            2013-01-27 19:31:28

Catalog:         MyCatalog

Priority:        10

Plugin Options:  *None*

OK to run? (yes/mod/no): mod                 #這個地方注意一下,如果要還原到client原位置則按以下步驟

Parameters to modify:

1: Level

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): /

Where:

When:            2013-01-27 19:31:28

OK to run? (yes/mod/no): yes

Job queued. JobId=15

現在再看看咱們client,方才删除的檔案全部回來了(表示體驗過程中覺得該工具的備份還原速度都很理想)

<a href="http://www.itchenyi.com/wp-content/uploads/2013/01/baculahy.jpg"></a>

到這裡,從部署到備份再到還原整個過程就完了~~~~~

本文轉自 lgpqdwjh 51CTO部落格,原文連結:http://blog.51cto.com/itchenyi/1127874,如需轉載請自行聯系原作者