Installing Bacula
Several network backup topologies for 1 Bacula
The previous article describes the Bacula has 5 components, in the actual application, there is no need to put 5 parts on different servers, some parts of them can be merged, the common Bacula deployment structure is as follows:
Director and SD and console on one machine, while client FD on another machine, of course, client FD can have one or more platforms. Director and console on a single machine, SD on a machine, client FD on one or more platforms. The Director and client FD, SD, and console are all on one machine, that is, the server backs itself up and the data is stored natively.
2 Compiling and installing Bacula
Here is an introduction to the first Bacula deployment structure in the previous section. The environment is shown in table 4-1.
Table 11 environments for BACULA deployment structures
Host name IP address operating system CentOS release 5.4 Director, SD, consolebaculaclient 192.168.12.189 CentOS Release 5.4 FD
The entire topology structure:
Figure 1 Topology of the Bacula instance
Install Bacula on the Bacula server side
First in http://www.bacula.org download the corresponding source code, here download is bacula-5.0.1. tar.gz, then compile the installation, the installation process is as follows:
CD bacula-5.0.1#./configure--prefix=/opt/bacula--with-make# make install
Bacula needs the support of the database, which uses the MySQL database, and assumes that MySQL is already installed on the Bacula server, and that the MySQL installation path is/opt/mysql (Bacula at compile time through "--with-mysql" option specifies the installation path for the MySQL database). After the Bacula installation is complete, all profiles are placed by default in the/opt/bacula/etc/directory.
Install Bacula on the Bacula client
Because the Bacula client is simply a client that needs to be backed up, it is only necessary to install the appropriate client components, as follows:
# tar zxvf bacula-5.0.1.tar.gz# cd bacula-5.0.1#./configure--prefix=/opt/bacula--enable-client-only# make# make in Stall
3 Initializing the MySQL database
After installing Bacula on Baculaserver, you also need to create bacula corresponding MySQL database and authorization to access the database, fortunately Bacula has prepared such a script for the user, and then just execute the following script on the Bacula server side.
#cd/opt/bacula/etc#/grant_mysql_privileges#./create_mysql_databasecreation of Bacula database succeeded.#./make_ Mysql_tablescreation of Bacula MySQL tables succeeded.
You can then log in to the MySQL database to see if the Bacula database and data tables have been established. When executing the above three lines of MySQL initial code, the default is performed by the root user of the empty password, so make sure that the MySQL database root password is empty.
Configuring the Bacula Backup system
In fact, the director-side profile bacula-dir.conf, SD configuration file bacula-sd.conf, The client FD Profile bacula-fd.conf and the console configuration file bconsole.conf the process of configuration. Depending on the installation deployment above, the director side, SD, The console side is centered on one server Baculaserver (that is, 192.168.12.188) and the client FD is deployed on the baculaclient (i.e. 192.168.12.189) server, which details the configuration process.
1 Configuring the console side of the Bacula
The configuration file on the console side is bconsole.conf, the configuration file is simple and the following files are configured:
Director {Name = F10-64-build-dir #控制端名称, bacula-dir.conf and bacula-sd.conf below#控制端服务端口address = 192.168.12.188 #控制端服务器IP地址Password = "oudao0sgxx/f+tx4yygkk4so0l/ieqgjikq5dmstqh6t"#控制端密码文件}
2 Configuring the director side of the Bacula
Bacula-dir.conf is the director side of the configuration file, is also the core configuration file of Bacula, this file is very complex, divided into 10 logical segments, respectively:
- Director, defining Global settings
- Catalog, defining the background database
- Jobdefs, defining Default execution Tasks
- Job, customizing a backup or recovery task
- Fileset, define what data is backed up, what data is not backed up
- Schedule, defining the backup time policy
- Pool, defining pools properties for job use
- Client, define the host address to be backed up
- Storage, defining how data is stored
- Messages, defining where to send log reports and log logs
Listing 1 is a well-configured file, where the "#" is followed by a comment.
Code Listing 1 The configuration file for the director side that is already set up
Director {#定义bacula的全局配置Name = F10-64-build-dirdirport = 9101#定义Director的监听端口QueryFile = "/opt/bacula/etc/query.sql" workingdirectory = "/opt/bacula/var/bacula/working" Piddirectory = "/var/run" Maximum ConcurrentJobs = 1#定义一次能处理的最大并发数#验证密码, this password must be the same as the corresponding director logic segment password in the bconsole.conf file password = "oudao0sgxx/f+tx4yygkk4so0l/ieqgjikq5dmstqh6t"#定义日志输出方式, "Daemon" is defined in the following messages logical segment messages = Daemon}job {#自定义一个备份任务Name = "Client1"#备份任务名称Client = DBFD#指定要备份的客户端主机, "DBFD" in the later client logic segmentTo define level = Incremental#定义备份的级别, incremental is an incremental backup. The level value # can be full (fully backed up), Incremental (incremental backup), and differential (differential backup), and if the first # does not make a full backup, a full backup is performed before the IncrementalType = Backup#定义Job的类型, "Backup" is a back up task, optionalThe type also hasFileset = dBFS for restore and verify#指定要备份的客户端数据, "dBFS" in the back FilesetDefined in a logical segment schedule = DBSCD#指定这个备份任务的执行时间策略, "DBSCD" indefined in the following schedule logical segment storage = Dbsd#指定备份数据的存储路径与介质, "Dbsd" in the rearThe storage logical segment of the polygon is defined messages = Standardpool = Dbpool#指定备份使用的pool属性, "Dbpool" in the back of theDefined in the pool logical segment.Write Bootstrap = "/OPT/BACULA/VAR/BACULA/WORKING/CLIENT2.BSR"#指定备份的引导信息路径}job {#定义一个名为Client的差异备份的任务Name = "Client" Type = Backupfileset = Dbfsschedule = Dbscdstorage = Dbsdmessages = Standardpool = DBP Oolclient = Dbfdlevel = Differential#指定备份级别为差异备份Write Bootstrap = "/OPT/BACULA/VAR/BACULA/WORKING/CLIENT1.BSR"}job {#定义一个名为BackupCatalog的完全备份任务Name = "Backupcatalog" Type = Backuplevel = Full#指定备份级别为完全备份Client = dbfdfileset= "dBFS" Schedule = "dbscd" Pool = Dbpoolstorage = Dbsdmessages = Standardrunbeforejob = "/op T/bacula/etc/make_catalog_backup Bacula bacula "runafterjob ="/opt/bacula/etc/delete_catalog_backup "Write Bootstrap = "/OPT/VAR/BACULA/WORKING/BACKUPCATALOG.BSR"}job {#定义一个还原任务Name = "Restorefiles" Type = Restore#定义Job的类型为 "Restore", that is, recover data Client=dbfdfileset=dbfsstorage = Dbsdpool = Dbpoolmessages = Standardwhere =/tmp/ Bacula-restores#指定默认恢复数据到这个路径}fileset {#定义一个名为dbfs的备份资源, that is, specify which data needs to be backed up and which to excludeData, you can specify multiple Filesetname = dbfsinclude {Options {signature = MD5; compression=Gzip }#表示使用MD5签名并压缩File =/cws3#指定客户端FD需要备份的文件目录}exclude {#通过Exclude排除不需要备份的文件或者目录, the file =/opt/bacula/var/bacula/workingfile =/tmpfile =/procfile =/tmpfile =/is modified as appropriate. Journalfile =/.Fsck}}schedule {#定义一个名为dbscd的备份任务调度策略Name = Dbscdrun = Full 1st SunAt 23:05#第一周的周日晚23:05 points for full backup run = Differential 2nd-5th Sun at 23:05Differential backup for #第2-week Sunday 23:05 run = Incremental Mon-sat at 23:05#所有周一至周六晚23:05 points for incremental backup}fileset {Name = "Catalog" Include {Options {signature = Md5}file =/opt/bacula/var/bacula/working/ bacula.sql}}client {#Client用来定义备份哪个客户端FD的数据Name = DBFD#Clinet的名称, you can call address = 192.168.12.189 in the previous job#要备份的客户端FD主机的IP地址FDPort = 9102#与客户端FD通信的端口Catalog = MyCatalog#使用哪个数据库存储信息, "MyCatalog" is in the back.Defined in the MyCatalog logical segment password = "oudao0sgxx/f+tx4yygkk4so0l/ieqgjikq5dmstqh6t"#Director端与客户端FD的验证密码, this value must be the same as the password in the client FD profile bacula-fd.conf file Retention =#指定保存在数据库中的记录多久循环一次, here is 30 days, only affects the records in the database does not affect the backup of the file job Retention = 6 months#指定Job的保持周期, should be greater than the value specified by file retention Autoprune =Yes#当达到指定的保持周期时, whether the records in the database are automatically deleted,Yes means automatic purge of expired job}client {Name = dbfd1address = 192.168.12.188FDPort = 9102Catalog = Mycatalogpassword = "wr8lj3q51pgz21u2f Satxicyhlmqkt1xhhbm8a6/j8bz "File Retention = daysjob Retention = 6 Monthsautoprune = yes}storage {# storage is used to define which storage device the client's data is backed up to, name = Dbsdaddress = 192.168.12.188#指定存储端SD的IP地址SDPort = 9103#指定存储端SD通信的端口Password = "oudao0sgxx/f+tx4yygkk4so0l/ieqgjikq5dmstqh6t"#Director端与存储端SD authentication password, this value must be the same as the director logic segment password in the storage-side SD configuration file bacula-sd.conf device = Dbdev#指定数据备份的存储介质, must be with the storage side (here is 192.168.12.188)The "name" entry for the "Device" logical segment in the bacula-sd.conf configuration file has the same name as media Type = File#指定存储介质的类别, must be with the storage-side SD (here is 192.168.12.188)The "Device" logical segment in the bacula-sd.conf configuration file has the same name as the "Media Type" item}catalog {# The Catalog Logic section is used to define the log and database settings for name = Mycatalogdbname = "Bacula"; Dbuser = "Bacula"; Dbpassword = ""#指定库名, user name, and password}messages {# Messages Logic section is used to set the director side how to save the log, as well as the log save format, you can send the log information to the administrator mailbox, if you must openSendMail service name = Standardmailcommand = "/usr/sbin/bsmtp-h localhost-f \" \ (bacula\) \<%r\>\ "-s \" Bacula:%t%e of %c%l\ "%r" Operatorcommand = "/usr/sbin/bsmtp-h localhost-f \" \ (bacula\) \<%r\>\ "-s \" Bacula:intervention needed For%j\ "%r"mail = [email protected] = all,!skippedoperator = [email protected] =Mountconsole = All,!skipped,!savedappend = '/opt/bacula/log/bacula.log ' = all,!skipped#定义bacula的运行日志append = "/opt/bacula/log/bacula.err.log" = error,warning, Fatal#定义bacula的错误日志catalog = all}messages {#定义了一个名为Daemon的Messages逻辑段, "Daemon" has been previously referenced by name = Daemonmailcommand = "/usr/sbin/bsmtp-h localhost-f \" \ (bacula\) \ <%r\>\ "-s \" Bacula daemon message\ "%r" mail = [email protected] = all,!skippedconsole = All,!skipped,!saved Append = "/opt/bacula/log/bacula_demo.log" = All,!skipped}pool {#定义供Job任务使用的池属性信息, for example, setting the expiration time of a backup file, overwriting expired backup data, automatically purging expired backups, and so on name = Dbpoolpool Type = backuprecycle = yes # Re-use Autoprune = yes #表示自动清除过期备份文件Volume Retention = 7 days #指定备份文件保留的时间Label Format = "db-${year}-${month:p/2/0/r}-${ Day:p/2/0/r}-id${jobid} " #设定备份文件的命名格式, this format will produce the named file: Db-2010-04-18-id139maximum Volumes = 7 # Set the maximum number of backup files to save recycle current Volume = yes #表示可以使用最近过期的备份文件来存储新备份Maximum Volume Jobs = 1 #表示每次执行备份任务创建一个备份文件} Console { #限定Console利用tray-monitor get status information for director name = F10-64-build-monpassword = " Rsqy3srjak3ktz8hr07gc728vkzhbr0qcjoc5x3pxeap "Commandacl = status,. Status}
3 Configuring the Bacula SD
The SD can be a separate server, or it can be on a single machine with director, this example puts the SD and director side together for configuration. The configuration file for SD is bacula-sd.conf, and listing 2 is an already configured bacula-sd.conf file.
Code Listing 2 configuration of the bacula-sd.conf file
Storage {#定义存储, in this case f10-64-build-sdname = F10-64-BUILD-SD#定义存储名称SDPort = 9103#监听端口WorkingDirectory = "/opt/bacula/var/bacula/working" Pid Directory = "/var/run" Maximum Concurrent Jobs = 20}director {#定义一个控制StorageDaemon的DirectorName = F10-64-build-dir#这里的 the "name" value must be the same as the director logical segment name in the director-side profile bacula-dir.conf Password = "oudao0sgxx/f+tx4yygkk4so0l/ IEQGJIKQ5DMSTQH6T "The #这里的 "Password" value must be the same as the storage logical segment password in the Director-side configuration file bacula-dir.conf}director {#定义一个监控端的DirectorName = F10-64-build-mon#这里的 the "name" value must be the same as the console logical segment name in the director-side profile bacula-dir.conf Password = " Rsqy3srjak3ktz8hr07gc728vkzhbr0qcjoc5x3pxeap "#这里的 "Password" value must be the same as the console logic segment password in the Director-side profile bacula-dir.conf monitor = Yes}device {#定义DeviceName = Dbdev #定义Device的名称, this name is referenced in the storage logical segment device item in the Director-side configuration file bacula-dir.conf Media Type = File #指定存储介质的类型, file means using the filesystem storage Archive device =/webdata #Archive device used to designate the backup storage media, which can be CD, DVD, tap, etc., this is the file to save the backup WebData directory under Labelmedia = yes; #通过Label命令来建立卷文件Random Access = yes; #设置是否采用随机访问存储介质, here choose Yesautomaticmount = yes; #表示当存储设备打开时, whether it is used automatically, this choice yesremovablemedia = no; #是否支持可移动的设备, such as tap or CD, select Noalwaysopen = no; #是否确保tap设备总是可用, no tap device is used, so set to No} Messages { #为存储端SD定义一个日志或消息处理机制Name = Standarddirector = F10-64-build-dir = all}
4 Configuring the FD side of the Bacula
The
Client FD runs on a separate server, in this case the Baculaclient host (that is, 192.168.12.189), and its configuration file is bacula-fd.conf, and the configured files are as follows:
Director { #定义一个允许连接FD的控制端Name = F10-64-build-dir #这里的" Password "value must be the same as the client logical segment password in the Director-side profile bacula-dir.conf} Director { #定义一个允许连接FD的监控端Name = F10-64-build-monpassword = " Rsqy3srjak3ktz8hr07gc728vkzhbr0qcjoc5x3pxeap "Monitor = yes}filedaemon { #定义一个FD端Name = Localhost.localdomain-fdfdport = 9102 #监控端口WorkingDirectory =/opt/bacula/var/bacula /workingpid Directory =/var/runmaximum Concurrent Jobs = #定义一次能处理的并发作业数}messages { Span style= "color: #006400;" > #定义一个用于FD端的MessagesName = Standarddirector = Localhost.localdomain-dir = All,!skipped,!restored}
Start Bacula's director daemon and storage daemon
Once you have completed the above configuration, you can start or close bacula. Starting or shutting down all services on the control side on the Baculaserver, as in the next two ways.
The first way is as follows:
[[email protected] etc]#/opt/bacula/sbin/bacula{start|stop|restart|status}
You can also start or close each service in turn by managing each of the Bacula configuration ends separately:
[Email protected] etc]#/opt/bacula/etc/bacula-ctl-dir {start|stop|restart|status}[[email protected] etc]#/opt/ BACULA/ETC/BACULA-CTL-SD {start|stop|restart|status}[[email protected] etc]#/OPT/BACULA/ETC/BACULA-CTL-FD {start| Stop|restart|status}
Because the client FD is configured on another host baculaclient, you do not need to start the File Daemon service on Baculaserver. After starting all the services of Bacula, observe the boot port situation through the netstat command:
[Email protected] etc]# Netstat-antl | grep 91tcp 0 0 0.0.0.0:9101 0.0.0.0:* listentcp 0 0 0.0.0.0:9102 0.0.0.0:* listentcp 0 0 0.0.0.0:9103 0.0.0.0:* LISTEN
Of these, 9101 represents director daemon;9102 representing the file daemon;9103 on behalf of storage daemon. Note Before starting all services for Bacula, you must start the MySQL database, and if the MySQL database does not start, the connection to the Bacula control side will be error:
[Email protected] opt]#/opt/bacula/sbin/bconsoleconnecting to Director 192.168.12.188:910119-04 month 09:45 bconsole JobId 0:fatal error:bsock.c:135 Unable to connect to Director daemon on 192.168.12.188:9101. Err= Deny connection
At this point, execute the netstat command to discover that port 9101 is not booting at all.
Start file daemon on client FD
Finally, start the File Daemon service on the client FD (that is, baculaclient), as follows:
[Email protected] etc]#/opt/bacula/sbin/bacula startstarting the Bacula File daemon
The service for managing client FD can also be done in the following ways:
[Email protected] etc]#/opt/bacula/sbin/bacula {start|stop|restart|status}[[email protected] baculaclient etc]#/opt /BACULA/ETC/BACULA-CTL-FD {Start|stop|restart|status}
Open Source network backup software Bacula installation, configuration, and operation