文檔控制html
文檔信息node |
|||
文檔名稱git |
Bacula 配置正則表達式 |
||
文檔編寫者算法 |
friend-sensql |
文檔版本編號數據庫 |
V1.0express |
文檔類型bootstrap |
技術文檔安全 |
2010-07-28 |
|
備註 |
因爲本人英文水平有限,文檔中諸多翻譯都是結合我的技術知識翻譯,僅做參考,以官方文檔爲準。博客格式比較亂,附件中的文檔更適合查閱。 測試環境:Bacula Server系統:Centos 5.3;Bacula Client for Linux系統:RHEL 4;Bacula Client for Windows系統:Windows 7。 |
全部權聲明
文 檔裏的資料多數能夠在個人博客(http://sens.cublog.cn)中找到,博客中大部分文檔也是在網絡中引用或轉載,我在這裏作了整理及修 改,目的是爲了集你們之所長,爲使用Bacula的你們提供更好幫助。若有侵權,還望通知,將予以改正。許多專業術語是我我的的理解,文檔中有錯誤的地 方,或者能夠用更好的語言表達的,但願將好的建議告訴我,以便錯誤獲得及時更正,共同爲使用Bacula的你們提供便利。
文檔下載
組 成Bacula備份系統有三個主要的部分,包括主控端、存儲端和客戶端,這三個部分都有各自的配置文件,相對應的是主控端(bacula- dir.conf,下同)、存儲端(bacula-sd.conf,下同)和客戶端(bacula-fd.conf,下同),各配置文件中的部分項存在一 定的關聯,官方也用一張圖形象的表示了它們之間的關係,看下圖:
圖中使用箭頭鏈接主控端配置文件的相關項與其它配置文件的相關項,所鏈接的相關項的值必須是相同的。下面用文件說明一下:
Name 值與控制檯配置文件(bconsole.conf,下同)的Director{}項、存儲端配置文件的Director{}項及客戶端配置文件的 Director{}項的Name值相同;Password值與控制檯配置文件的Director{}項的Password值相同。
Device值與存儲端配置文件的Device{}項的Name值相同;
MediaType值與存儲端配置文件的Device{}項的MediaType值相同;
Password值與存儲端配置文件的Director{}項的Password值相同。
Password值與客戶端配置文件的Director{}項的Password值相同。
理解了圖中表示的意思,對配置Bacula很是有幫助。因此但願你們先熟悉此圖以後再作配置。
下圖是主控端配置文件的主要選項。安裝Bacula以後,主控端配置文件中的都默認啓用了這些選項,圖中對其作了簡單的介紹:
爲何Job項與其餘選項用線鏈接呢?
由於在執行一個任務(Job)的過程當中,須要調用到其餘選項的參數設置,從而使得任務的完整。若是這麼多的參數所有寫在Job選項裏,那麼就會將致使Job選項的參數設置很是複雜,這樣的模塊化設計顯得更直觀,也能使程序運行更效高效。下面用一句話說明一下:
建 立一個備份任務(Job)時,就須要選擇一臺備份的計算機(Client),而後肯定須要備份的文件(FileSet)及備份時間週期和備份類型 (Schedule),最後選擇備份到哪裏(Storage)以及文件存儲的方式(Pool),讓管理者知道備份任務的的狀況(Messages)。
注意:Job項也能夠是還原任務。
Bacula Director服務管理全部的備份,恢復,驗證和存檔事務,因此主控端的配置文件也是最爲複雜的。下面將對配置文件中各選項的參數設置進行詳細的介紹。
Director{}部分的官方文檔見The Director Resource。
如下是關於Director{}部分的參數說明
Name = name 指定主控端名稱,必選。默認爲計算機名-dir。 |
Description = text 用文本字段描述主控端,可選。 |
Password = UA-password 設置主控端密碼,通常控制檯鏈接時須要使用。必選。 |
Messages = Messages-resource-name 引用Messages{}的Name值。必選。 |
Working Directory = Directory 指定工做目錄,目錄必須已經存在,必選。通常在./configure時已經指定。 |
Pid Directory = Directory 指定進程ID文件存放目錄,必選。通常在./configure時已經指定。 |
Scripts Directory = Directory 指定腳本目錄,可選。 |
QueryFile = Path 指定一個目錄和文件的路徑,必選。 |
Heartbeat Interval = time-interval 可選。 |
Maximum Concurrent Jobs = number 設置同時執行的最大任務數量,默認設置爲1。 |
FD Connect Timeout = time 指定主控端嘗試聯繫客戶端開始一個job的超時時間。若是超時將取消該job,默認爲30分鐘。 |
SD Connect Timeout = time 指定主控端嘗試聯繫存儲端開始一個job的超時時間。若是超時將取消該job,默認爲30分鐘。 |
DirAddresses = IP-address-specification 指定地址和端口監聽控制檯鏈接,用法能夠查看官方文檔。 |
DirPort = port-number 指定端口號監聽控制檯鏈接,默認是9101。不與DirAddresses參數同時使用。 |
DirAddress = IP-Address 指定地址監聽控制檯鏈接,可選。若是它被指定,那麼此地址將與主控端綁定;若是未指定將綁定到本機當前使用的地址。只容許指定一個地址。不與DirAddresses參數同時使用。 |
DirSourceAddress = IP-Address 可選。 |
Statistics Retention = time 指定job記錄統計在目錄數據庫中保留的時間,默認爲5年。主要是用於容量規劃等等,不是以恢復爲目的。 |
VerId = string
|
MaximumConsoleConnections = number 指定控制檯最大同時鏈接數,默認是20。 |
範例
Director { # define myself
Name = ser1-dir
DIRport = 9101 # where we listen for UA connections
QueryFile = "/usr/local/bacula/bin/query.sql"
WorkingDirectory = "/usr/local/bacula/working"
PidDirectory = "/usr/local/bacula/bin/working"
Maximum Concurrent Jobs = 1
Password = "111" # Console password
Messages = Daemon
}
JobDefs選項容許全部能夠出如今Job選項中的參數。可是,JobDefs 不會建立一個做業(Job),而是Job{}引用它的參數設置。
JobDefs選項的參數細節能夠參考Job選項。
下面貼一下主控端配置文件中默認生成的JobDefs選項範例
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = ser1-fd
FileSet = "Full Set"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = "/usr/local/bacula/working/%c.bsr"
}
定義一個客戶端的備份做業或還原做業的相關參數。Job{}部分的官方文檔見The Job Resource。
當須要引用其餘選項的參數設置時,設置爲相對應的Name值就能夠了。下面用圖體現一下,以便更好的理解:
下面是Job{}能夠設置的詳細參數
Name = name 指定Job{}名稱,必選。命名自行指定,建議由計算機名和Job類型組成,如ser1-backup表示計算機ser1的備份任務。 |
Enabled = yesno 是否啓用此Job{},可選。 |
Type = job-type Job類型,定義備份做業或還原做業。取值有Backup、Restore、Verify和Admin。 |
Level = job-level 備 份類型,當type參數爲備份做業時,取值有Full、Incremental和Differential;還原做業不須要設置此選項;當type參數爲 Verify做業時,取值有InitCatalog、Catalog、VolumeToCatalog和DiskToCatalog。 |
Accurate = yesno 是否啓用精確模式。 |
Verify Job = Job-Resource-Name 當type參數爲Verify做業時,引用Job{}的Name值;不設置時,默認爲記錄的最後一次Job。 |
JobDefs = JobDefs-Resource-Name 引用JobDefs{}的Name值。可選。 |
Bootstrap = bootstrap-file 指定引導文件,啓動還原做業時自動建立。此參數只用於Job類型爲Restore時,此時必選。 |
Write Bootstrap = bootstrap-file-specification 當執行備份做業是,將做業記錄寫入到一個引導文件。此參數只用於Job類型爲Backup時,此時必選。 |
Client = client-resource-name 引用Client{}的Name值,也就是選擇須要備份的客戶端。必選。 |
FileSet = FileSet-resource-name 引用FlieSet{}的Name值,也就是選擇客戶端須要備份的目錄及文件。必選。 |
Messages = messages-resource-name 引用Messages{}的Name值。必選。 |
Pool = pool-resource-name 引用Pool{}的Name值。必選。 |
Full Backup Pool = pool-resource-name 引用Pool{}的Name值。可選。 |
Differential Backup Pool = pool-resource-name 引用Pool{}的Name值。可選。 |
Incremental Backup Pool = pool-resource-name 引用Pool{}的Name值。可選。 |
Schedule = schedule-name 引用Schedule{}的Name值,設置做業執行的時間週期,可選。若是沒有指定,此任務必須手動執行。 |
Storage = storage-resource-name 引用Storage{}的Name值,選擇執行Job時的存儲端。必選。 |
Max Start Delay = time 最大啓動時間,默認爲0,無限制。定義做業開始時間的最大超時時間。若是一個做業計劃在凌晨1:00,但此時有其餘工做再運行,可能就會延遲執行,若是設置爲3600(一個小時)到2:00還未執行,此做業將被取消,防止做業在白天執行。 |
Max Run Time = time 指定做業最大容許運行的時間。 |
Incremental|Differential Max Wait Time = time 從bacula 2.3.18此參數已棄用。 |
Incremental Max Run Time = time 指定增量做業最大容許運行的時間。 |
Differential Max Wait Time = time 指定差別做業最大容許運行的時間。 |
Max Run Sched Time = time 最大開始時間和最大運行時間的和 |
Max Wait Time = time 最大等待時間 |
Max Full Interval = time 見官方文檔 |
Prefer Mounted Volumes = yesno 默認爲yes |
Prune Jobs = yesno 默認爲no |
Prune Files = yesno 默認爲no |
Prune Volumes = yesno 默認爲no |
RunScript {body-of-runscript} 添加腳本使用做業更好的執行,詳細查看官方文檔 |
Run Before Job = command 引用腳本,詳見官方文檔。 |
Run After Job = command 引用腳本,詳見官方文檔。 |
Run After Failed Job = command 引用腳本,詳見官方文檔。 |
Client Run Before Job = command 引用腳本,詳見官方文檔。 |
Client Run After Job = command 引用腳本,詳見官方文檔。 |
Rerun Failed Levels = yesno 當運行任務運行失敗後一次備份做業時,將提高更高的備份類型,好比差別備份異常終止,下次備份將執行徹底備份。默認爲no。 |
Spool Data = yesno 默認爲no |
Spool Attributes = yesno 默認爲no |
Where = directory 指定文件還原到該客戶端的目錄。此參數只用於Job類型爲Restore時。若是沒有指定文件將被還原到其原始位置。默認爲/tmp/bacula-restores |
Add Prefix = directory 此參數只用於Job類型爲Restore時。 |
Strip Prefix = directory 此參數只用於Job類型爲Restore時 |
RegexWhere = expressions 此參數只用於Job類型爲Restore時。 |
Replace = replace-option 此參數只用於Job類型爲Restore時。當恢復的文件存在時,執行什麼操做。取值有always、ifnewer、ifolder和never。 |
Prefix Links=yesno 默認爲no |
Maximum Concurrent Jobs = number 容許同時運行的做業數量,默認爲1。 |
Reschedule On Error = yesno 是否從新執行發生錯誤的做業,默認爲no。 |
Reschedule Interval = time-specification 從新執行發生錯誤的做業的間隔時間。 |
Reschedule Times = count 重複次數,默認爲0,反覆重複。 |
Allow Duplicate Jobs = yesno 默認爲no |
Allow Higher Duplicates = yesno 默認爲no |
Cancel Lower Level Duplicates = yesno 默認爲no |
Cancel Queued Duplicates = yesno 默認爲no |
Cancel Running Duplicates = yesno 默認爲no |
DuplicateJobProximity = time-specification 見官方文檔。 |
Run = job-name 見官方文檔。 |
Priority = number 設置做業執行優先級,默認爲10。數字越大,優先級越低。 |
Allow Mixed Priority = yesno 默認爲no |
Write Part After Job = yesno 默認爲no |
備份做業範例
Job {
Name = "ser1-backup"
Type = Backup
Level = Full
Client = ser1-fd
FileSet = "ser1-backup"
Messages = Standard
Pool = Default
Storage = File
Schedule = "OneDay"
Priority = 10
Write Bootstrap = "/usr/local/bacula/working/ser1-backup.bsr"
}
還原做業範例
Job {
Name = "ser1-restore"
Type = Restore
Client = ser1-fd
FileSet = "ser1-backup"
Storage = File
Pool = Default
Messages = Standard
Where = /opt/restore
Bootstrap = "/usr/local/bacula/working/ser1-backup.bsr"
}
定義時間週期使任務能夠自動調度任務的執行,也能夠覆蓋Job{}的備份類型(Level),Pool{},Storage{}和Message{}的默認參數。當Job{}不引用它時,做業就只能手動運行。
Schedule{}部分的官方文檔見The Schedule Resource。
Name = name 指定Schedule{}名稱,必選。 |
Run = Job-overrides Date-time-specification 指定覆蓋Job{}默認參數的參數及執行做業的時間週期。 |
Job-overrides指定覆蓋Job{}默認參數的參數,自定義一個特定的做業。例如,設置一個增量備份做業的Message{}定義爲輸出到一個文件,而每週或每個月的徹底備份做業的Message{}定義是發送不一樣郵件。
Level=Incremental 備份類型爲Incremental |
Pool=Weekly 引用Name值爲Weekly的Pool{} |
Storage= DLT_Drive 引用Name值爲DLT_Drive的Storage{} |
Messages=Verbose 引用Name值爲Verbose的Messages{} |
FullPool=Full 若是爲徹底備份做業,引用Name值爲Full的Pool{} |
DifferentialPool=Differential 若是爲差別備份做業,引用Name值爲Differential的Pool{} |
IncrementalPool= Incremental 若是爲增量備份做業,引用Name值爲Incremental的Pool{} |
SpoolData=yesno 見官方文檔。 |
SpoolSize=bytes 見官方文檔。 |
WritPartAfterJob=yesno 見官方文檔。 |
Date-time-specification定義任務什麼時候執行。關於時間設定規範建議查看詳細的官方文檔。
如下是關於官方文檔的時間設定規範:
<void-keyword> = on
<at-keyword> = at
<week-keyword> = 1st | 2nd | 3rd | 4th | 5th | first |
second | third | fourth | fifth
<wday-keyword> = sun | mon | tue | wed | thu | fri | sat |
sunday | monday | tuesday | wednesday |
thursday | friday | saturday
<week-of-year-keyword> = w00 | w01 | ... w52 | w53
<month-keyword> = jan | feb | mar | apr | may | jun | jul |
aug | sep | oct | nov | dec | january |
february | ... | december
<daily-keyword> = daily
<weekly-keyword> = weekly
<monthly-keyword> = monthly
<hourly-keyword> = hourly
<digit> = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0
<number> = <digit> | <digit><number>
<12hour> = 0 | 1 | 2 | ... 12
<hour> = 0 | 1 | 2 | ... 23
<minute> = 0 | 1 | 2 | ... 59
<day> = 1 | 2 | ... 31
<time> = <hour>:<minute> |
<12hour>:<minute>am |
<12hour>:<minute>pm
<time-spec> = <at-keyword> <time> |
<hourly-keyword>
<date-keyword> = <void-keyword> <weekly-keyword>
<day-range> = <day>-<day>
<month-range> = <month-keyword>-<month-keyword>
<wday-range> = <wday-keyword>-<wday-keyword>
<range> = <day-range> | <month-range> |
<wday-range>
<date> = <date-keyword> | <day> | <range>
<date-spec> = <date> | <date-spec>
<day-spec> = <day> | <wday-keyword> |
<day> | <wday-range> |
<week-keyword> <wday-keyword> |
<week-keyword> <wday-range> |
<daily-keyword>
<month-spec> = <month-keyword> | <month-range> |
<monthly-keyword>
<date-time-spec> = <month-spec> <day-spec> <time-spec>
針對時間設定規範中的一些詞解釋一下:
mday |
月的某一天 |
wday |
周的某一天 |
wom |
月的某一週 |
woy |
年的某一週 |
下面舉例說明一下
範例:天天在2:05執行徹底備份。
Schedule {
Name = "Daily"
Run = Level=Full daily at 2:05
}
範例:週日2:05執行徹底備份,週一到週六2:05執行增量備份。
Schedule {
Name = "WeeklyCycle"
Run = Level=Full sun at 2:05
Run = Level=Incremental mon-sat at 2:05
}
範例:每個月第一週的週日2:05執行徹底備份,每個月第二到第五週的週日2:05執行差別備份,週一到週六2:05執行增量備份。
Schedule {
Name = "MonthlyCycle"
Run = Level=Full Pool=Monthly 1st sun at 2:05
Run = Level=Differential 2nd-5th sun at 2:05
Run = Level=Incremental Pool=Daily mon-sat at 2:05
}
範例:每個月1日2:05執行徹底備份,其他日期2:05執行增量備份。
Schedule {
Name = "First"
Run = Level=Full on 1 at 2:05
Run = Level=Incremental on 2-31 at 2:05
}
範例:每10分鐘執行徹底備份。
Schedule {
Name = "TenMinutes"
Run = Level=Full hourly at 0:05
Run = Level=Full hourly at 0:15
Run = Level=Full hourly at 0:25
Run = Level=Full hourly at 0:35
Run = Level=Full hourly at 0:45
Run = Level=Full hourly at 0:55
}
Fileset{}定義哪些文件須要備份或者哪些文件排除在備份任務中,定義一個Fileset{}是每一個備份任務必須的。可定義一個文件或者目錄清單,可將壓縮、加密和簽名各類備份方案應用到每一個文件。
Fileset{}部分的官方文檔見The FileSet Resource,文檔部分也引用了Victor’s CUBlog的文檔。
Name = name 指定Fileset{}名稱,必選。 |
Ignore FileSet Changes = yesno 默認爲no。詳細說明請參考官方文檔 |
Enable VSS = yesno 是否啓用卷影複製服務,默認爲yes。此指令僅適用於啓用VSS的有效的Win32文件守護進程。 |
Include { Options {file-options} ...; file-list } 設置客戶端須要備份的文件及目錄的路徑,及備份方案。一個Fileset{}可包含多個Include{},一個Include{}可包含多個Options{}。下面再詳細說明。 |
Include{}必須包含一個目錄列表或文件。正常狀況下,目錄中的全部子目錄及文件都會被備份。
客戶端是Windows系統的備份文件路徑以「/」 代替「\」,並且須要使用雙引號括起來。例,須要備份C盤,路徑則以」C:/」表示。
當文件路徑存中在空格也須要使用雙引號括起來。
如下Options{}參數的說明
compression=GZIP 使用GZIP6壓縮格式備份文件 |
signature=SHA1 對備份文件添加SHA1簽名。聽說比MD5算法慢,可是相對更安全。 |
signature=MD5 對備份文件添加MD5簽名。Catalog數據庫裏將爲每一個文件多寫大於16字節的MD5簽名,推薦設置此參數。注意SHA1簽名和MD5簽名只容許使用一個。 |
basejob=options The options letters specified are used when running a Backup Level=Full with BaseJobs. The options letters are the same than in the verify= option below. |
accurate=options The options letters specified are used when running a Backup Level=Incremental/Differential in Accurate mode. The options letters are the same than in the verify= option below. |
verify=options The options letters specified are used when running a Verify Level=Catalog as well as the DiskToCatalog level job. The options letters may be any combination of the following: i compare the inodes p compare the permission bits n compare the number of links u compare the user id g compare the group id s compare the size a compare the access time m compare the modification time (st_mtime) c compare the change time (st_ctime) d report file size decreases 5 compare the MD5 signature 1 compare the SHA1 signature |
onefs=yesno 默認爲yes,這個選項是指定Bacula備份分區時若是發現該分區裏有不一樣的文件系統存在是否一塊兒備份,yes不備份,no備份。若是你忘記了備份某個特別的分區(例如/dev,/proc,/net,/sys.....)這個選項會頗有用,由於它會提醒你該分區裏包含了什麼不一樣分區。 若是你想備份多個文件系統或者要把某個分區連同該分區下掛載的nfs,samba數據(前提是沒在exclude裏定義的)都備份下來的話你能夠設置no,但這樣作有個弊端可能引發備份迴環的問題發生,最好的設置是onefs=no ; fstype=ext2配合。 |
honor nodump flag=yesno If your file system supports the nodump flag (e. g. most BSD-derived systems) Bacula will honor the setting of the flag when this option is set to yes. Files having this flag set will not be included in the backup and will not show up in the catalog. For directories with the nodump flag set recursion is turned off and the directory will be listed in the catalog. If the honor nodump flag option is not defined or set to no every file and directory will be eligible for backup. |
portable=yesno 默認爲no,若是爲yes,Bacula將按照輕便的格式備份文件,以便儘量多的保存WIN32系統的文件信息。 |
recurse=yesno 設置目錄遞歸,默認爲yes。 |
sparse=yesno 默 認爲no。這裏是設置若是有稀疏的文件(直譯)Bacula是否將zero字節的部分也備份下來,若是選no不檢測sparse file的話將備份文件空白的部分佔用不少的磁帶或卷空間,選yes檢測的話就不備份空白字節,作到這點的代價是Bacula必須在備份前檢查每一個塊備份 速度將變慢。 |
readfifo=yesno 默認爲no。 |
noatime=yesno |
mtimeonly=yesno 默認爲no。若是爲yes,備份時將以文件修改時間爲準;若是爲no,則自動按照文件的修改時間或訪問時間備份。 |
keepatime=yesno 默認爲no。若是爲yes,備份時將先備份文件的訪問時間,恢復時也將保持文件的原有訪問時間。 |
checkfilechanges=yesno 在2.0.4或更高版本,若是啓用此項,客戶端備份後將檢查每一個文件的大小、日期在備份過程當中時候改變。若是大小或時間不匹配,將引起錯誤。建議啓用此項。 錯誤舉例: zog-fd: Client1.2007-03-31_09.46.21 Error: /tmp/test mtime changed during backup. |
hardlinks=yesno 默認yes,按照硬連接軌跡備份文件。若是硬連接過多將消耗大量CPU資源。 |
wild=string 指定字符串應用於文件名或目錄名。請注意若是Exclude未啓用,那麼字符串將匹配被包括在內的文件;若是Exclude=yes,那麼字符串將匹配被排除在外的文件。能夠指定多個字符串;若是排除的是一個目錄,那麼下面的文件或目錄將不作匹配。 |
wilddir=string 指定字符串應用於目錄名,此參數不會匹配文件名。 |
wildfile=string 指定字符串應用於非目錄。注意這個字符串匹配也適用於完整路徑和文件名,那麼指定字符串時注意文件名前面的路徑。 |
regex=string 指定POSIX擴展正則表達式應用到文件名和目錄名,也包括完整的路徑。 建議使用簡潔的語句,已節省CPU開銷;使用雙引號將字符串括起來。 |
regexfile=string 指定POSIX擴展正則表達式應用到非目錄。 |
regexdir=string 指定POSIX擴展正則表達式應用到目錄名。 |
exclude=yesno 默認爲no。啓用時,匹配的任何文件將不備份。 |
aclsupport=yesno 默 認爲no。若是系統安裝libacl庫支持ACL,Bacula會自動將支持acl編譯進來。若是選擇yes,備份和恢復時都會參考acl。注意,若是備 份帶有acl的ext三、xfs系統的文件或目錄,恢復到一個不支持acl的系統例如reiserfs時acl將被忽略。 |
ignore case=yesno 默認爲no,啓用時,不區分大小寫。 |
fstype=filesystem-type 指定文件和目錄的文件系統,此參數不該用於WIN32系統。 在一個Options{}裏容許你同時指定多個文件系統,若是你指定的文件系統與你要備份的分區不匹配將不會執行備份操做,這個指示經常使用在防止備份非本地的文件系統,按理說當你設置了這個指示後,你也將同時設置onefs=no以便bacula在文件系統中來回移動。 容許的文件系統類型包括:ext2, jfs, ntfs, proc, reiserfs, xfs, usbdevfs, sysfs, smbfs, iso9660. For ext3 systems, use ext2. |
DriveType=Windows-drive-type 指定Windows驅動器的類型,此參數不該用於Unix/Linux系統。容許的值有: removable, fixed, remote, cdrom, ramdisk |
hfsplussupport=yesno 這個參數容許控制是否打開支持Mac OSX HFS plus插件。 |
strippath=integer This option will cause integer paths to be stripped from the front of the full path/filename being backed up. This can be useful if you are migrating data from another vendor or if you have taken a snapshot into some subdirectory. This directive can cause your filenames to be overlayed with regular backup data, so should be used only by experts and with great care. |
file-list
一個或多個文件或目錄路徑,使用’File=’開頭。包含空格時,須要使用雙引號。Wild-cards 應用於Options{},不該用於file-list。
下面這些例子在file-list中比較特殊:
l 使用‘@’代替’File=’做爲開頭,‘@’後面爲主控端的文件路徑,而不是客戶端的文件路徑。例:
Include {
Options { compression=GZIP }
@/home/files/my-files
}
l ’File=’做爲開頭,使用‘|’後跟命令、腳本代替文件路徑。詳細見官方文檔。
l ’File=’做爲開頭,使用‘<’後跟主控端文件路徑。詳細見官方文檔。
l 使用設備、分區代替文件路徑。此時也建議設置sparse=yes參數。例:
Include {
Options { signature=MD5; sparse=yes }
File = /dev/hd6
}
l If you explicitly specify a FIFO device name (created with mkfifo), and you add the option readfifo=yes as an option, Bacula will read the FIFO and back its data up to the Volume.詳見官方文檔。 For example:
Include {
Options {
signature=SHA1
readfifo=yes
}
File = /home/abc/fifo
}
l 使用ExcludeDirContaining = filename參數時,當目錄中的文件符合filename值,那麼此文件所在的目錄將不備份。例:
# List of files to be backed up
FileSet {
Name = "MyFileSet"
Include {
Options {
signature = MD5
}
File = /home
Exclude Dir Containing = .excludeme
}
}
此時/home目錄下有兩個子目錄中包含.excludeme的文件
/home/user/www/cache/.excludeme
/home/user/temp/.excludeme
那麼這兩個目錄將不備份
/home/user/www/cache/
/home/user/temp/
如下是FileSet{}的範例
範 例1:第一個Include備份全部/etc/backup.list裏除了.Z和.gz的文件和目錄,並GZIP壓縮,SHA1簽名,檢測稀疏文件處 理。第二個Include備份/root/myfile目錄和/usr/lib/目錄下的全部子目錄和文件,可是*.o,*.exe文件除外。
FileSet {
Name = "Full Set"
Include {
Options {
Compression=GZIP
signature=SHA1
Sparse = yes
}
Options {
wildfile = "*.Z"
wildfile = "*.gz"
Exclude = yes
}
@/etc/backup.list
}
Include {
Options {
wildfile = "*.o"
wildfile = "*.exe"
Exclude = yes
}
File = /root/myfile
File = /usr/lib/
}
}
範例2:備份整個系統
$ df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/hda5 5044156 439232 4348692 10% /
/dev/hda1 62193 4935 54047 9% /boot
/dev/hda9 20161172 5524660 13612372 29% /home
/dev/hda2 62217 6843 52161 12% /rescue
/dev/hda8 5044156 42548 4745376 1% /tmp
/dev/hda6 5044156 2613132 2174792 55% /usr
none 127708 0 127708 0% /dev/shm
//minimatou/c$ 14099200 9895424 4203776 71% /mnt/mmatou
lmatou:/ 1554264 215884 1258056 15% /mnt/matou
lmatou:/home 2478140 1589952 760072 68% /mnt/matou/home
lmatou:/usr 1981000 1199960 678628 64% /mnt/matou/usr
lpmatou:/ 995116 484112 459596 52% /mnt/pmatou
lpmatou:/home 19222656 2787880 15458228 16% /mnt/pmatou/home
lpmatou:/usr 2478140 2038764 311260 87% /mnt/pmatou/usr
deuter:/ 4806936 97684 4465064 3% /mnt/deuter
deuter:/home 4806904 280100 4282620 7% /mnt/deuter/home
deuter:/files 44133352 27652876 14238608 67% /mnt/deuter/files
考慮到/tmp、/proc,nfs,samba文件系統.journal;.autofsck應該排除,則設置以下:
FileSet {
Name = Include_example
Include {
Options {
wilddir = /proc
wilddir = /tmp
wildfile = "/.journal"
wildfile = "/.autofsck"
exclude = yes
}
File = /
File = /boot
File = /home
File = /rescue
File = /usr
}
}
範例3:只備份帶有字母a和字母b的子目錄
FileSet {
Name = "Full Set"
Include {
Options {
wilddir = "/home/a*"
wilddir = "/home/b*"
}
File = /home
}
}
範例4:排除c – z 開頭的目錄
FileSet {
Name = "Full Set"
Include {
Options {
RegexDir = "^/home/[c-z]"
exclude = yes
}
File = /home
}
}
範例5:備份一個分區或設備
FileSet {
Name = "RawPartition"
Include {
Options { sparse=yes }
File = /dev/hda2
}
}
範例6:備份Windows文件系統
FileSet {
Name = "Windows 2000"
Include {
Options {
signature = MD5
IgnoreCase = yes
# Exclude directories full of lots and lots of useless little files
WildDir = "[A-Z]:/Documents and Settings/*/Cookies"
WildDir = "[A-Z]:/Documents and Settings/*/Recent"
Exclude = yes
}
File = "C:/"
File = "D:/"
}
}
Client{}爲主控端定義了所屬客戶端的屬性,須要將每臺須要備份的客戶端都定義一個Client{}。官方文檔見The Client Resource
Name = name 指定Client{}名稱,可設置爲客戶端計算機名-fd,有利於記憶。必選。 |
Address = address 指定客戶端地址,能夠是IP或者計算機名,若是選擇計算機名,必須在/etc/hosts文件中加入解析條目,讓系統能解析到此計算機名。必選。 |
FD Port = port-number 指定客戶端監聽端口號。默認爲9102。 |
Catalog = Catalog-resource-name 引用Catalog{}的Name值,爲客戶端調用。必選。 |
Password = password 指定客戶端的密碼,出於安全緣由,最好設置複雜密碼,必選。 |
File Retention = time-period-specification 定義文件記錄在Catalog數據庫中的保留時間,不影響已存檔的備份文件,須要設置AutoPrune = yes。默認60天。 |
Job Retention = time-period-specification 定義任務記錄在Catalog數據庫中的保留時間,不影響已存檔的備份文件,須要設置AutoPrune = yes。默認6個月。 |
AutoPrune = yesno 是否自動修剪,默認爲yes。 |
Maximum Concurrent Jobs = number 設置同時進行的做業最大數,默認爲1。 |
Priority = number 設置客戶端的優先級,能夠設置1到1000,數字越小優先級越高。 |
範例
Client {
Name = ser1-fd
Address = ser1
FDPort = 9102
Catalog = MyCatalog
Password = "333" # password for FileDaemon
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}