相關資訊
本類常用軟件
-
福建農村信用社手機銀行客戶端下載下載量:584204
-
Windows優化大師下載量:416898
-
90美女秀(視頻聊天軟件)下載量:366961
-
廣西農村信用社手機銀行客戶端下載下載量:365699
-
快播手機版下載量:325855
一、bacula概述
1.bacula的組件
bacula,被譽為開源軟件中最好的備份還原軟件,它提供了企業級的客戶機/服務器的備份解決方案,能夠通過網絡來管理文件的備份,恢復和核實工作.既有windows版本的,也有Linux,Unix的.
一個完整的bacula備份系統,由以下五個主要部分或服務組成:
Directory: 管理所有備份,恢復,驗證,和存檔事務,定制備份和恢復文件的計劃.
Storge: 指定進行存儲和恢復文件屬性和數據的物理備份媒介.
File: 安裝在被備份機器上的程序,將被directory調用時候,它提供關于自己的操作系統、文件屬性、數據等資料.
Console: 管理控制臺,與directory進行通訊.
Catalog: 負責維護所有備份文件的索引和數據庫.Catalog服務允許系統管理員或用戶能夠快速地找到并恢復任何需要的檔案。catalog服務是Bacula和簡單的tar,bru備份命令的主要區別,因為catalog維護所有Volume使用情況的記錄,所有任務的運行情況,和所有檔案的保存情況,允許有效的恢復和Volume管理。 Bacula目前支持的三個數據庫(postgresql、mysql、sqlite),在安裝Bacula時,必須選擇其中之一。
Monitor: 監控directory、file、storage的守護進程
bacula各個組成部分的關聯性
2. 部署結構
主機名 ip地址 應用角色 OS
baculaserver 192.168.32.30 Director、SD、Console rhel5.5
baculaclient 192.168.32.31 FD rhel5.5
二、安裝
1.bacula服務器端安裝和初始化
1.1. bacula軟件安裝
[root@baculaserver ~]# tar -zxf bacula-5.0.1.tar.gz
[root@baculaserver ~]# cd bacula-5.0.1
[root@baculaserver bacula-5.0.1]# ./configure --prefix=/usr/local/bacula --with-mysql
#指定安裝路徑和所用數據庫
[root@baculaserver bacula-5.0.1]# make && make install
1.2 MySQL數據庫初始化
[root@baculaserver ~]# cd /usr/local/bacula/etc
[root@baculaserver etc]# ./grant_mysql_privileges
[root@baculaserver etc]# ./create_mysql_database
[root@baculaserver etc]# ./make_mysql_tables
#在執行上面三行mysql初始化時,默認由數據庫管理員root執行,因此可能需要輸入root密碼或設置root密碼為空。
2.bacula客戶端安裝
[root@baculaclient ~]# tar -zxf bacula-5.0.1.tar.gz
[root@baculaclient ~]# cd bacula-5.0.1
[root@baculaclient bacula-5.0.1]# ./configure --prefix=/usr/local/bacula --enable-client-only
#指定安裝路徑,和只安裝客戶端組件
[root@baculaclient bacula-5.0.1]# make && make install
三、bacula的配置
1. bacula的console端配置(bconsole.conf)
[root@baculaserver etc]# vim bconsole.conf
# Bacula User Agent (or Console) Configuration File
#
Director {
Name = 2012-02-15-dir #主控臺名稱,自定義,要求與bacula-dir.conf中定義相同
DIRport = 9101 #控制臺服務器端口
address = 192.168.32.30 #控制臺服務器IP,不要用localhost
Password = "xgjYPXCfgFT6ZS/9tQQTtfrFZ90CFFfIcj+qDKm8FpO0" #控制臺密碼
}
2. bacula的Director端配置(bacula-dir.conf)
2.1 bacula-dir.conf的組成
bacula-dir.conf是Director端的配置文件,也是bacula的核心配置文件,該文件由以下10個邏輯端組成:
Director:定義全局設置
Catalog:定義后臺數據庫
Jobdefs:定義默認執行任務
Job:自定義一個備份或恢復任務
Fileset:定義備份哪些數據,不備份哪些數據
Schedule:定義備份時間策略
Pool:定義供Job使用的池屬性
Client:定義要備份的客戶端
Storage:定義數據的存儲方式
Messages:定義發送日志報告和日志的記錄
2.2 bacula-dir.conf配置
[root@baculaserver etc]# vim bacula-dir.conf
Director { #控制臺的全局配置
Name = 2012-02-15-dir #定義控制臺名稱,要與sd、fa的Director相同
DIRport = 9101 # Director的服務端口
QueryFile = "/usr/local/bacula/etc/query.sql"
WorkingDirectory = "/usr/local/bacula/var/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1 #一次能處理的最大并發數
Password = "xgjYPXCfgFT6ZS/9tQQTtfrFZ90CFFfIcj+qDKm8FpO0" #控制臺密碼,要與bconsole.conf中Director密碼相同
Messages = Daemon #日志輸出方式,“Daemon”在下面Messages邏輯段中定義
}
#JobDefs { #JobDefs類似一個模板,并不是真正創建一個任務,只為Job提供一個默認的配置,當前Job明確定義的任何值,將會覆蓋沖突的JobDefs值.
# Name = "DefaultJob"
# Type = Backup
# Level = Incremental
# Client = 2012-02-15-fd
# FileSet = "Full Set"
# Schedule = "WeeklyCycle"
# Storage = File
# Messages = Standard
# Pool = File
# Priority = 10
# Write Bootstrap = "/usr/local/bacula/var/bacula/working/%c.bsr"
#}
Job { #備份任務,注意注釋標號,可按照該標號與后面各邏輯端定義相對應
Name = webjob #備份job的名字,這個可以隨便起,在后面的備份操作的時候可以看到
Type= backup #可用類型有backup,restore,verify,admin
Client= 2012-02-15-fd #1.要備份的客戶端,“2012-02-15-fd”在后面的Client邏輯段定義
FileSet = dbfs #2.要備份的客戶端數據,“dbfs”在后面的FileSet邏輯段定義
schedule = dbscd #3.備份任務的執行時間策略,“dbscd”在后面的Schedule邏輯段定義
Storage = dbsd #4.備份數據的存儲介質和路徑,“dbsd”在后面的Storage邏輯段定義
Messages = Daemon
Pool = dbpool #5.pool屬性,“dbpool”在后面的Pool邏輯段定義
Level = Incremental #備份類型,可用的值是FULL(完全備份),incremental(增量備份),differential(差異備份),如第一次沒做完全備份,則先進行完全備份后再執行Incremental
Priority = 10 #優先級
Write Bootstrap = "/usr/local/bacula/var/bacula/working/%c.bsr" #指定備份的引導信息路徑
}
#Job { #定義一個Catalog備份任務,確保控制端備份數據庫的安全
# Name = "BackupCatalog"
# JobDefs = "DefaultJob"
# Level = Full
# FileSet="Catalog"
# Schedule = "WeeklyCycleAfterBackup"
# # This creates an ASCII copy of the catalog
# # Arguments to make_catalog_backup.pl are:
# # make_catalog_backup.pl <catalog-name>
# RunBeforeJob = "/usr/local/bacula/etc/make_catalog_backup.pl MyCatalog"
# # This deletes the copy of the catalog
# RunAfterJob = "/usr/local/bacula/etc/delete_catalog_backup"
# Write Bootstrap = "/usr/local/bacula/var/bacula/working/%n.bsr"
# Priority = 11 # run after main backup
#}
Job { #定義一個還原任務
Name = "Restoreweb"
Type = Restore
Client=2012-02-15-fd
FileSet="dbfs"
Storage = dbsd
Pool = dbpool
Messages = Standard
Where = /home/bacula #指定默認恢復數據到這個路徑,注意:還原客戶端數據時,默認會將數據存放在客戶端/home/bacula下。如不指定,默認會還原的原數據所在地
}
FileSet { #2.定義名為dbfs要備份的客戶端數據,即指定需要備份哪些數據,需要排除哪些數據,可指定多個FileSet
Name = "dbfs"
Include {
Options {
# Compression=GZIP #對備份文件進行gzip的壓縮
signature = MD5 #驗證方式為MD5碼的方式
}
File = /var/www #指定客戶端需要備份的文件或目錄
}
Exclude { #排除不需要備份的文件或目錄
File = /var/www/cgi-bin
File = /var/www/error
File = /var/www/icons
}
}
Schedule { #3.備份任務的執行時間策略,定義名為dbscd的備份任務調度策略
Name = dbscd
Run = Level=Full mon at 7:00 #在周一7點作一次全備份
Run = Level=Full fri at 7:00 #在周五7點作一次全備份
Run = Level=Differential sat at 7:00 #在周六7點作一次差異備份
Run = Level=Differential sun at 7:00 #在周日7點作一次差異備份
Run = Level=Differential tue-thu at 7:00 #在周二到周四7點作差異備份
}
#Schedule {
# Name = "WeeklyCycle"
# Run = Full 1st sun at 23:05
# Run = Differential 2nd-5th sun at 23:05
# Run = Incremental mon-sat at 23:05
#}
#Schedule {
# Name = "WeeklyCycleAfterBackup"
# Run = Full sun-sat at 23:10
#}
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/usr/local/bacula/var/bacula/working/bacula.sql"
}
}
Client { #1.要備份的客戶端
Name = 2012-02-15-fd
Address = 192.168.32.31
FDPort = 9102
Catalog = MyCatalog #記錄客戶機備份情況的日志名,后面Catalog邏輯段定義
Password = "d1+RTcYIpa7YYB2/SrhRp/BAB7lBSF/Rl7wgrkSb52A2" # Director與FD的驗證密碼,必須與bacula-fd.conf中密碼相同
File Retention = 30 days # 指定保存在數據庫中的記錄多久循環一次,這里30天,只影響數據庫中的記錄,不影響備份的文件
Job Retention = 6 months # job的保持周期,應大于File Retention的值
AutoPrune = yes # 當達到指定的保存周期時,是否自動刪除數據庫中記錄,yes表自動清除過期的job
}
Storage { #4.備份數據的存儲介質和路徑;Storage用來指定將客戶端數據備份到哪個存儲設備上。
Name = dbsd
Address = 192.168.32.30 #存儲端SD的IP地址
SDPort = 9103
Password = "w6YqAfWkU7NMxRJ8s/8y5kUffGpysot4vt9HVQjE9bQy" #Director端與SD的通訊密碼,必須與bacula-sd.conf中Director段密碼相同
Device = dbdev #指定數據備份介質,必須與存儲SD端的bacula-sd.conf中Device邏輯端的Name相同
Media Type = File #指定數據備份介質類別,必須與存儲SD端的bacula-sd.conf中Device邏輯端的Media Type相同
}
Catalog { #Catalog邏輯段用來定義關于日志和數據庫的設定
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
}
Messages { #Messages邏輯段用來設定Director端如何保存日志,日志格式,可以將日志信息發送給管理員,要求開啟sendmail服務。
Name = Standard
mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = "/usr/local/bacula/var/bacula/working/log" = all, !skipped
catalog = all
}
Messages {
Name = Daemon
mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/usr/local/bacula/var/bacula/working/log" = all, !skipped
}
#Pool {
# Name = Default
# Pool Type = Backup
# Recycle = yes # Bacula can automatically recycle Volumes
# AutoPrune = yes # Prune expired volumes
# Volume Retention = 365 days # one year
#}
Pool { #6.定義job任務使用的池屬性信息,如:設定文件過期時間,是否覆蓋過去備份數據,是否自動清除過去備份等。
Name = dbpool
Pool Type = Backup
Recycle = yes # 重復使用
AutoPrune = yes # 自動清除過去備份
Volume Retention = 365 days # 備份文件保存時間
Maximum Volume Jobs =1 # 每次執行備份任務創建一個備份文件。
Maximum Volume Bytes = 50G # 限制備份文件文件最大值
Maximum Volumes = 100 # 最多保存多少個備份文件
Recycle Current Volume = yes # 使用最近過期的文件存儲新備份
Label Format = "db-${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-id${JobId}" #設定備份文件命名格式
}
#Pool {
# Name = Scratch
# Pool Type = Backup
#}
Console { #限定console利用tray-monitor獲取diretor的狀態信息
Name = 2012-02-15-mon
Password = "1tcj5GjpmPFP6M46JgjYzhiDsdC3br/4fDzKuH9kQRlz"
CommandACL = status, .status
}
3. bacula的SD配置(bacula-sd.conf)
[root@baculaserver etc]# vim bacula-sd.conf
Storage { # 定義存儲,本例2012-02-15-sd
Name = 2012-02-15-sd
SDPort = 9103 # 服務端口
WorkingDirectory = "/usr/local/bacula/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
Director { #定義一個控制StorageDaemon的控制臺Director
Name = 2012-02-15-dir #該值必須與bacula-dir.conf中Director邏輯段內定義相同
Password = "w6YqAfWkU7NMxRJ8s/8y5kUffGpysot4vt9HVQjE9bQy" #必須與bacula-dir.conf中Storage邏輯端定義password相同
}
Director { #定義一個監控端的Director
Name = 2012-02-15-mon #必須與bacula-dir.conf中Console邏輯段內定義相同
Password = "1tcj5GjpmPFP6M46JgjYzhiDsdC3br/4fDzKuH9kQRlz" #必須與bacula-dir.conf中Console邏輯段內定義password相同
Monitor = yes
}
Device {
Name = dbdev #定義device,名稱與Director端配置文件bacula-dir.conf中的Storage邏輯端Device相同
Media Type = File #存儲介質類型,file表示文件系統存儲
Archive Device = /home/webbak #指定存儲介質,可以使cd、dvd、tap等,這里是將備份文件保存在/home/webak目錄下
LabelMedia = yes; #通過Label建立卷文件
Random access = Yes; #是否采用隨機訪問存儲介質,
AutomaticMount = yes; # 存儲設備打開是,是否自動使用他
RemovableMedia = no; #是否支持移動設備,如tap,cd等
AlwaysOpen = no; #是否確保tap設備總是可用
}
Messages { #為存儲端SD定義一個日志或消息出來機制
Name = Standard
director = 2012-02-15-dir = all
}
4. bacula的FD端配置(bacula-fd.conf)
[root@balucaclient etc]# vim bacula-fd.conf
Director {
Name = 2012-02-15-dir #定義一個允許連接FD的控制端,必須與bacula-dir.conf中Director邏輯端名稱相同
Password = "d1+RTcYIpa7YYB2/SrhRp/BAB7lBSF/Rl7wgrkSb52A2" #必須與bacula-dir.conf中Client邏輯端密碼相同
}
#
# Restricted Director, used by tray-monitor to get the
# status of the file daemon
#
Director {
Name = 2012-02-15-mon #定義一個允許連接FD的監控端Console
Password = "1tcj5GjpmPFP6M46JgjYzhiDsdC3br/4fDzKuH9kQRlz" #必須與bacula-dir.conf中Console邏輯段內定義password相同
Monitor = yes
}
#
# "Global" File daemon configuration specifications
#
FileDaemon { # 定義一個FD端
Name = 2012-02-15-fd
FDport = 9102 # 監控端口
WorkingDirectory = /usr/local/bacula/var/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
# Send all messages except skipped files back to Director
Messages {
Name = Standard
director = balucaclient-dir = all, !skipped, !restored
}
四、 bacula服務的啟動
1. 在服務器端啟動bacula的Director Daemon和Storage Daemon
1.1 啟動方式一
[root@baculaserver etc]#/usr/local/bacula/etc/bacula {start|stop|restart|status}
1.2 啟動方式二:分別管理各個配置端的方式,依次啟動或關閉每個服務
[root@baculaserver etc]#/usr/local/bacula/etc/bacula-dir {start|stop|restart|status}
[root@baculaserver etc]#/usr/local/bacula/etc/bacula-sd {start|stop|restart|status}
[root@baculaserver etc]#/usr/local/bacula/etc/bacula-fd {start|stop|restart|status}
#由于fd端在baculaclient上,在此無需自動bacula-fd服務
[root@baculaserver etc]# netstat -tnpl | grep 910
tcp 0 0 0.0.0.0:9101 0.0.0.0:* LISTEN 1507/bacula-dir
tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN 1333/bacula-fd
tcp 0 0 0.0.0.0:9103 0.0.0.0:* LISTEN 1323/bacula-sd
#在啟動bacula的所有服務前,必須啟動MySQL數據庫,否則連接bacula的控制端是會報錯。
2. 在客戶端啟動bacula的File Daemon
[root@baculaserver etc]#/usr/local/bacula/etc/bacula {start|stop|restart|status}
[root@baculaserver etc]#/usr/local/bacula/etc/bacula-fd {start|stop|restart|status}
#由于baculaclient只做fd端,在此只需啟動bacula-fd服務即可
五、bacula備份文件
1. 創建卷組
[root@baculaserver etc]# ./bconsole
Connecting to Director 192.168.32.30:9101
1000 OK: 2012-02-15-dir Version: 5.0.1 (24 February 2010)
Enter a period to cancel a command.
*label #創建一個卷組
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Automatically selected Storage: dbsd
Enter new Volume name: webbak #卷組名稱,可隨意指定,指定完畢后,會在bacula-dir.conf中Device邏輯字段指定的/home/webbak下生成一個文件
Automatically selected Pool: dbpool
Connecting to Storage daemon dbsd at 192.168.32.30:9103 ...
Sending label command for Volume "webbak" Slot 0 ...
3000 OK label. VolBytes=202 DVD=0 Volume="webbak" Device="dbdev" (/home/webbak)
Catalog record for Volume "webbak", Slot 0 successfully created.
Requesting to mount dbdev ...
3906 File device "dbdev" (/home/webbak) is always mounted.
You have messages.
#只有在使用磁帶卷時才需要這樣,而像我們剛才使用的磁盤卷,Bacula是可以自動進行label的。想要刪除測試數據的話,就將/tmp目錄下的卷直接刪除,再使用drop_mysql_tables和make_mysql_tables腳本
2. 執行備份
2.1 第一次增量備份,默認會是一個完全備份 #備份前fd中文件有index1.html
*run
A job name must be specified.
The defined Job resources are:
1: webjob
2: Restoreweb
Select Job resource (1-2): 1 #選擇備份任務
Run Backup job
JobName: webjob
Level: Incremental
Client: 2012-02-15-fd
FileSet: dbfs
Pool: dbpool (From Job resource)
Storage: dbsd (From Job resource)
When: 2012-02-15 23:29:58
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=1
#到處為止,可以開始備份了,在bacula-dir.conf文件中定義的webjob是一個增量備份,因此這個備份只是一個增量操作,由于是第一個備份,因此默認webjob會做一個完全備份,第二次備份時才執行增量備份
2.2 第二次增量備份,只做增量操作 #備份前fd中文件有index1.html、index2.html
*run
A job name must be specified.
The defined Job resources are:
1: webjob
2: Restoreweb
Select Job resource (1-2): 1
Run Backup job
JobName: webjob
Level: Incremental
Client: 2012-02-15-fd
FileSet: dbfs
Pool: dbpool (From Job resource)
Storage: dbsd (From Job resource)
When: 2012-02-15 23:37:00
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=2
#這是第二備份,只做一個增量操作
2.3 第三次備份,手動改為差異備份 #備份前fd中文件有index1.html、index2.html 、index3.html
*run
A job name must be specified.
The defined Job resources are:
1: webjob
2: Restoreweb
Select Job resource (1-2): 1
Run Backup job
JobName: webjob
Level: Incremental
Client: 2012-02-15-fd
FileSet: dbfs
Pool: dbpool (From Job resource)
Storage: dbsd (From Job resource)
When: 2012-02-15 23:40:15
Priority: 10
OK to run? (yes/mod/no): mod #mod修改備份任務參數
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: When
7: Priority
8: Pool
9: Plugin Options
Select parameter to modify (1-9): 1 #1表示選擇備份類別
Levels:
1: Full
2: Incremental
3: Differential
4: Since
5: VirtualFull
Select level (1-5): 3 #3表示差異備份
Run Backup job
JobName: webjob
Level: Differential
Client: 2012-02-15-fd
FileSet: dbfs
Pool: dbpool (From Job resource)
Storage: dbsd (From Job resource)
When: 2012-02-15 23:40:15
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=3
3. 查看備份狀態
*status
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 1
2012-02-15-dir Version: 5.0.1 (24 February 2010) i686-pc-linux-gnu redhat Enterprise release
Daemon started 15- 212 23:05, 3 Jobs run since started.
Heap: heap=258,048 smbytes=65,799 max_bytes=113,185 bufs=204 max_bufs=231
Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Differential Backup 10 16- 212 07:00 webjob *unknown*
====
Running Jobs:
Console connected at 15- 212 23:40
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
1 Full 3 5 OK 15- 212 23:30 webjob
2 Incr 2 5 OK 15- 212 23:37 webjob
3 Diff 3 9 OK 15- 212 23:40 webjob
#顯示備份任務webjob第一次為full完全備份,第二次為增量備份,第三次為差異備份。
4.查看備份文件
[root@baculaserver etc]# ls -ls /home/webbak/
總計 12
4 -rw-r----- 1 root root 825 02-15 23:37 db-2012-02-15-id2
4 -rw-r----- 1 root root 969 02-15 23:40 db-2012-02-15-id3
4 -rw-r----- 1 root root 900 02-15 23:30 webbak #label產生的卷組文件
六、bacula恢復文件
1. 利用差異備份進行完全恢復
[root@balucaclient etc]# rm -rf /var/www/html/* #刪除fd中所有文件
[root@baculaserver etc]# ./bconsole
Connecting to Director 192.168.32.30:9101
1000 OK: 2012-02-15-dir Version: 5.0.1 (24 February 2010)
Enter a period to cancel a command.
*restore
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
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: 1,3
You have selected the following JobIds: 1,3
#從備份狀態看,JobID為1的為完全備份,JobID為3的為差異備份,因此只需恢復jobid為1和3的備份即可完全恢復
Building directory tree for JobId(s) 1,3 ...
3 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 * #指定要恢復的文件或目錄,* 表所有
5 files marked.
$ done
Storage "" not found, using Storage "dbsd" from MediaType "File".
Bootstrap records written to /usr/local/bacula/var/bacula/working/2012-02-15-dir.restore.1.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
webbak
db-2012-02-15-id3
Volumes marked with "*" are online.
5 files selected to be restored.
Automatically selected Client: 2012-02-15-fd
Run Restore job
JobName: Restoreweb
Bootstrap: /usr/local/bacula/var/bacula/working/2012-02-15-dir.restore.1.bsr
Where: *None*
Replace: always
FileSet: dbfs
Backup Client: 2012-02-15-fd
Restore Client: 2012-02-15-fd
Storage: dbsd
When: 2012-02-15 23:54:12
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=4
[root@balucaclient etc]# ls /var/www/html/
index1.html index2.html index3.html
#查看fd端,顯示已經完全恢復
2. 利用恢復指定的文件
[root@balucaclient etc]# rm -rf /var/www/html/*
[root@baculaserver etc]# ./bconsole
*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): 7 #7表示恢復指定的文件
Automatically selected Client: 2012-02-15-fd
Enter file names with paths, or < to enter a filename
containing a list of file names with paths, and terminate
them with a blank line.
Enter full filename: /var/www/html/index2.html #指定恢復index2.html文件
Enter full filename:
Storage "" not found, using Storage "dbsd" from MediaType "File".
Bootstrap records written to /usr/local/bacula/var/bacula/working/2012-02-15-dir.restore.2.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
db-2012-02-15-id3
Volumes marked with "*" are online.
1 file selected to be restored.
Run Restore job
JobName: Restoreweb
Bootstrap: /usr/local/bacula/var/bacula/working/2012-02-15-dir.restore.2.bsr
Where: *None*
Replace: always
FileSet: dbfs
Backup Client: 2012-02-15-fd
Restore Client: 2012-02-15-fd
Storage: dbsd
When: 2012-02-16 00:03:19
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=5
[root@balucaclient etc]# ls /var/www/html/
index2.html
#顯示fd上index2.html成功恢復
3. 增量備份的完全恢復
[root@balucaclient etc]# rm -rf /var/www/html/*
[root@baculaserver etc]# ./bconsole
Connecting to Director 192.168.32.30:9101
1000 OK: 2012-02-15-dir Version: 5.0.1 (24 February 2010)
Enter a period to cancel a command.
*restore
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
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: 1,2
You have selected the following JobIds: 1,2
#從備份狀態看,JobID為1的為完全備份,JobID為2的為第一個增量備份,如果2之前還有其他的增量備份,必須在此指定,才能完全恢復
2 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 *
4 files marked.
$ done
Storage "" not found, using Storage "dbsd" from MediaType "File".
Bootstrap records written to /usr/local/bacula/var/bacula/working/2012-02-15-dir.restore.3.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
webbak
db-2012-02-15-id2
Volumes marked with "*" are online.
4 files selected to be restored.
Automatically selected Client: 2012-02-15-fd
Run Restore job
JobName: Restoreweb
Bootstrap: /usr/local/bacula/var/bacula/working/2012-02-15-dir.restore.3.bsr
Where: *None*
Replace: always
FileSet: dbfs
Backup Client: 2012-02-15-fd
Restore Client: 2012-02-15-fd
Storage: dbsd
When: 2012-02-16 00:08:05
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=6
[root@balucaclient etc]# ls /var/www/html/
index1.html index2.html
#顯示fd上已經完全恢復Jobid為2前所有的文件
七、bconsole中相關命名說明
1. status 查看director、client、storage 狀態。
[root@baculaserver etc]# ./bconsole
Connecting to Director 192.168.32.30:9101
1000 OK: 2012-02-15-dir Version: 5.0.1 (24 February 2010)
Enter a period to cancel a command.
*status
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3
Automatically selected Client: 2012-02-15-fd
Connecting to Client 2012-02-15-fd at 192.168.32.31:9102
2012-02-15-fd Version: 5.0.1 (24 February 2010) i686-pc-linux-gnu redhat Enterprise release
Daemon started 15- 212 23:16, 6 Jobs run since started.
Heap: heap=516,096 smbytes=81,546 max_bytes=154,559 bufs=68 max_bufs=95
Sizeof: boffset_t=8 size_t=4 debug=0 trace=0
Running Jobs:
Director connected at: 16- 212 00:16
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
======================================================================
20 3 314.5 M OK 15- 212 21:56 Restoreweb
21 Incr 4 524.2 M OK 15- 212 22:18 webjob
22 3 314.5 M OK 15- 212 22:25 Restoreweb
23 4 524.2 M OK 15- 212 22:27 Restoreweb
1 Full 3 5 OK 15- 212 23:31 webjob
2 Incr 2 5 OK 15- 212 23:38 webjob
3 Diff 3 9 OK 15- 212 23:41 webjob
4 5 14 OK 15- 212 23:55 Restoreweb
5 1 5 OK 16- 212 00:04 Restoreweb
6 4 10 OK 16- 212 00:09 Restoreweb
====
也可以
status dir 查看director 的狀態
status client 查看 client 的狀態
status storage 查看 storage 的狀態
2. show 查看資源信息。
pools filesets clients storages schedule jobs message
3. list llist
list pools | jobs | jobtotals | media <pool=pool-name> | files <jobid=nn>
4. run 手動運行一次編好的任務。
5. reload 從新載入配置文件(當修改配置文件后用這個,不需要停止服務)
6. estimate 對某次任務進行評估。它會連接到客戶端,并輸出這次任務的fileset 中 文件數,和這次備份任務所占的空間。
7. purge prune
一般不會用到,我們設定的是過期自動清除。
purge 危險!!!!! 這是一個危險命令。他能清除一個客戶端的所有備份任務,文件,和卷。
prune 這個命令和 purge 相似,但安全很多,它只會清除過期的文件,任務,和卷。
8. time 查看時間。
9. delete 刪除volume , pool 或某次任務。
10. disable 和 enable 是一對,它可以禁止和啟用某個任務。
11 cancel 取消一次正在運行的任務。例如:某次任務由于設置不當,卡住不動了,我們就可以使用這條命令,去取消這次任務。
cancel 20 取消任務ID=20 的任務。
12 update 修改 volumes ,pool 參數。