bacula網路備份軟體的安裝以及配置
最近在網上看到有一個強大的網路備份軟體bacula,於是就找了一些資料來看,發現網上的資料寥寥無幾啊,我看了論壇好像也沒有相關的文章,網上講的也不是很詳細很多東西含含糊糊的,看的人頭疼,憑著自己的理解就在本地環境下面進行了測試,最後終於實現了網路的備份以及還原功能,最終整理了此文檔,一些比較重要的地方都做相應的解釋,希望此文章可以幫助那些正在安裝或者有興趣安裝的朋友。
簡介: Bacula,被譽為開源軟體中最好的備份還原軟體,它提供了企業級的客戶機/伺服器的備份解決方案,能夠通過網路來管理文件的備份,恢復和核實工作.既有windows版本的,也有Linux,Unix的.
關於bacula的組建介紹:
Directory:管理所有備份,恢復,驗證,和存檔事務,定製備份和恢復文件的計劃.
Storge:指定進行存儲和恢復文件屬性和數據的物理備份媒介.
File:安裝在被備份機器上的程序,將被directory調用時候,它提供關於自己的操作系統、文件屬性、數據等資料.
Console:與directory進行通訊.
Catalog:負責維護所有備份文件的索引和資料庫.
Monitor:監控directory、file、storage的守護進程.
試驗環境:
使用2台伺服器來做這個網路備份的測試環境,環境如下:
10.10.2.226 作為directory、storage、catalog.
10.10.2.162 作為file.
關於bacula的結構圖:
http://i.namipan.com/files/6a94addbfdabd6a8036c20714ed1466a0f28f132e92500005e02/0/1.jpg
一. Bacula在server上的安裝以及配置
bacula的安裝不是很複雜,我這裡安裝的是bacula的2.4.3版本的.
#tar zxvf bacula-2.4.3.tar.gz
#./configure --with-mysql
#make&&make intall
默認情況下,bacula的安裝路徑為/etc/bacula.
2.創建mysql腳本
#./grant_mysql_privileges
#./ create_mysql_database
#./ make_mysql_tables
3.bacula的配置
在這裡說明下,bacula的主要配置都在directory這個配置文件裡面的,這個算是一個核心文件了,一定要搞清楚裡面配置文件的配置項都代表什麼意思,否則很難配置成功.
#####################################################################
directory端的配置:
#more bacula-dir.conf
//directory的全局配置
Director {
Name = linux-0fdr-dir
DirAddress=10.10.226 //這裡是directory端的ip
DIRport = 9101 //這裡是directory端的進程號
QueryFile = "/etc/bacula/query.sql"
WorkingDirectory = "/var/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 1
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7" //這裡要與bconsole.conf配置文件里的passwor一致
Messages = Daemon
}
//directory的job配置
Job {
Name =dbjob //job的名字,這個可以隨便起,在後面的備份操作的時候可以看到
Client=dbfd //這裡要和後面的client的name名字要一樣
Type=backup //可用類型有backup,restore,verify,admin
FileSet=dbfs //這個要和後面的fileset的name名字要一樣
Messages=Daemon //這個要與後面的message的name名字要一樣
Pool=dbpool //這個要與後面的pool的name名字要一樣
Storage=dbsd //這個要與後面的storage的name名字要一樣
Write Bootstrap = "/var/bacula/working/Client1.bsr"
Level=Full //這裡是備份類型,可用的值是FULL(完全備份),incremental(增量備份),differential(差異備份)
schedule=dbscd //這裡要與後面的schedule的name名字要一樣
}
//directory的還原job配置
job{
Name=restrory
Client=dbfd
Type=Restore
FileSet=dbfs
Messages=Daemon
Pool=dbpool
Storage=dbsd
Write Bootstrap = "/var/bacula/working/Client1.bsr"
Where =/home/bacula/ //還原的路徑
}
FileSet {
Name =dbfs //這個名字是應用到job裡面的
Include{
Options {
Compression=GZIP //對備份文件進行gzip的壓縮
signature = MD5 //驗證方式為MD5碼的方式
Sparse=yes
}
File =/home/mysql_packup //需要備份的目錄
}
Exclude { // 排除的,不備份的內容
File = /proc //不備份/proce
File = /tmp
File = /.journal
File = /.fsck
}
}
Client {
Name = dbfd //這裡要與FD配置文件的name相同,並且應用在job裡面的
Address = 10.10.2.162 //要備份的客戶機IP
FDPort = 9102
Catalog = dbcatalog //記錄客戶機備份情況的日誌名,後面會定義
Password = "Nd+Yuqe+Kd5wBc1S9uMTEGTNqNIe1cupnfuOdwboej6Z" //與FD的密碼一致
File Retention = 30 days //保存在資料庫目錄多久輪詢一次,這裡是30天
Job Retention = 6 months //job保持周期,大於FRetention
AutoPrune = yes //當FR/JR周期滿了是否執行自動刪除它們在資料庫的目錄
#priority =1 //如果多個client時,定義優先順序1-1000,值越小越優先
}
Storage {
Name =dbsd //必須與SD配置文件的name相同,這個應用到了job裡面
Address = 10.10.2.226 //安裝sd服務的伺服器IP
SDPort = 9103
Password = "5jipKA7pekDel6BUjgIwD3LkPPBgxcecbLpLfl9puj0c" //要與SD的password一樣
Device =dbdev //要與SD配置文件的device的name相同
Media Type = File //要與SD配置文件device的Media Type相同
}
Pool {
Name =dbpool //這個應用到了job裡面
Pool Type=backup
Maximum Volume Jobs = 1
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
}
Schedule { //定時任務
Name =dbscd //這個應用到了job裡面
Run = Full 1st sun at 23:05
Run = Differential 2nd-5th sun at 23:05
Run = Incremental mon-sat at 23:05
}
Catalog {
Name =dbcatalog //這個應用到了job裡面
dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
DB Address=10.10.2.226 //不要用localhost,資料庫所在的IP
DB Port=3306
}
Messages {
Name = Daemon //這個應用到了job裡面
mailcommand = "/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/var/bacula/working/log" = all, !skipped
}
Console {
Name = linux-0fdr-mon
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
CommandACL = status, .status
}
#####################################################################
SD配置:
Storage {
Name =dbsd //這裡要與director配置文件的storage的name一樣
SDAddress=10.10.2.226 //這裡是SD的IP
SDPort = 9103
WorkingDirectory = "/var/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20 //job的最大連接數
}
Director {
Name =linux-0fdr-dir //這裡要與directory的name相同
Password = "5jipKA7pekDel6BUjgIwD3LkPPBgxcecbLpLfl9puj0c " //這裡與directory中storage的password相同
}
Director { //這個是做監控的配置
Name = linux-0fdr-dir
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
Monitor = yes
Device {
Name =dbdev //這裡要與directory中storage的device一樣
Media Type = File //這裡要與diretory中storage的Media Type相同
Archive Device =/home/bakcup/ //備份的路徑
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}
Messages {
Name = Standard
director = linux-0fdr-dir = all
}
##################################################################
console端的配置:
Director {
Name = linux-0fdr-dir //這裡要與directory的name相同
DIRport = 9101
address = 10.10.2.226 //console端的IP
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
//這個密碼要與directory的password一樣
}
4.啟動bacula的進程
在server端,只啟動directory和storage的進程,啟動命令如下:
#./bacula-ctl-dir start
#./bacula-ctl-sd start
啟動之後,要給bacula添加存儲介質,
linux-0fdr:/etc/bacula # ./bconsole
Connecting to Director 10.10.2.226:9101
1000 OK: linux-0fdr-dir Version: 2.4.3 (10 October 2008)
Enter a period to cancel a command.
*label
Automatically selected Catalog: dbcatalog
Using Catalog "dbcatalog"
Automatically selected Storage: dbsd
Enter new Volume name: woyun //這裡隨便給他起個卷名
Automatically selected Pool: dbpool
Connecting to Storage daemon dbsd at 10.10.2.226:9103 ...
Sending label command for Volume "test" Slot 0 ...
3000 OK label. VolBytes=188 DVD=0 Volume="test" Device="dbdev" (/home/bakcup/)
Catalog record for Volume "test", Slot 0 successfully created.
Requesting to mount dbdev ...
3906 File device "dbdev" (/home/bakcup/) is always mounted.
You have messages.
注意:藍色字的為要輸入的內容.
[ 本帖最後由 wiliiwin 於 2009-8-26 10:40 編輯 ]
《解決方案》
回復 #1 wiliiwin 的帖子
由於文章太長,只能分2部分了
二. bacula在client伺服器上的安裝和配置
1.安裝bacula
#tar zxvf bacula-2.4.3.tar.gz
# cd bacula-2.4.3
#./configure --enable-client-only
#make&&make install
默認安裝在/etc/bacula/目錄下
2.bacula的配置
#more bacula-fd.conf
#####################################################################
FD配置:
Director
Name = linux-0fdr-dir //這裡要與directory的name相同
Password = "Nd+Yuqe+Kd5wBc1S9uMTEGTNqNIe1cupnfuOdwboej6Z" //這裡與directory中client的password相同
}
Director { //這個是做監控的配置
Name = linux-0fdr-mon
Password = "MJ8SyFywMm+4ntJf2EupggRWIWE6LozmLfIKC8J9nYt7"
Monitor = yes
}
FileDaemon {
Name = dbfd //這裡要與diretory的 job里的client相同
FDport = 9102
FDAddress=10.10.2.162 //被備份伺服器的IP
WorkingDirectory = /var/bacula/working
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
}
3.啟動bacula的fd進程
#bacula-ctl-fd start
三.備份以及還原過程.
經過艱辛萬苦終於走到了這一步,不容易啊,好現在備份下10.10.2.162的/home/bacula這個目錄,操作如下:
#./bconsole
Connecting to Director 10.10.2.226:9101
1000 OK: linux-0fdr-dir Version: 2.4.3 (10 October 2008)
Enter a period to cancel a command.
*run
Automatically selected Catalog: dbcatalog
Using Catalog "dbcatalog"
A job name must be specified.
The defined Job resources are:
1: dbjob
2: restrory
Select Job resource (1-2): 1
Run Backup job
JobName: dbjob
Level: Full
Client: dbfd
FileSet: dbfs
Pool: dbpool (From Job resource)
Storage: dbsd (From Job resource)
When: 2009-08-25 15:23:14
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=54
*list jobs
54 | dbjob | 2009-08-25 15:23:18 | B | F | 0 | 0 | R | //這裡會出現一個列表,我當前只複製最新的一個JOBID,這裡注意紅色的R表示已經在運行了,要是E或者C就是有問題了,要是T就表示複製完成了.
*status
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3
Automatically selected Client: dbfd
Connecting to Client dbfd at 10.10.2.162:9102
……………………………………………………… //這裡省略一部分輸出信息
54 Full 1,628 9.773 M OK 25- 8?009 15:27 dbjob
//看到這裡已經顯示OK了,表示備份成功
現在去看看備份路徑下面是否生成了備份文件
# du -sh *
9.7M woyun
可以看到這個卷有9.4M的大小了,原來是4K的文件,再次證明了備份成功了.
下面做還原的操作,我們把client端的被備份目錄下面文件進行刪除
# rm -rf *
# ls
然後我們到directory端進行還原
# ./bconsole
Connecting to Director 10.10.2.226:9101
1000 OK: linux-0fdr-dir Version: 2.4.3 (10 October 2008)
Enter a period to cancel a command.
*restore
Automatically selected Catalog: dbcatalog
Using Catalog "dbcatalog"
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: Cancel
Select item: (1-12): 5
Automatically selected Client: dbfd
Automatically selected FileSet: dbfs
+-------+-------+----------+-----------+---------------------+------------+
| JobId | Level | JobFiles | JobBytes | StartTime | VolumeName |
+-------+-------+----------+-----------+---------------------+------------+
| 54 | F | 1,628 | 9,773,751 | 2009-08-25 15:23:18 | woyun |
+-------+-------+----------+-----------+---------------------+------------+
You have selected the following JobId: 54
Building directory tree for JobId 54 ... +++++++++++++++++++++++++++++++++++++++++++++++++
1 Job, 1,621 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 home
1,628 files marked.
$ done
Bootstrap records written to /var/bacula/working/linux-0fdr-dir.restore.1.bsr
The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================
woyun dbsd dbdev
1,628 files selected to be restored.
Run Restore job
JobName: restrory
Bootstrap: /var/bacula/working/linux-0fdr-dir.restore.1.bsr
Where: /home/bacula/
Replace: always
FileSet: dbfs
Backup Client: dbfd
Restore Client: dbfd
Storage: dbsd
When: 2009-08-25 16:09:03
Catalog: dbcatalog
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Restore Client
6: When
7: Priority
8: Bootstrap
9: Where
10: File Relocation
11: Replace
12: JobId
Select parameter to modify (1-12): 9
Please enter path prefix for restore (/ for none): /home/bacula
Run Restore job
JobName: restrory
Bootstrap: /var/bacula/working/linux-0fdr-dir.restore.1.bsr
Where: /home/bacula
Replace: always
FileSet: dbfs
Backup Client: dbfd
Restore Client: dbfd
Storage: dbsd
When: 2009-08-25 16:09:03
Catalog: dbcatalog
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=55
*exit
OK還原完成,我們現在到client端看看有什麼還原回來
# ls
bacula-2.4.3 bacula-2.4.3.tar.gz
看到了已經還原回來了,說明我們的還原操作已經實現了
文章源地址:http://blog.chinaunix.net/u2/75613/showart_2036786.html
[ 本帖最後由 wiliiwin 於 2009-8-26 10:42 編輯 ]
《解決方案》
:shock: :shock: 只有人看沒有人回復 難道對我寫的文章不屑一顧
《解決方案》
非常不錯啊。!
《解決方案》
謝謝版主的支持 我很傷心 居然辛辛苦苦寫的文章 用了將近1,2個小時編輯的文章 居然沒有人回帖 只有看的沒有回的
《解決方案》
支持下~最近也在給小規模應用弄這個
《解決方案》
謝謝lz的無私貢獻。正在學習這個備份軟體。
《解決方案》
現在CU的學習風氣沒有以前濃了,連清茶也不清了:em17:
《解決方案》
感謝樓主~~幫助十分大.
《解決方案》
各位大俠好,我在AIX 5.3上編譯安裝 bacula-5.0.3.tar.gz,步驟如下:
export CFLAGS="-g -O2 -Wall -I/usr/local/mysql/include"
export CC=gcc
export CXX=g++
當帶libtool編譯的時候,報Segmentation fault (core dumped)
一:./configure --prefix=/home/mysql/forsetup/bacula-5.0.3 --with-libiconv-prefix=/home/mysql/forsetup/libiconv1.13.1 --with-libintl-prefix=/home/mysql/forsetup/gettext0.17 --sbindir=/home/mysql/forsetup/bacula-5.0.3/sbin --sysconfdir=/etc/bacula --with-readline=/home/mysql/forsetup/readline-5.2 --with-scriptdir=/etc/bacula --enable-smartalloc --with-mysql=/usr/local/mysql --with-working-dir=/var/bacula --with-pid-dir=/var/run
二:make
三:make install
安裝完成後執行/home/mysql/forsetup/bacula-5.0.3/sbin下的那些二進位文件(例如bconsole,bacula-dir)等,報Segmentation fault (core dumped)
當不帶libtool(--disable-libtool)編譯的時候,報錯如下:
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
ld: 0711-317 ERROR: Undefined symbol: .mysql_field_seek
ld: 0711-317 ERROR: Undefined symbol: .mysql_num_fields
ld: 0711-317 ERROR: Undefined symbol: .mysql_fetch_field
ld: 0711-317 ERROR: Undefined symbol: .mysql_num_rows
ld: 0711-317 ERROR: Undefined symbol: .mysql_fetch_row
ld: 0711-317 ERROR: Undefined symbol: .mysql_insert_id
ld: 0711-317 ERROR: Undefined symbol: .mysql_error
ld: 0711-317 ERROR: Undefined symbol: .mysql_data_seek
ld: 0711-317 ERROR: Undefined symbol: .mysql_affected_rows
ld: 0711-317 ERROR: Undefined symbol: .mysql_query
ld: 0711-317 ERROR: Undefined symbol: .mysql_store_result
ld: 0711-317 ERROR: Undefined symbol: .mysql_free_result
ld: 0711-317 ERROR: Undefined symbol: .mysql_use_result
ld: 0711-317 ERROR: Undefined symbol: .mysql_real_escape_string
ld: 0711-317 ERROR: Undefined symbol: .my_thread_end
ld: 0711-317 ERROR: Undefined symbol: .mysql_close
ld: 0711-317 ERROR: Undefined symbol: .mysql_init
ld: 0711-317 ERROR: Undefined symbol: .mysql_real_connect
ld: 0711-317 ERROR: Undefined symbol: .mysql_errno
ld: 0711-317 ERROR: Undefined symbol: .mysql_sqlstate
請問各位有沒有解決的辦法,萬分感謝