備份/恢復系統BAREOS的安裝、設定和使用(二)
備份/恢復系統BAREOS的設定
本文將介紹如何設定bareos系統,將分別介紹Bareos系統主機設定(含Director Daemon、Storage Daemon和Storage Daemon)、客戶機安裝/設定和系統整合測試。
在介紹設定前,我們先簡單介紹一下bareos系統架構,方便大家理解。
管理終端: bconsole:全功能CLI管理終端。 WebUI:只能用於備份和恢復,同時包含基於Web的CLI介面。
管理服務(Director Daemon): 執行在bareos管理機上,包含全部管理功能、CLI管理服務、WebUI後臺支援、目錄(catalog)資料庫支援等。
儲存服務(Storage Daemon): 執行在bareos管理機上,支援不同的物理儲存媒體(如硬碟儲存系統、磁帶儲存系統等),管理資料的讀取和儲存。
檔案服務(File Daemon): 執行在客戶機上,管理本地檔案的備份和恢復。
儲存媒體: 物理儲存媒體(如硬碟儲存系統、磁帶儲存系統等)。
Bareos系統設定
配置Bareos儲存服務(Storage Daemon)模組
Bareos儲存服務(Storage)模組為bareos系統提供資料儲存服務模組。它的配置檔案位於/etc/bareos/bareos-sd.d目錄下。
[email protected]:/etc/bareos/bareos-sd.d# ls -l
total 16
drwxr-x--- 2 bareos bareos 4096 Sep 16 11:37 device
drwxr-x--- 2 bareos bareos 4096 Sep 16 11:37 director
drwxr-x--- 2 bareos bareos 4096 Sep 16 11:44 messages
drwxr-x--- 2 bareos bareos 4096 Sep 16 11:43 storage
[email protected]:/etc/bareos/bareos-sd.d#
配置Storage的儲存裝置
device下放的是儲存媒體配置檔案,bareos系統是基於檔案的備份/恢復系統,device下只有一個配置檔案FileStorage.conf。
可能的FileStorage.conf如下:
# HDD 儲存裝置 Device { Name = FileStorage # 裝置名稱 Media Type = File # 型別,bareos是基於檔案的備份/恢復系統,型別永遠是檔案 Archive Device = /bareos/hdd # Ubuntu下的備份檔案目錄(或mount point) LabelMedia = yes; # lets Bareos label unlabeled media Random Access = yes; # 可隨機讀寫 AutomaticMount = yes; # 自動載入 RemovableMedia = no; # 媒體介質不可移除 AlwaysOpen = yes; # 總是開啟 } # 磁帶儲存裝置 Device { Name = TapeStorage # 裝置名稱 Media Type = File # 型別,bareos是基於檔案的備份/恢復系統,型別永遠是檔案 Archive Device = /bareos/tape # Ubuntu下的mount point LabelMedia = yes; # lets Bareos label unlabeled media Random Access = no; # 不能隨機讀寫 AutomaticMount = no; # 不自動載入 RemovableMedia = yes; # 媒體介質可移除 AlwaysOpen = no; # 按需開啟 }
在上述配置檔案中,我們配置了二種儲存裝置,分別是硬碟和磁帶。在配置時,請注意被配置儲存裝置的物理屬性。硬碟類的儲存裝置是可隨機讀寫,磁帶類的是不可隨機讀寫。 現在公司一般很少配磁帶備份,我們的備份方案是:在/bareos/hdd下掛載SAN裝置,然後通過rsync將/bareos/hdd目錄下的內容同步到遠端SAN上,從而保證資料的安全。
例項中的FileStorage.conf檔案:
/etc/bareos/bareos-sd.d/device/FileStorage.conf
# HDD 儲存裝置
Device {
Name = FileStorage # 裝置名稱
Media Type = File # 型別,bareos是基於檔案的備份/恢復系統,型別永遠是檔案
Archive Device = /bareos/hdd # Ubuntu下的mount point
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes; # 可隨機讀寫
AutomaticMount = yes; # 自動載入
RemovableMedia = no; # 媒體介質不可移除
AlwaysOpen = yes; # 總是開啟
}
配置Storage的ACL
director下有二個配置檔案bareos-dir.conf
和bareos-mon.conf
,分別用於管理director和monitor對storage模組的授權。
/etc/bareos/bareos-sd.d/director/bareos-dir.conf
Director {
Name = bareos-dir # 名字
Password = "JgwtSYloo93DlXnt/cjUfPJIAD9zocr920FEXEV0Pn+S" # 密碼
Description = "允許操作此storage的Director設定"
}
/etc/bareos/bareos-sd.d/director/bareos-mon.conf
Director {
Name = bareos-mon
Password = "4wdzVcvZAFgTz+IWlB4C5hd09czTXhsAd8SnZQ1VZn4X"
Monitor = yes
Description = "允許讀取此storage狀態的Monitor設定"
}
monitor是bareos的GUI監視程式。
配置 storage 相關資訊服務
/etc/bareos/bareos-sd.d/messages/Standard.conf
Messages {
Name = Standard
Director = bareos-dir = all # bareos-dir:傳送資訊到bareis-dir,all:所有資訊
# mailcommand = # 可執行命令或指令碼
# operatorcommand = # 可執行命令或指令碼
Description = "Send all messages to the Director."
# 可用引數
# %% = %
# %c = Client’s name
# %d = Director’s name
# %e = Job Exit code (OK, Error, ...)
# %h = Client address
# %i = Job Id
# %j = Unique Job name
# %l = Job level
# %n = Job name
# %r = Recipients
# %s = Since time
# %t = Job type (e.g. Backup, ...)
# %v = Read Volume name (Only on director side)
# %V = Write Volume name (Only on director side)
}
配置 storage 相關特性或功能
Storage {
Name = bareos-sd
Maximum Concurrent Jobs = 20
# remove comment from "Plugin Directory" to load plugins from specified directory.
# if "Plugin Names" is defined, only the specified plugins will be loaded,
# otherwise all storage plugins (*-sd.so) from the "Plugin Directory".
#
# Plugin Directory = /usr/lib/bareos/plugins
# Plugin Names = ""
}
一般情況下,我們只需要修改FileStorage.conf配置檔案中的Archive Device
,預設的Archive Device
是/var/lib/bareos/storage
,預設的bareos-sd
配置能滿足一般需求。
修改bareos-sd
的配置後,必須重啟bareos-sd
。在重啟bareos-sd
前,請首先使用bareos-sd -t -v
檢查bareos-sd
配置檔案。如bareos-sd -t -v
沒有任何輸出,說明配置檔案沒有任何語法問題,可以重啟bareos-sd
。
配置Bareos管理(Director)模組
Bareos管理(Director)模組為bareos系統管理模組。它的配置檔案位於/etc/bareos/bareos-dir.d目錄下。
[email protected]:/etc/bareos/bareos-dir.d# ls -l
total 48
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 catalog
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 client
drwxr-x--- 2 bareos bareos 4096 Sep 11 11:08 console
drwxr-x--- 2 bareos bareos 4096 Sep 15 20:42 director
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 fileset
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 job
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 jobdefs
drwxr-x--- 2 bareos bareos 4096 Sep 18 17:18 messages
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 pool
drwxr-x--- 2 bareos bareos 4096 Sep 15 20:45 profile
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 schedule
drwxr-x--- 2 bareos bareos 4096 Sep 11 09:13 storage
[email protected]:/etc/bareos/bareos-dir.d#
配置檔案的檔名可任意,但必須以.conf
結尾。
目錄(catalog)資料庫連結方式配置檔案
/etc/bareos/bareos-dir.d/MyCatalog.conf
Catalog {
Name = MyCatalog # catalog名字
dbdriver = mysql # 使用MySQL驅動(相容MariaDB)
dbname = bareos # 資料庫名
dbuser = bareos # 該資料庫之使用者名稱
dbpassword = bareos # 該使用者之密碼
}
該檔案在安裝bareos-mysql時已被初始化,一般情況下無需修改。
客戶端(File Daemon)配置檔案
/etc/bareos/bareos-dir.d/client/clientname-fd.conf
下面是bareos伺服器的預設File Daemon配置檔案:
Client {
Name = bareos-fd # Director中使用的客戶端名字
Description = "Client resource of the Director itself." # 解釋
Address = localhost # 客戶端FQDN或IP地址
Password = "QGSqraVyf7kQfpdTxv+j/h27nesW7ypmGP5wLPLXltE9" # 密碼
}
配置客戶端可以直接建立/修改配置檔案,也可以通過bconsole來完成。
下面是使用bconsole建立客戶端示例:
[email protected]:~# bconsole
Connecting to Director localhost:9101
1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017)
Enter a period to cancel a command.
*configure add client name=lscms-fd address=lscms.lswin.cn password=lscmsFdPasswd
我們可以在/etc/bareos/bareos-dir.d/client下見到新的客戶端配置檔案lscms-fd.conf
。內容為:
Client {
Name = lscms-fd
Address = lscms.lswin.cn
Password = lscmsFdPasswd
}
終端(console)配置檔案
在該目錄(/etc/bareos/bareos-dir.d/console
)下有二個配置檔案:admin.conf 和 bareos-mon.conf
/etc/bareos/bareos-dir.d/console/admin.conf
:Web GUI 配置檔案
/etc/bareos/bareos-dir.d/console/bareos-mon.conf
:Bareos 托盤監測配置檔案
Web GUI 配置檔案 /etc/bareos/bareos-dir.d/console/admin.conf
:
Console {
Name = admin
Password = pwd111111
Profile = webui-admin # 指明是為WebGUI,該名字必須是webui-admin
}
托盤監測配置檔案/etc/bareos/bareos-dir.d/console/bareos-mon.conf
Console {
Name = bareos-mon
Description = "Restricted console used by tray-monitor to get the status of the director."
Password = "8ipdQxiufhgskdNWk4ydvVWZfXGa9SmVBG690X+Mh9Ph"
CommandACL = status, .status # 只有 status 命令或 .status命令被授權
JobACL = *all* # 所有任務都被授權
}
一般情況下,這些檔案無需修改。
控制端(Director)配置檔案
/etc/bareos/bareos-dir.d/director/bareos-dir.conf
Director { # 配置控制端
Name = bareos-dir
QueryFile = "/usr/lib/bareos/scripts/query.sql"
Maximum Concurrent Jobs = 10 # 同時可執行10個任務,更多工需排隊
Password = "LiYwqsOHIEhfjPts14Pvenk9YMfmWEN81PxugpdOHt3C" # 控制端 password
Messages = Daemon # 只接受駐留任務訊息
Auditing = yes # 開啟審計
# Enable the Heartbeat if you experience connection losses
# Heartbeat Interval = 1 min # 如Director不在本地,可能需要開啟
}
一般情況,無需修改。
備份檔案組(fileset)配置檔案
/etc/bareos/bareos-dir.d/fileset/*.conf
該目錄下有一系列配置檔案,這些檔案用於定義如何備份一組檔案(fileset)。 這是最重要的配置之一,而又只能通過終端手工配置,所以我們在此將詳細介紹。
一、備份Linux電腦
FileSet { # fileset 開始標誌
Name = "LinuxAll" # 該 fileset 的名字,這個名字會在備份任務中使用
Description = "備份所有系統,除了不需要備份的。"
Include { # 備份中需要包含的檔案
Options { # 選項
Signature = MD5 # 每個檔案產生MD5校驗檔案
One FS = No # 所有指定的檔案(含子目錄)都會被備份
# One FS = Yes # 指定的檔案(含子目錄)如不在同一檔案系統下不會被備份
#
# 需要備份的檔案系統型別列表
FS Type = btrfs # btrfs 檔案系統需要備份
FS Type = ext2 # ext2 檔案系統需要備份
FS Type = ext3 # ext3 檔案系統需要備份
FS Type = ext4 # ext4 檔案系統需要備份
FS Type = reiserfs # reiserfs 檔案系統需要備份
FS Type = jfs # jfs 檔案系統需要備份
FS Type = xfs # xfs 檔案系統需要備份
FS Type = zfs # zfs 檔案系統需要備份
}
File = / # 所有目錄和檔案
}
# 定義不需要備份的檔案和目錄
Exclude { # 備份中不應該包含的檔案
# 無需備份檔案/目錄列表
File = /var/lib/bareos # /var/lib/bareos 下放的是bareos的臨時檔案
File = /var/lib/bareos/storage # /var/lib/bareos/storage 下放的是備份檔案
File = /proc # /proc 無需備份
File = /tmp # /tmp無需備份
File = /var/tmp # /var/tmp無需備份
File = /.journal # /.journal 無需備份
File = /.fsck # /.fsck無需備份
}
}
一般情況下,您只需要修改該檔案來達到不同的備份需求。如子備份/home
目錄:
......
FS Type = xfs # xfs 檔案系統需要備份
FS Type = zfs # zfs 檔案系統需要備份
}
File = /home # /home下的所有目錄和檔案
}
# 定義不需要備份的檔案和目錄
Exclude { # 備份中不應該包含的檔案
# 無需備份檔案/目錄列表
File = /var/lib/bareos # /var/lib/bareos 下放的是bareos的臨時檔案
......
二、備份Windows電腦
FileSet {
Name = "Windows電腦備份[A-Z]:/QMDownload"
Enable VSS = yes # 當YES時,當檔案正在被寫時也能被備份;如NO,被寫檔案不會被備份
Include {
Options {
Signature = MD5
Drive Type = fixed # 只備份固定磁碟
IgnoreCase = yes # 忽略字母的大小寫
WildFile = "[A-Z]:/pagefile.sys" # 指定檔案:從磁碟A到Z下的/pagefile.sys
WildDir = "[A-Z]:/RECYCLER" # 指定檔案:從磁碟A到Z下的
WildDir = "[A-Z]:/$RECYCLE.BIN" # 指定檔案:從磁碟A到Z下的
WildDir = "[A-Z]:/System Volume Information" # 指定檔案:從磁碟A到Z下的
Exclude = yes # 另一種方式指定不備份上述指定檔案
}
File ="C: / QMDownload " # 備份目錄C:/QMDownload
}
}
如您需要備份不同的檔案,只需要修改 File =C: /QMDownload
即可。
如:
File = D:/Data # 備份D:/Data目錄
使用者可根據不同的需求來定義不同的fileset。
三、下面我們定義一個用於測試任務的fileset(TestSet
)
FileSet { # fileset 開始標誌
Name = "TestSet" # 該 fileset 的名字,這個名字會在備份任務中使用
Description = "備份/usr/sbin(用於測試任務)"
Include { # 備份中需要包含的檔案
Options { # 選項
Signature = MD5 # 每個檔案產生MD5校驗檔案
One FS = No # 所有指定的檔案(含子目錄)都會被備份
# One FS = Yes # 指定的檔案(含子目錄)如不在同一檔案系統下不會被備份
#
# 需要備份的檔案系統型別列表
FS Type = btrfs # btrfs 檔案系統需要備份
FS Type = ext2 # ext2 檔案系統需要備份
FS Type = ext3 # ext3 檔案系統需要備份
FS Type = ext4 # ext4 檔案系統需要備份
FS Type = reiserfs # reiserfs 檔案系統需要備份
FS Type = jfs # jfs 檔案系統需要備份
FS Type = xfs # xfs 檔案系統需要備份
FS Type = zfs # zfs 檔案系統需要備份
}
File = /"/usr/sbin" # 所有目錄和檔案
}
}
因為沒有不需要備份的檔案,所以我們移除了Exclude。
備份任務定義(jobdefs)配置檔案
/etc/bareos/bareos-dir.d/jobdefs/*.conf
例項:測試任務(TestJob)
JobDefs {
Name = "TestJob" # 測試任務
Type = Backup # 型別:備份(Backup)
Level = Incremental # 方式:遞進(Incremental)
Client = bareos-fd # 被備份客戶端:bareos-fd (在Client中定義)
FileSet = "TestSet" # 備份檔案組:TesetSet (在FileSet中定義)
Schedule = "WeeklyCycle" # 備份週期:WeeklyCy(在schedule中定義)
Storage = File # 備份媒體: File(在Storage中定義)
Messages = Standard # 訊息方式:Standard(在Message中定義)
Pool = Incremental # 儲存池:Incremental(在pool中定義)
Priority = 10 # 優先順序:10
Write Bootstrap = "/var/lib/bareos/%c.bsr" #
Full Backup Pool = Full # Full備份,使用 "Full" 池(在storage中定義)
Differential Backup Pool = Differential # Differential備份,使用 "Differential" 池(在storage中定義)
Incremental Backup Pool = Incremental # Incremental備份,使用 "Incremental" 池(在storage中定義)
}
任務(job)配置檔案
/etc/bareos/bareos-dir.d/job/*.conf
配置備份任務:例項:在客戶端bareos-fa上執行TestJob(備份/usr/sbin下的所有檔案)
Job {
Name = "backup-test-on-bareos-fd" # 任務名
JobDefs = "TestJob" # 使用已定義的備份任務TestJob (在jobdefs中定義)
Client = "bareos-fd" # 客戶端名稱: bareos-fd(在client中定義)
}
儲存媒體(storage)配置檔案
/etc/bareos/bareos-dir.d/storage/*.conf
Storage {
Name = File
Address = bareos # director-sd名字,使用FQDN (不要使用 "localhost" ).
Password = "JgwtSYloo93DlXnt/cjUfPJIAD9zocr920FEXEV0Pn+S"
Device = FileStorage # 在bareos-sd中定義
Media Type = File
}
注意:Device是在Bareos的Storage Daemon中定義的,Device的名字和Media Type必須一致。
這是在安裝時自動生成的儲存媒體配置檔案,如使用本地硬碟檔案系統做儲存媒體,不需要做任何修改。
儲存池(pool)配置檔案
/etc/bareos/bareos-dir.d/pool/*.conf
一般情況下,我們需要四個儲存池。分別是:
Full:用於完整備份【Full:備份所有檔案】
Incremental:用於遞增備份【Incremental:備份所有狀態變化的檔案】
Differential:用於差異備份【Differential:備份所有修改了(modified標誌變化)的檔案】
Scratch:當系統找不到需要的Volume時,自動使用該儲存池。
Scratch名稱不可修改,其他儲存池名字可修改。
下面是系統安裝時生成的pool定義檔案,一般情況下無需修改。
Differential.conf
Pool {
Name = Differential
Pool Type = Backup
Recycle = yes # Bareos 自動回收重複使用 Volumes(Volume備份檔案標記)
AutoPrune = yes # 自動清除過期的Volumes
Volume Retention = 90 days # Volume有效時間
Maximum Volume Bytes = 10G # Volume最大尺寸
Maximum Volumes = 100 # 單個儲存池允許的Volume數量
Label Format = "Differential-" # Volumes 將被標記為 "Differential-<volume-id>"
}
Full.conf
Pool {
Name = Full
Pool Type = Backup
Recycle = yes # Bareos 自動回收重複使用 Volumes(Volume備份檔案標記)
AutoPrune = yes # 自動清除過期的Volumes
Volume Retention = 365 days # Volume有效時間
Maximum Volume Bytes = 50G # Volume最大尺寸
Maximum Volumes = 100 # 單個儲存池允許的Volume數量
Label Format = "Full-" # Volumes 將被標記為 "Differential-<volume-id>"
}
Incremental.conf
Pool {
Name = Incremental
Pool Type = Backup
Recycle = yes # Bareos 自動回收重複使用 Volumes(Volume備份檔案標記)
AutoPrune = yes # 自動清除過期的Volumes
Volume Retention = 30 days # Volume有效時間
Maximum Volume Bytes = 1G # Volume最大尺寸
Maximum Volumes = 100 # 單個儲存池允許的Volume數量
Label Format = "Incremental-" # Volumes 將被標記為 "Differential-<volume-id>"
}
Scratch.conf
Pool {
Name = Scratch
Pool Type = Scratch
}
修改bareos-dir
的配置後,必須重啟Director。在重啟Director前,請首先使用bareos-dir -t -v
檢查bareos-dir
配置檔案。如bareos-dir -t -v
沒有任何輸出,說明配置檔案沒有任何語法問題,可以重啟Director。
計劃(schedule)配置檔案
/etc/bareos/bareos-dir.d/schedule/*.conf
例項:
一、每月第一個週六晚9點做完整備份;
二、其餘週六晚9點做差異備份;
三、週一至週五晚九點做遞增備份。
Schedule {
Name = "WeeklyCycle"
Run = Full 1st sat at 21:00 # 每月第一個週六/晚九點,完整備份
Run = Differential 2nd-5th sat at 21:00 # 其餘週六/晚九點,差異備份
Run = Incremental mon-fri at 21:00 # 週一至週五,遞增備份
}
提示資訊(message)配置檔案
/etc/bareos/bareos-dir.d/message/*.conf
用於配置任務(job)完成後如何傳送提示資訊
示例:
Messages {
Name = Standard
Description = "Reasonable message delivery -- send most everything to email address and to the console."
# operatorcommand = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: Intervention needed for %j\" %r"
# mailcommand = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: %t %e of %c %l\" %r"
operator = [email protected] = mount # 執行operatorcommand命令,使用者:[email protected],操作:mount
mail = [email protected] = all, !skipped, !saved, !audit # 執行mailcommand,使用者:[email protected],操作:所有(除skipped,saved和audit)
console = all, !skipped, !saved, !audit # 所有操作,除skipped,saved和audit
append = "/var/log/bareos/bareos.log" = all, !skipped, !saved, !audit # 所有操作,除skipped,saved和audit
catalog = all, !skipped, !saved, !audit # 所有操作,除skipped,saved和audit
# 可用引數
# %% = %
# %c = Client’s name
# %d = Director’s name
# %e = Job Exit code (OK, Error, ...)
# %h = Client address
# %i = Job Id
# %j = Unique Job name
# %l = Job level
# %n = Job name
# %r = Recipients
# %s = Since time
# %t = Job type (e.g. Backup, ...)
# %v = Read Volume name (Only on director side)
# %V = Write Volume name (Only on director side)
# console:定義傳送到console的資訊
# append:定義傳送到日誌檔案的資訊
# catalog:定義傳送到資料庫的資訊
}
bsmtp只適用於有本地SMTP伺服器,一般情況並不適用。我們將另文介紹如何使用外部SMTP郵件伺服器傳送bareos的資訊郵件。
Bareos的Director已配置完成,在開始備份任務前,我們還需要配置客戶端(File Daemon)。
配置Bareos客戶端(File Daemon)模組
Bareos客戶端(File Daemon)模組的配置檔案位於/etc/bareos/bareos-dir.d目錄下。
一、新增/配置客戶機
需要在Director和客戶機上分別配置。
首先在Director上有 bconsole 新增客戶機 scm.lswin.cn(這是示例用Ubuntu客戶機)
[email protected]:~# bconsole
Connecting to Director localhost:9101
1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017)
Enter a period to cancel a command.
*
You have messages.
*configure add client name=scm-fd address=scm.lswin.cn password=scmFdPass
Exported resource file "/etc/bareos/bareos-dir-export/client/scm-fd/bareos-fd.d/director/bareos-dir.conf":
Director {
Name = bareos-dir
Password = "[md5]94d9e38bace980feecc1be983f379823"
}
Created resource config file "/etc/bareos/bareos-dir.d/client/scm-fd.conf":
Client {
Name = scm-fd
Address = scm.lswin.cn
Password = scmFdPass
}
*
[email protected]:~# bconsole
Connecting to Director localhost:9101
1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017)
Enter a period to cancel a command.
*
You have messages.
*configure add client name=lswin7-1-fd address=lswin7-1.lswin.cn password=lswin7-1FdPass
Exported resource file "/etc/bareos/bareos-dir-export/client/lswin7-1-fd/bareos-fd.d/director/bareos-dir.conf":
Director {
Name = bareos-dir
Password = "[md5]c25dfe0e029bfcebc4feb30c0d68f857"
}
Created resource config file "/etc/bareos/bareos-dir.d/client/lswin7-1-fd.conf":
Client {
Name = lswin7-1-fd
Address = lswin7-1.lswin.cn
Password = lswin7-1FdPass
}
*
新增客戶機配置後,需要重啟Director,否則新增的客戶機不會出現在客戶機列表中。
二、在Ubuntu客戶機上安裝bareos-fd軟體包。
新增 Bareos 庫的APT健
[email protected]:~#
[email protected]:~# wget -q http://download.bareos.org/bareos/release/latest/Debian_9.0/Release.key -O- | apt-key add -
OK
[email protected]:~#
新增 Bareos 庫定義(/etc/apt/sources.list.d/bareos.list)
deb http://download.bareos.org/bareos/release/latest/Debian_9.0 /
更新 APT 庫
[email protected]:~# apt update
在Ubuntu安裝 bareos-fd軟體包
[email protected]:~# apt install bareos-filedaemon
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
bareos-common libfastlz libjansson4
The following NEW packages will be installed:
bareos-common bareos-filedaemon libfastlz libjansson4
0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.
Need to get 756 kB of archives.
After this operation, 2,369 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libjansson4 amd64 2.11-1 [29.3 kB]
......
......
......
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for ureadahead (0.100.0-20) ...
[email protected]:~#
然後將Director機器上的/etc/bareos/bareos-dir-export/client/scm-fd/bareos-fd.d/director/bareos-dir.conf
檔案複製到本地,檔案為/etc/bareos/bareos-fd.d
。複製完成後需重啟Bareos 的 FileDaemon,否則新的配置不會取作用。
三、在Windows客戶機上安裝bareos-fd軟體包。
安裝Bareos File Daemon
將Director機器上檔案/etc/bareos# /etc/bareos/bareos-dir-export/client/lswin7-1-fd/bareos-fd.d/director/bareos-dir.conf
中的Password複製到Password中;再將/etc/bareos/bareos-dir.d/bareos-dir.d/console/bareos-mon.conf
檔案中的Password複製到Client Monitor Password
中。如不需要Monitor,可忽略複製Client Monitor Password
這一步。
後面的只需要按提示進行直到完成即可。
到此為止Bareos的Director,Storage和Client都已經配置完成,可以使用了。
Bareos系統測試
在此我們使用bconsole對已配置的Bareos系統進行測試。
檢查安裝的版本
[email protected]:~# bconsole
Connecting to Director localhost:9101
1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017)
Enter a period to cancel a command.
*version
bareos-dir Version: 17.2.4 (21 Sep 2017) x86_64-pc-linux-gnu debian Debian GNU/Linux 9.3 (stretch) Debian_9.0 x86_64
*
安裝的bareos-dir版本是 17.2.4 的 Debian_9.0版,ubuntu 18.04是基於Debian_9.0。
檢查配置的客戶機
*show client
Client {
Name = "scm-fd"
Address = "scm.lswin.cn"
Password = "[md5]94d9e38bace980feecc1be983f379823"
Catalog = "MyCatalog"
}
Client {
Name = "lswin7-1-fd"
Address = "lswin7-1.lswin.cn"
Password = "[md5]c25dfe0e029bfcebc4feb30c0d68f857"
Catalog = "MyCatalog"
}
Client {
Name = "bareos-fd"
Description = "Client resource of the Director itself."
Address = "localhost"
Password = "[md5]33e11c4e5a631bf5620f66e4b4e18e76"
Catalog = "MyCatalog"
}
*
測試備份任務(backup-test-on-bareos-fd)
*
*run
A job name must be specified.
The defined Job resources are:
1: RestoreFiles
2: backup-test-on-bareos-fd
3: BackupCatalog
4: backup-bareos-fd
Select Job resource (1-4): 2
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Incremental
Client: bareos-fd
Format: Native
FileSet: TestSet
Pool: Incremental (From Job IncPool override)
Storage: File (From Job resource)
When: 2018-10-04 18:39:17
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: Backup Format
7: When
8: Priority
9: Pool
10: Plugin Options
Select parameter to modify (1-10): 1
Levels:
1: Full
2: Incremental
3: Differential
4: Since
5: VirtualFull
Select level (1-5): 1
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Full
Client: bareos-fd
Format: Native
FileSet: TestSet
Pool: Full (From Job FullPool override)
Storage: File (From Job resource)
When: 2018-10-04 18:39:17
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: Backup Format
7: When
8: Priority
9: Pool
10: Plugin Options
Select parameter to modify (1-10): 5
The defined Client resources are:
1: scm-fd
2: bareos-fd
Select Client (File daemon) resource (1-3): 1
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Full
Client: scm-fd
Format: Native
FileSet: TestSet
Pool: Full (From Job FullPool override)
Storage: File (From Job resource)
When: 2018-10-04 18:39:17
Priority: 10
OK to run? (yes/mod/no):
Job queued. JobId=13
*status
Status available for:
1: Director
2: Storage
3: Client
4: Scheduler
5: All
Select daemon type for status (1-5): 1
bareos-dir Version: 17.2.4 (21 Sep 2017) x86_64-pc-linux-gnu debian Debian GNU/Linux 9.3 (stretch)
Daemon started 04-Oct-18 18:03. Jobs: run=2, running=0 mode=0 db=mysql
Heap: heap=409,600 smbytes=260,292 max_bytes=302,389 bufs=1,044 max_bufs=1,458
Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 04-Oct-18 21:00 backup-test-on-bareos-fd Incremental-0002
Incremental Backup 10 04-Oct-18 21:00 backup-bareos-fd Incremental-0002
Full Backup 11 04-Oct-18 21:10 BackupCatalog Incremental-0002
====
Running Jobs:
Console connected at 04-Oct-18 18:32
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
4 Incr 0 0 OK 20-Sep-18 21:00 backup-bareos-fd
5 Full 62 84.23 K OK 20-Sep-18 21:10 BackupCatalog
6 Incr 0 0 OK 24-Sep-18 21:00 backup-bareos-fd
7 Full 67 96.19 K OK 24-Sep-18 21:10 BackupCatalog
10 Full 202 32.57 M OK 03-Oct-18 15:08 backup-test-on-bareos-fd
11 1 83.58 K OK 03-Oct-18 15:17 RestoreFiles
13 Full 175 30.33 M OK 04-Oct-18 18:40 backup-test-on-bareos-fd
Client Initiated Connections (waiting for jobs):
Connect time Protocol Authenticated Name
====================================================================================================
====
You have messages.
*messages
04-Oct 18:40 bareos-dir JobId 13: Start Backup JobId 13, Job=backup-test-on-bareos-fd.2018-10-04_18.40.45_37
04-Oct 18:40 bareos-dir JobId 13: Using Device "FileStorage" to write.
04-Oct 18:40 bareos-sd JobId 13: Volume "Full-0001" previously written, moving to end of data.
04-Oct 18:40 bareos-sd JobId 13: Ready to append to end of Volume "Full-0001" size=95925221
04-Oct 18:40 bareos-sd JobId 13: Elapsed time=00:00:01, Transfer rate=30.35 M Bytes/second
04-Oct 18:40 bareos-dir JobId 13: sql_create.c:872 Insert of attributes batch table done
04-Oct 18:40 bareos-dir JobId 13: Bareos bareos-dir 17.2.4 (21Sep17):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 9.3 (stretch)
JobId: 13
Job: backup-test-on-bareos-fd.2018-10-04_18.40.45_37
Backup Level: Full
Client: "scm-fd" 17.2.4 (21Sep17) x86_64-pc-linux-gnu,debian,Debian GNU/Linux 9.3 (stretch),Debian_9.0,x86_64
FileSet: "TestSet" 2018-10-03 15:08:15
Pool: "Full" (From Job FullPool override)
Catalog: "MyCatalog" (From Client resource)
Storage: "File" (From Job resource)
Scheduled time: 04-Oct-2018 18:39:17
Start time: 04-Oct-2018 18:40:47
End time: 04-Oct-2018 18:40:48
Elapsed time: 1 sec
Priority: 10
FD Files Written: 175
SD Files Written: 175
FD Bytes Written: 30,336,281 (30.33 MB)
SD Bytes Written: 30,354,503 (30.35 MB)
Rate: 30336.3 KB/s
Software Compression: None
VSS: no
Encryption: no
Accurate: no
Volume name(s): Full-0001
Volume Session Id: 2
Volume Session Time: 1538647406
Last Volume Bytes: 126,307,760 (126.3 MB)
Non-fatal FD errors: 0
SD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Backup OK
*
資訊顯示備份已成功完成。
測試恢復任務(backup-test-on-bareos-fd)
*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: bareos-fd
2: scm-fd
Select the Client (1-3): 3
Automatically selected FileSet: TestSet
+-------+-------+----------+------------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |
+-------+-------+----------+------------+---------------------+------------+
| 13 | F | 175 | 30,336,281 | 2018-10-04 18:40:47 | Full-0001 |
+-------+-------+----------+------------+---------------------+------------+
You have selected the following JobId: 13
Building directory tree for JobId(s) 13 ... +++++++++++++++++++++++++++++++++++++++++++
174 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: /
$
$ ls
usr/
$ mark usr
175 files marked.
$ done
Bootstrap records written to /var/lib/bareos/bareos-dir.restore.1.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
Full-0001 File FileStorage
Volumes marked with "*" are online.
175 files selected to be restored.
Run Restore job
JobName: RestoreFiles
Bootstrap: /var/lib/bareos/bareos-dir.restore.1.bsr
Where: /tmp/bareos-restores
Replace: Always
FileSet: LinuxAll
Backup Client: scm-fd
Restore Client: scm-fd
Format: Native
Storage: File
When: 2018-10-04 18:56:40
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no):
Job queued. JobId=16
*status
Status available for:
1: Director
2: Storage
3: Client
4: Scheduler
5: All
Select daemon type for status (1-5): 1
bareos-dir Version: 17.2.4 (21 Sep 2017) x86_64-pc-linux-gnu debian Debian GNU/Linux 9.3 (stretch)
Daemon started 04-Oct-18 18:03. Jobs: run=5, running=0 mode=0 db=mysql
Heap: heap=311,296 smbytes=535,619 max_bytes=836,693 bufs=1,209 max_bufs=1,792
Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 04-Oct-18 21:00 backup-test-on-bareos-fd Incremental-0002
Incremental Backup 10 04-Oct-18 21:00 backup-bareos-fd Incremental-0002
Full Backup 11 04-Oct-18 21:10 BackupCatalog Incremental-0002
====
Running Jobs:
Console connected at 04-Oct-18 18:32
No Jobs running.
====
Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
7 Full 67 96.19 K OK 24-Sep-18 21:10 BackupCatalog
10 Full 202 32.57 M OK 03-Oct-18 15:08 backup-test-on-bareos-fd
11 1 83.58 K OK 03-Oct-18 15:17 RestoreFiles
13 Full 175 30.33 M OK 04-Oct-18 18:40 backup-test-on-bareos-fd
16 175 30.33 M OK 04-Oct-18 18:56 RestoreFiles
Client Initiated Connections (waiting for jobs):
Connect time Protocol Authenticated Name
====================================================================================================
====
You have messages.
*
*messages
04-Oct 18:56 bareos-dir JobId 16: Start Restore Job RestoreFiles.2018-10-04_18.56.47_55
04-Oct 18:56 bareos-dir JobId 16: Using Device "FileStorage" to read.
04-Oct 18:56 bareos-sd JobId 16: Ready to read from volume "Full-0001" on device "FileStorage" (/var/lib/bareos/storage).
04-Oct 18:56 bareos-sd JobId 16: Forward spacing Volume "Full-0001" to file:block 0:95925221.
04-Oct 18:56 bareos-sd JobId 16: End of Volume at file 0 on device "FileStorage" (/var/lib/bareos/storage), Volume "Full-0001"
04-Oct 18:56 bareos-sd JobId 16: End of all volumes.
04-Oct 18:56 bareos-dir JobId 16: Bareos bareos-dir 17.2.4 (21Sep17):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 9.3 (stretch)
JobId: 16
Job: RestoreFiles.2018-10-04_18.56.47_55
Restore Client: scm-fd
Start time: 04-Oct-2018 18:56:49
End time: 04-Oct-2018 18:56:49
Elapsed time: 0 secs
Files Expected: 175
Files Restored: 175
Bytes Restored: 30,336,281
Rate: 0.0 KB/s
FD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Restore OK
*
資訊顯示檔案恢復已成功完成。
測試備份Windows電腦(backup-test-on-bareos-fd)
[email protected]:~#
[email protected]:~# bconsole
Connecting to Director localhost:9101
1000 OK: bareos-dir Version: 17.2.4 (21 Sep 2017)
Enter a period to cancel a command.
*run
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
A job name must be specified.
The defined Job resources are:
1: RestoreFiles
2: backup-test-on-bareos-fd
3: BackupCatalog
4: backup-bareos-fd
Select Job resource (1-4): 2
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Incremental
Client: bareos-fd
Format: Native
FileSet: TestSet
Pool: Incremental (From Job IncPool override)
Storage: File (From Job resource)
When: 2018-10-05 10:39:59
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: Backup Format
7: When
8: Priority
9: Pool
10: Plugin Options
Select parameter to modify (1-10): 1
Levels:
1: Full
2: Incremental
3: Differential
4: Since
5: VirtualFull
Select level (1-5): 1
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Full
Client: bareos-fd
Format: Native
FileSet: TestSet
Pool: Full (From Job FullPool override)
Storage: File (From Job resource)
When: 2018-10-05 10:39:59
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: Backup Format
7: When
8: Priority
9: Pool
10: Plugin Options
Select parameter to modify (1-10): 5
The defined Client resources are:
1: scm-fd
2: lswin7-1-fd
3: lscms-fd
4: bareos-fd
Select Client (File daemon) resource (1-4): 2
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Full
Client: lswin7-1-fd
Format: Native
FileSet: TestSet
Pool: Full (From Job FullPool override)
Storage: File (From Job resource)
When: 2018-10-05 10:39:59
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: Backup Format
7: When
8: Priority
9: Pool
10: Plugin Options
Select parameter to modify (1-10): 4
The defined FileSet resources are:
1: Windows Test Fileset
2: Windows All Drives
3: TestSet
4: SelfTest
5: LinuxAll
6: Catalog
Select FileSet resource (1-6): 1
Run Backup job
JobName: backup-test-on-bareos-fd
Level: Full
Client: lswin7-1-fd
Format: Native
FileSet: Windows Test Fileset
Pool: Full (From Job FullPool override)
Storage: File (From Job resource)
When: 2018-10-05 10:39:59
Priority: 10
OK to run? (yes/mod/no):
Job queued. JobId=19
You have messages.
*messages
05-Oct 10:18 bareos-dir JobId 19: Start Backup JobId 18, Job=backup-test-on-bareos-fd.2018-10-05_10.18.57_06
05-Oct 10:18 bareos-dir JobId 19: Using Device "FileStorage" to write.
05-Oct 10:18 bareos-sd JobId 19: Volume "Full-0001" previously written, moving to end of data.
05-Oct 10:18 bareos-sd JobId 19: Ready to append to end of Volume "Full-0001" size=126308232
05-Oct 10:18 lswin7-1-fd JobId 19: Created 28 wildcard excludes from FilesNotToBackup Registry key
05-Oct 10:19 lswin7-1-fd JobId 19: Generate VSS snapshots. Driver="Win64 VSS", Drive(s)="C"
05-Oct 10:19 lswin7-1-fd JobId 19: VolumeMountpoints are not processed as onefs = yes.
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "Task Scheduler Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "VSS Metadata Store Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "Performance Counters Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "System Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "ASR Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "Registry Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "Shadow Copy Optimization Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "BITS Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "COM+ REGDB Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "WMI Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 lswin7-1-fd JobId 19: VSS Writer (BackupComplete): "MSSearch Service Writer", State: 0x1 (VSS_WS_STABLE)
05-Oct 10:19 bareos-sd JobId 19: Elapsed time=00:00:18, Transfer rate=2.182 M Bytes/second
05-Oct 10:19 bareos-dir JobId 19: sql_create.c:872 Insert of attributes batch table done
05-Oct 10:19 bareos-dir JobId 19: Bareos bareos-dir 17.2.4 (21Sep17):
Build OS: x86_64-pc-linux-gnu debian Debian GNU/Linux 9.3 (stretch)
JobId: 19
Job: backup-test-on-bareos-fd.2018-10-05_10.18.57_06
Backup Level: Full
Client: "lswin7-1-fd" 17.2.4 (21Sep17) Microsoft Windows 7 Ultimate Edition Service Pack 1 (build 7601), 64-bit,Cross-compile,Win64
FileSet: "Windows Test Fileset" 2018-10-05 10:18:57
Pool: "Full" (From command line)
Catalog: "MyCatalog" (From Client resource)
Storage: "File" (From Job resource)
Scheduled time: 05-Oct-2018 10:18:57
Start time: 05-Oct-2018 10:18:59
End time: 05-Oct-2018 10:19:17
Elapsed time: 18 secs
Priority: 10
FD Files Written: 6
SD Files Written: 6
FD Bytes Written: 39,284,012 (39.28 MB)
SD Bytes Written: 39,285,181 (39.28 MB)
Rate: 2182.4 KB/s
Software Compression: None
VSS: yes
Encryption: no
Accurate: no
Volume name(s): Full-0001
Volume Session Id: 2
Volume Session Time: 1538702289
Last Volume Bytes: 165,623,141 (165.6 MB)
Non-fatal FD errors: 0
SD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Backup OK
*
備份Windows電腦已成功備份。
最基本的Bareos系統配置已全部完成。Bareos是一個完整的企業級備份恢復系統,上述介紹的只是最簡單的配置,詳細配置請參閱Bareos文件。
下文我們將介紹Bareos-WebUI。