目的

指导开源备份软件Bacula的安装、配置及应用。

适用范围

适合重要服务器资源的数据备份操作。

定义

服务器端:指备份系统的配置中心和管理控制中心,也包括备份数据的存放位置。

客户端:指需要备份的服务器。

职责

网络工程师:负责该指南的更新、整理。

Bacula简介

Bacula是一款开源的跨平台企业级备份软件。它采用C/S架构,可以实现对数据备份、恢复及校验;支持完全备份、增量备份和差异备份;支持多种操作系统和文件系统(例如windows和linux系统);支持定时备份,无需人工干预;支持终端命令控制,更加灵活;支持正则表达式,可以对备份文件进行更严格的匹配;支持MD5和SHA1签名校验;支持压缩备份和断点续传功能。

Bacula的组成

Bacula主要由以下六部份组成:

Bacula Director:全局设置。负责备份的验证、运行、计划任务、备份和恢复的各种定义和执行操作。配置文件是bacula-dir.conf。以下简称主控端。

Bacula Console:终端管理控制台。通过该控制台连接Bacula Director查看或执行系统的备份、恢复操作。配置文件是bconsole.conf。以下简称console端。

Bacula File:需要备份的机器。安装在需要备份数据的机器上的守护进程,在备份数据时,它负责把文件传出,在恢复数据时负责接收数据并执行恢复操作。配置文件为bacula-fd.conf。以下简称客户端。

Bacula Storage:备份文件的存放介质。负责将数据备份到存储介质上,而在数据恢复时,负责将数据从存储介质中传送出去。其配置文件为bacula-sd.conf。以下简称介质端。

Bacula Monitor:备份进程的监控。显示进程的备份或恢复时的状态信息。以下简称监控端。

Catalog:备份信息元数据。用于记录系统运行的状态信息。

Bacula的恢复流程

通过上图可知,系统的恢复流程如下:

1、通过Console连接到Director端,开始恢复操作。

2、Director端从自己的Catalog中取出备份的记录信息,同时对存储端SD和客户端FD的任务进行协调。

3、客户端FD验证Director的操作许可,验证通过后连接到存储端SD。

4、客户端FD根据Director发出的请求去连接SD,将FD端的数据按恢复要求重新存储到SD端或FD端。

Bacula安装

系统环境

CentOS7最小化安装

主机名

IP地址

系统版本

应用角色

Bacula-test

192.168.17.100

CentOS7

Director、SD、Console


192.168.17.98

Windows10

FD

Bacula-test

192.168.17.100

CentOS7

FD

系统更新

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean
yum makecache
yum update

禁用selinux

vim /etc/selinux/config

下载安装包

wget http://www.bacula.com.br/wp-content/uploads/2016/01/bacula-7.4.0.tar.gz -P /root
tar zxvf bacula-7.4.0.tar.gz

安装相关软件包

yum install gcc-c++ readline-devel zlib-devel lzo-devel libacl-devel mt-st mtx postfix libssl-dev mariadb-devel mariadb-server

编译安装

cd bacula
./configure --disable-conio --bindir=/usr/bin --sbindir=/usr/sbin {color}
--with-scriptdir=/usr/libexec/bacula/ {color}
--with-working-dir=/var/spool/bacula/ {color}
--with-logdir=/var/log --enable-smartalloc --with-mysql {color}
--with-hostname=192.168.17.100 --sysconfdir=/etc/bacula --with-systemd
make
make install
make install-autostart

完成后检查相关文件和目录是否存在。可以参考编译的参数查找对应的文件和目录,如下图所示。

MYSQL数据库配置

数据库MariaDB通过yum的方式安装,版本是5.5.47,以下的数据库设置针对该版本,其它版本的数据库请对照修改。
vim /etc/my.cnf

mysql_secure_installation
mysql -u root -p
create database bacula;
set password for bacula@'%'=password('password'); 
set password for bacula@'localhost'=password('password'); 
grant all privileges on bacula.* to 'bacula'@'%';
grant all privileges on bacula.* to 'bacula'@'localhost';
select user,host,password from mysql.user; 


/usr/libexec/bacula/grant_mysql_privileges -p
/usr/libexec/bacula/create_mysql_database -p
/usr/libexec/bacula/make_mysql_tables -p
use bacula;
show tables;

Bacula配置

Bacula备份的主要配置项目存放在bacula-dir.conf文件中,该文件中的配置项包含以下内容。

  • Jobdefs:默认执行任务
  • Job:自定义一个备份或恢复任务
  • Fileset:定义备份那些数据,不备份那些数据
  • Schedule:定义备份时间策略
  • Pool:定义供Job使用的池属性
  • Client:定义要备份的主机地址
  • Storange:定义数据的存储方式
  • Messages:定义发送日子报告和记录日志的位置


各项目定义的名称会相互关联,如下图所示。

bacula-dir.conf配置

主控端的Director项:

1、Name和Console端Director项的Name一致;

2、Name要和介质端Director项的Name一致;

3、Name要和客户端Director项的Name一致;

4、Password项要和Console端的Password项的密码一致;

主控端的Storage项:

1、Device要和介质端Device项的Name一致;

2、MediaType要和介质端Device项的MediaType一致;

3、Password要和介质端Director项的Pasword一致;

主控端的Client项:

Password要和客户端Director项的Password一致;

vim /etc/bacula/bacula-dir.conf
Director { #全局设置 
  Name = bacula-test-dir #名称要和Console端、SD端、FD端一致
  DIRport = 9101 #启动的端口
  QueryFile = "/usr/libexec/bacula/query.sql"
  WorkingDirectory = "/var/spool/bacula/"
  PidDirectory = "/var/run"
  Maximum Concurrent Jobs = 20 #同时执行的最大任务数量
  Password = "u3R1MUpLlKodHFr4PiqGQMGJfaNfhiXb14ul6xcpBA8d" #密码和Console端一致
  Messages = Daemon
} 

JobDefs { #默认的任务设置
  Name = "DefaultJob" #任务名称
  Type = Backup #任务的类型,有备份、恢复、校验、管理等
  Level = Incremental #增量备份,有差异、全备份
  Client = bacula-test-fd #备份的客户端
  FileSet = "Full Set" #选择客户端需要备份额目录及文件
  Schedule = "WeeklyCycle" #备份周期
  Storage = File1 #存储的方式
  Messages = Standard
  Pool = File
  SpoolAttributes = yes
  Priority = 10
  Write Bootstrap = "/var/spool/bacula/%c.bsr" #将作业记录写入文件
}

Job {
  Name = "Backup-17.98" #定义一个备份任务
  Type = Backup
  Level = Incremental
  Client = bacula-17-98 #需要备份的客户端
  FileSet = "Windows" #需要备份的目录和文件
  Schedule = "WeeklyCycle"
  Storage = File1
  Messages = Standard
  Pool = File
  SpoolAttributes = yes
  Priority = 10
  Write Bootstrap = "/var/spool/bacula/windows%c.bsr"
}

Job {
  Name = "BackupClient1"
  JobDefs = "DefaultJob"
}

Job {
  Name = "BackupCatalog" #定义一个元数据备份任务
  JobDefs = "DefaultJob"
  Level = Full
  FileSet="Catalog"
  Schedule = "WeeklyCycleAfterBackup"
  RunBeforeJob = "/usr/libexec/bacula/make_catalog_backup.pl MyCatalog"
  RunAfterJob = "/usr/libexec/bacula/delete_catalog_backup"
  Write Bootstrap = "/var/spool/bacula/%n.bsr"
  Priority = 11 
}

Job {
  Name = "RestoreFiles" #定义一个恢复任务
  Type = Restore
  Client=bacula-test-fd
  FileSet="Full Set"
  Storage = File1
  Pool = File
  Messages = Standard
  Where = /tmp/bacula-restores
}

FileSet {
  Name = "Full Set" #定义需要备份的目录及文件
  Include {
    Options {
      signature = MD5 #采用MD5
      Compression = GZIP #启用GZIP压缩
      }
    File = /var/lib/mysql #需要备份的目录 
  }
  Exclude { #无需备份的目录和文件
    File = /var/spool/bacula/
    File = /tmp
    File = /proc
    File = /tmp
    File = /sys
    File = /.journal
    File = /.fsck
    }
}

FileSet {
  Name = "Windows" #定义一个新的需要备份的设置
  Include {
    Options {
      signature = MD5
      compression = GZIP
      IgnoreCase = yes
    }
  File = "D:/msdn"
  }
}

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 = "/var/spool/bacula/bacula.sql"
  }
}

Client {
  Name = bacula-test-fd #定义需要备份的客户端
  Address = 192.168.17.100
  FDPort = 9102
  Catalog = MyCatalog
  Password = "nb5dURhiVT3RPsHkFvXetau9LrnL/FhY/ORWkFOTPamT" #密码要和FD端的一致
  File Retention = 30 days #定义文件记录在 Catalog 数据库中的保留时间,不影响已存档的备份文件
  Job Retention = 3 months #定义任务记录在 Catalog 数据库中的保留时间,不影响已存档的备份文件
  AutoPrune = yes #自动修剪
} 

Client {
  Name = bacula-17-98
  Address = 192.168.17.98
  FDPort = 9102
  Catalog = MyCatalog
  Password = "nb5dURhiVT3RPsHkFvXetau9LrnL/FhY/ORWkFOTPamT"
  File Retention = 30 days
  Job Retention = 3 months
  AutoPrune = yes
}

Storage {
  Name = File1
  Address = 192.168.17.100 #存储端的地址
  SDPort = 9103
  Password = "qy5ILHHJNXLCUWGudeC1ke1hPioBo+ye2bUBU5ncxADg"
  Device = FileChgr1 #指定存储的设备。引用存储端配置文件的 Device{}的 Name 值
  Media Type = File1 #与存储端配置文件的 Device{}的 Media Type 值相同
  Maximum Concurrent Jobs = 10 #定义此存储端所允许同时进行的任务最大数量
}

Storage {
  Name = File2
  Address = 192.168.17.100 
  SDPort = 9103
  Password = "qy5ILHHJNXLCUWGudeC1ke1hPioBo+ye2bUBU5ncxADg"
  Device = FileChgr2
  Media Type = File2
  Maximum Concurrent Jobs = 10 
}

Catalog {
  Name = MyCatalog #指定 Catalog{}名称
  dbname = "bacula"; dbuser = "bacula"; dbpassword = "bacula"
}

Messages {
  Name = Standard #定义日志
  append = "/var/log/bacula.log" = all, !skipped
  append = "/var/log/bacula.err.log" = error,warning,fatal
  catalog = all
}

Messages {
  Name = Daemon
  append = "/var/log/bacula.log" = all, !skipped
  append = "/var/log/bacula.err.log" = error,warning,fatal
}

Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes #是否重复使用 Volumes
  AutoPrune = yes #自动清理
  Maximum Volume Jobs = 1
  Volume Retention = 15 days #卷的保留时间
  Maximum Volume Bytes = 5G #Volume容量
  Maximum Volumes = 100 #Volumes数量l
  Label Format = "db-${Year}${Month/2/0/r}${Day/2/0/r}-id${JobId}" #卷命名方式
}

Pool {
  Name = File
  Pool Type = Backup
  Recycle = yes 
  AutoPrune = yes 
  Maximum Volume Jobs = 1
  Volume Retention = 15 days 
  Maximum Volume Bytes = 50G 
  Maximum Volumes = 100 
  Label Format = "db-${Year}${Month/2/0/r}${Day/2/0/r}-id${JobId}"
}

# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}

Console {
  Name = bacula-test-mon
  Password = "fX2cKUkN2RSiLTkeQd5LCPDDw61PzGkuit2+7DvWxVG1"
  CommandACL = status, .status
}

bacula-sd.conf配置

存储端的配置文件是bacula-sd.conf,它主要负责定义备份文件的存放方式和地址,具体的情况如下所示:

Storage { #定义存储端名称
  Name = bacula-test-sd
  SDPort = 9103 
  WorkingDirectory = "/var/spool/bacula/"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
}

Director {
  Name = bacula-test-dir
  Password = "qy5ILHHJNXLCUWGudeC1ke1hPioBo+ye2bUBU5ncxADg"
}

Director {
  Name = bacula-test-mon
  Password = "7zSF0B9viPBuwkKpPC2PoJw1qxOEuvCxbWDxzXc1cHk9"
  Monitor = yes
}

Autochanger { #是否自动更换设备
  Name = FileChgr1
  Device = FileChgr1-Dev1, FileChgr1-Dev2 #定义需更换的设备
  Changer Command = ""
  Changer Device = /dev/null
} 

Device {
  Name = FileChgr1-Dev1
  Media Type = File1 #类型是文件(可以是DVD,磁带)
  Archive Device = /tmp #存放位置
  LabelMedia = yes; #媒体标注
  Random Access = Yes;
  AutomaticMount = yes; #自动挂载
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Device {
  Name = FileChgr1-Dev2
  Media Type = File1
  Archive Device = /tmp
  LabelMedia = yes; 
  Random Access = Yes;
  AutomaticMount = yes; 
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Autochanger {
  Name = FileChgr2
  Device = FileChgr2-Dev1, FileChgr2-Dev2
  Changer Command = ""
  Changer Device = /dev/null
} 

Device {
  Name = FileChgr2-Dev1
  Media Type = File2
  Archive Device = /tmp
  LabelMedia = yes; 
  Random Access = Yes;
  AutomaticMount = yes; 
  RemovableMedia = no;
  AlwaysOpen = no;
 Maximum Concurrent Jobs = 5
}

Device {
  Name = FileChgr2-Dev2
  Media Type = File2
  Archive Device = /tmp
  LabelMedia = yes; 
  Random Access = Yes;
  AutomaticMount = yes; 
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Messages {
  Name = Standard
  director = bacula-test-dir = all
}

Bacula备份、恢复测试

备份操作

运行备份操作
[root@bacula-test /tmp]bconsole                                           #进入console界面
Connecting to Director 192.168.17.100:9101
1000 OK: 102 bacula-test-dir Version: 7.4.1 (15 February 2016)
Enter a period to cancel a command.
*label                                                                                    #标签状态
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
The defined Storage resources are:
     1: File1
     2: File2
Select Storage resource (1-2): 1                                         #定义的存储资源
Enter new Volume name: vol-20160601
Defined Pools:
     1: Default
     2: File
     3: Scratch
Select the Pool (1-3): 2                                                     #文件类型
Connecting to Storage daemon File1 at 192.168.17.100:9103 ...
Sending label command for Volume "vol-20160601" Slot 0 ...
3000 OK label. VolBytes=209 VolABytes=0 VolType=1 Volume="vol-20160601" Device="FileChgr1-Dev1" (/tmp)
Catalog record for Volume "vol-20160601", Slot 0  successfully created.
Requesting to mount FileChgr1 ...
3906 File device ""FileChgr1-Dev1" (/tmp)" is always mounted.
*run                                                                                   #执行备份操作
A job name must be specified.
The defined Job resources are:
     1: Backup-17.98
     2: BackupClient1
     3: BackupCatalog
     4: RestoreFiles
Select Job resource (1-4): 3                                               #选择需要备份的客户端
Run Backup job
JobName:  BackupCatalog
Level:    Full
Client:   bacula-test-fd
FileSet:  Catalog
Pool:     File (From Job resource)
Storage:  File1 (From Job resource)
When:     2016-06-01 15:59:49
Priority: 11
OK to run? (yes/mod/no): yes                                              #同意备份
Job queued. JobId=37
*messages
You have no messages.
*exit

恢复操作

#bconsole
Connecting to Director 192.168.17.100:9101
1000 OK: 102 bacula-test-dir Version: 7.4.1 (15 February 2016)
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): 5
Defined Clients:
1: bacula-17-98
2: bacula-test-fd
Select the Client (1-2): 2
The defined FileSet resources are:
1: Catalog
2: Full Set
Select FileSet resource (1-2): 2
------------------------------------------------------------------+

JobId

Level

JobFiles

JobBytes

StartTime

VolumeName

------------------------------------------------------------------+

1

F

126

731,496

2016-05-18 16:02:32

linux-file1

29

D

5

991,369

2016-05-29 23:05:04

db-2016-05-29-id29

32

I

2

1,000,660

2016-05-30 23:05:04

db-2016-05-30-id32

35

I

2

1,038,878

2016-05-31 23:05:05

db-2016-05-31-id35

------------------------------------------------------------------+
You have selected the following JobIds: 1,29,32,35
Building directory tree for JobId(s) 1,29,32,35 ... ++++++++++++++++++++++++++++++++++++++++
122 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
var/
$ mark var
126 files marked.
$ lsmark
*var/
*lib/
*mysql/
*aria_log.00000001
*aria_log_control
*bacula/
*BaseFiles.frm
*CDImages.frm
*Client.frm
done
Bootstrap records written to /var/spool/bacula//bacula-test-dir.restore.1.bsr
Bootstrap records written to /var/spool/bacula//bacula-test-dir.restore.1.bsr
The Job will require the following (*=>InChanger):
Volume(s) Storage(s) SD Device(s)
===========================================================================
linux-file1 File1 FileChgr1
db-2016-05-29-id29 File1 FileChgr1
db-2016-05-31-id35 File1 FileChgr1
Volumes marked with "*" are in the Autochanger.

126 files selected to be restored.
Using Catalog "MyCatalog"
Run Restore job
JobName: RestoreFiles
Bootstrap: /var/spool/bacula//bacula-test-dir.restore.1.bsr
Where: /tmp/bacula-restores
Replace: Always
FileSet: Full Set
Backup Client: bacula-test-fd
Restore Client: bacula-test-fd
Storage: File1
When: 2016-06-01 16:08:14
Catalog: MyCatalog
Priority: 10
Plugin Options:
OK to run? (yes/mod/no): yes
Job queued. JobId=38
*messages
You have no messages.


 



iscsi网络存储

配置FreeNAS

考虑专业的磁盘柜价格不菲,而使用服务器的方式一方面磁盘容量有限,另一方面IO的性能也很难保障。FreeNAS是一套免费的NAS服务器,它能将一部普通PC变成网络存储服务器。用户可通过Windows、Macs、FTP、SSH 及网络文件系统 (NFS) 来访问存储服务器。

我们通过它来组建符合企业使用的备份存储设备,该系统具体的安装步骤可参考相关资源。这里通过启用iscsi功能实现网络备份存储,相关设置如下图。


配置iscsi客户端

iSCSI的服务器端已经在FreeNAS上完成配置,接下来需要在linux系统上完成客户端的配置,实现在客户端对网络存储的挂载。

首先安装相关的系统组件并完成配置文件的修改。

yum -y install iscsi-initiator-utils 
vi /etc/iscsi/initiatorname.iscsi 
InitiatorName=iqn.2016-06.com.redhat:82367514497d #客户端的标记

接下来修改主要的配置文件。

vi /etc/iscsi/iscsid.conf 
node.session.auth.authmethod = CHAP #根据freenas的设置修改
node.session.auth.username = myj.5.199
node.session.auth.password = testtesttest
discovery.sendtargets.auth.authmethod = CHAP #根据freenas的设置修改
discovery.sendtargets.auth.username = backup.myj
discovery.sendtargets.auth.password = testtesttest


完成设置后通过以下指令查看配置和连接情况。

iscsiadm -m discovery -t sendtargets -p 192.168.5.199
iscsiadm -m node -o show 



配置开机自动挂载

完成iSCSI的配置后,接下来配置开机自动挂载及相应的服务自动启动设定,具体系统分区操作略。

systemctl enable iscsid.service
iscsiadm -m node -T iqn.2005-10.org.freenas.ctl:backu-10ttarget -p 192.168.5.199 --op update -n node.startup -v automatic
Ls -l /dev/disk/by-uuid
Blkid /dev/sdc1


备份存储设置

配置bacula-dir.conf

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Client = bak-192.168.0.97
  FileSet = "Windows"
  Schedule = "WeeklyCycle"
  Storage = windows-file
  Messages = Standard
  Pool = Default
  Full Backup Pool = full-pool
  Incremental Backup Pool = inc-pool
  Differential Backup Pool = diff-pool
  SpoolAttributes = yes
  Priority = 10
  Write Bootstrap = "/var/spool/bacula/%h.bsr"
}

Job {
  Name = "bak-192.168.0.97"
  JobDefs = "DefaultJob"
}

Job{
  Name = "bak-192.168.5.86"
  Type = Backup
  Level = Incremental
  Client = bacula-fd
  FileSet = "Bacula Set"
  Schedule = "WeeklyCycle"
  Storage = linux-file
  Messages = Standard
  Pool = Default
  Full Backup Pool = full-pool
  Incremental Backup Pool = inc-pool
  Differential Backup Pool = diff-pool
  SpoolAttributes = yes
  Priority = 10
  Write Bootstrap = "/var/spool/bacula/%h.bsr"
}

Job {
  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/libexec/bacula/make_catalog_backup.pl MyCatalog"
# This deletes the copy of the catalog
  RunAfterJob = "/usr/libexec/bacula/delete_catalog_backup"
  Write Bootstrap = "/var/spool/bacula/%n.bsr"
  Priority = 11 # run after main backup
}

Job {
  Name = "RestoreFiles"
  Type = Restore
  Client=bacula-fd
  FileSet="Bacula Set"
  Storage = linux-file
  Pool = Default
  Full Backup Pool = full-pool
  Incremental Backup Pool = inc-pool
  Differential Backup Pool = diff-pool
  Messages = Standard
  Where = /tmp/bacula-restores
}

FileSet {
  Name = "Windows"
  Include {
    Options {
      signature = MD5
      compression = GZIP
      IgnoreCase = yes
    }
  File = "e:/datatbak"
  }
}

FileSet {
  Name = "Bacula Set"
  Include {
    Options {
      signature = MD5
      Compression = GZIP
    }
    File = /var/lib/mysql
  }
  Exclude {
    File = /var/spool/bacula
    File = /tmp
    File = /proc
    File = /tmp
    File = /sys
    File = /.journal
    File = /.fsck
  }
}

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 = "/var/spool/bacula/bacula.sql"
  }
}

Client {
  Name = bak-192.168.0.97
  Address = 192.168.0.97
  FDPort = 9102
  Catalog = MyCatalog
  Password = "IYN0eZTw2BrRcA/MNGCwGHb9OrHDRykMMF8jSxtA7zUF" # password for FileDaemon
  File Retention = 15 days # 60 days
  Job Retention = 1 months # six months
  AutoPrune = yes # Prune expired Jobs/Files
}

Storage {
  Name = windows-file
# Do not use "localhost" here
  Address = 192.168.5.86 # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "4UMQ2b+Il8HiPxXotZLCzUhNfXasKRFlVOeOFNN0m5XS"
  Device = FileChgr-windows
  Media Type = File
  Maximum Concurrent Jobs = 10 # run up to 10 jobs a the same time
}

Storage {
  Name = linux-file
# Do not use "localhost" here
  Address = 192.168.5.86 # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "4UMQ2b+Il8HiPxXotZLCzUhNfXasKRFlVOeOFNN0m5XS"
  Device = FileChgr-linux
  Media Type = File
  Maximum Concurrent Jobs = 10 # run up to 10 jobs a the same time
}

Catalog {
  Name = MyCatalog
  dbname = "bacula"; dbuser = "bacula"; dbpassword = "www.myj123.com"
}

Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes # Bacula can automatically recycle Volumes
  AutoPrune = yes # Prune expired volumes
  Volume Retention = 30 days # one year
  Maximum Volume Bytes = 150G # Limit Volume size to something reasonable
  Maximum Volumes = 100 # Limit number of Volumes in Pool
}

Pool {
  Name = File
  Pool Type = Backup
  Recycle = yes # Bacula can automatically recycle Volumes
  AutoPrune = yes # Prune expired volumes
  Volume Retention = 30 days # one year
  Maximum Volume Bytes = 150G # Limit Volume size to something reasonable
  Maximum Volumes = 100 # Limit number of Volumes in Pool
  Label Format = "Vol-" # Auto label
}

pool{
  Name = full-pool
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Maximum Volume Jobs = 1
  Volume Retention = 15 days
  Maximum Volumes = 30
  Label Format = "Full-${Year}${Month/2/0/r}${Day/2/0/r}-id${JobId}"
}

pool{
  Name = diff-pool
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Maximum Volume Jobs = 1
  Volume Retention = 30 days
  Maximum Volumes = 60
  Label Format = "Diff-{Year}${Month/2/0/r}${Day/2/0/r}-id${JobId}"
}

pool{
  Name = inc-pool
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Maximum Volume Jobs = 6
  Volume Retention = 20 days
  Maximum Volumes = 150
  Maximum Volume Bytes = 200G
  Label Format = "Inc-${Year}${Month/2/0/r}${Day/2/0/r}-id${JobId}"
}

# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}



配置bacula-sd.conf

Device {
  Name = FileChgr-windows
  Media Type = File
  Archive Device = /backup/windows
  LabelMedia = yes; # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes; # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

Device {
  Name = FileChgr-linux
  Media Type = File
  Archive Device = /backup/linux
  LabelMedia = yes; # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes; # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
  Maximum Concurrent Jobs = 5
}

图形界面配置

bacula默认的安装是字符界面(其实也有基于QT环境的GUI界面,考虑性能和所依赖的安装包太多,没有使用)。第三方的工具有基于WEB的界面报告,基本上可以满足日常需要。

安装相关组件


yum install httpd php php-gd php-gettext php-mysql php-pdo
systemctl enable httpd.service
systemctl start httpd.service
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
cd /var/www/html
curl -O http://www.bacula-web.org/files/bacula-web.org/downloads/bacula-web-latest.tgz
mkdir -v /var/www/html/bacula
tar -xzf bacula-web-latest.tgz -C /var/www/html/bacula
chown -Rv apache: /var/www/html/bacula
cd application/config
cp -v config.php.sample config.php
chown -v apache: config.php

配置文件

vi config.php
$config['language'] = 'en_EN';
$config[0]['label'] = 'Backup Server';
$config[0]['host'] = 'localhost';
$config[0]['login'] = 'bacula';
$config[0]['password'] = 'verystrongpassword';
$config[0]['db_name'] = 'bacula';
$config[0]['db_type'] = 'mysql';
$config[0]['db_port'] = '3306';

vi /etc/php.ini
date.timezone = Asia/Shanghai

vim /etc/httpd/conf.d/bacula.conf



测试

  • 无标签

0 评论

你还没有登录。你所做的任何更改会将作者标记为匿名用户。 如果你已经拥有帐户,请登录