本帖最后由 xsser 于 2016-4-21 17:39 编辑
bacula 是什么 不知道的请自行百度,现在演示bacula 的安装步骤,我的配置是Director与SD以及Console在一台机器上,而客户端FD在另外一台机器上下面开始
1.bacula(console端ip:10.0.1.121)安装
#yum install gcc* libtermcap-devel make ncurses-devel ncurses
#wget http://netcologne.dl.sourceforge ... bacula-7.4.0.tar.gz
#tar zxvf bacula-7.4.0.tar.gz
#cd bacula-7.4.0
#./configure --prefix=/usr/local/bacula/ --with-mysql=/usr/local/mysql/ #需要提前安装配置mysql,mysql安装与配置请自行百度
#make
#make install
#make install-autostart #添加自动启动程序
安装好以后会自动创建bacula用户,请自行设置bacula的密码初始化Mysql数据库
#cd /usr/local/bacula/etc
#./grant_mysql_privileges -p
#./create_bacula_database -u bacula -p
#./make_mysql_tables -u bacula -p
2.bacula (FD端安装ip:10.0.1.122)
#yum install gcc* libtermcap-devel make ncurses-devel ncurses
#wget http://netcologne.dl.sourceforge ... bacula-7.4.0.tar.gz
#tar zxvf bacula-7.4.0.tar.gz
#cd bacula-7.4.0
#./configure --prefix=/usr/local/bacula/ --enable-client-only
#make
#make install
3.配置bconsole.conf bacula-dir.conf bacula-sd.conf
bconsole.conf配置如下:红色部分是需要修改的(可以直接复制粘贴我的配置文件个别需要根据自己的配置进行修改)
# Bacula User Agent (or Console) Configuration File
#
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
Director {
Name = server_10.0.1.121 #控制端名称,在下面的bacula-dir.conf和bacula-sd.conf
文件中会陆续的被引用
DIRport = 9101 #控制端服务端口
address = 10.0.1.121 #控制端服务器IP地址
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" #控制端密码文件
}
bacula-dir.conff配置如下:红色部分是需要修改的(可以直接复制粘贴我的配置文件个别需要根据自己的配置进行修改)
#
# Default Bacula Director Configuration file
#
# The only thing that MUST be changed is to add one or more
# file or directory names in the Include directive of the
# FileSet resource.
#
# For Bacula release 7.4.0 (16 January 2016) -- redhat
#
# You might also want to change the default email address
# from root to your address. See the "mail" and "operator"
# directives in the Messages resource.
#
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
Director { # define myself
Name = server_10.0.1.121
DIRport = 9101 # where we listen for UA connections
QueryFile = "/usr/local/bacula/etc/query.sql"
WorkingDirectory = "/opt/bacula/working"
PidDirectory = "/var/run"
Maximum Concurrent Jobs = 20
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" # Console password
Messages = Daemon
}
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental #Incremental为增量备份。Level的取值#可为Full(完全备份)、Incremental(增量备份)和Differential(差异备份)
Client = 10.0.1.122-fd
FileSet = "web"
Schedule = "WeeklyCycle"
Storage = 10.0.1.121-sd
Messages = Standard
Pool = File
SpoolAttributes = yes
Priority = 10
Write Bootstrap = "/opt/bacula/working/%c.bsr"
}
#
# Define the main nightly save backup job
# By default, this job will back up to disk in /tmp
Job {
Name = "BackupClient1"
JobDefs = "DefaultJob"
}
#Job {
# Name = "BackupClient2"
# Client = nginx2-fd
# JobDefs = "DefaultJob"
#}
#Job {
# Name = "BackupClient1-to-Tape"
# JobDefs = "DefaultJob"
# Storage = LTO-4
# Spool Data = yes # Avoid shoe-shine
# Pool = Default
#}
#}
# Backup the catalog database (after the nightly save)
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/local/bacula/etc/make_catalog_backup.pl MyCatalog"
# This deletes the copy of the catalog
RunAfterJob = "/usr/local/bacula/etc/delete_catalog_backup"
Write Bootstrap = "/opt/bacula/working/%n.bsr"
Priority = 11 # run after main backup
}
#
# Standard Restore template, to be changed by Console program
# Only one such job is needed for all Jobs/Clients/Storage ...
#
Job {
Name = "RestoreFiles"
Type = Restore
Client=10.0.1.122-fd
FileSet="web"
Storage = 10.0.1.121-sd
Pool = File
Messages = Standard
Where = /tmp/bacula-restores #数据恢复的目录
}
# List of files to be backed up
FileSet {
Name = "web"
Include {
Options {
signature = MD5
}
#
# Put your list of files here, preceded by 'File =', one per line
# or include an external list with:
#
# File = <file-name
#
# Note: / backs up everything on the root partition.
# if you have other partitions such as /usr or /home
# you will probably want to add them too.
#
# By default this is defined to point to the Bacula binary
# directory to give a reasonable FileSet to backup to
# disk storage during initial testing.
#
File = /data #需要备份的目录
}
#
# If you backup the root directory, the following two excluded
# files can be useful
#
Exclude {
File = /opt/bacula/working
File = /tmp
File = /proc
File = /tmp
File = /sys
File = /.journal
File = /.fsck
}
}
#
# When to do the backups, full backup on first sunday of the month,
# differential (i.e. incremental since full) every other sunday,
# and incremental backups other days
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
}
# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
Name = "WeeklyCycleAfterBackup"
Run = Full sun-sat at 23:10
}
# This is the backup of the catalog
FileSet {
Name = "Catalog"
Include {
Options {
signature = MD5
}
File = "/opt/bacula/working/bacula.sql"
}
}
# Client (File Services) to backup
Client {
Name = 10.0.1.122-fd
Address = 10.0.1.122
FDPort = 9102
Catalog = MyCatalog
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" # password for FileDaemon
File Retention = 60 days # 60 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}
#
# Second Client (File Services) to backup
# You should change Name, Address, and Password before using
#
#Client {
# Name = nginx2-fd
# Address = nginx2
# FDPort = 9102
# Catalog = MyCatalog
# Password = "LsvHRHJNr4vzwaVicb6tKvsuLGGPUiZfdvrj/MO2DEPu2" # password for FileDaemon 2
# File Retention = 60 days # 60 days
# Job Retention = 6 months # six months
# AutoPrune = yes # Prune expired Jobs/Files
#}
# Definition of file Virtual Autochanger device
Storage {
Name = 10.0.1.121-sd
# Do not use "localhost" here
Address = 10.0.1.121 # N.B. Use a fully qualified name here
SDPort = 9103
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t"
Device = FileChgr1
Media Type = File1
Maximum Concurrent Jobs = 10 # run up to 10 jobs a the same time
}
# Definition of a second file Virtual Autochanger device
# Possibly pointing to a different disk drive
#Storage {
# Name = File2
# Do not use "localhost" here
# Address = nginx # N.B. Use a fully qualified name here
# SDPort = 9103
# Password = "fRHtos0rZjmJRTgXztrWB0hWHpFXkWMkEa1xFWZjW220"
# Device = FileChgr2
# Media Type = File2
# Maximum Concurrent Jobs = 10 # run up to 10 jobs a the same time
#}
# Definition of LTO-4 tape Autochanger device
#Storage {
# Name = LTO-4
# Do not use "localhost" here
# Address = nginx # N.B. Use a fully qualified name here
# SDPort = 9103
# Password = "fRHtos0rZjmJRTgXztrWB0hWHpFXkWMkEa1xFWZjW220" # password for Storage daemon
# Device = LTO-4 # must be same as Device in Storage daemon
# Media Type = LTO-4 # must be same as MediaType in Storage daemon
# Maximum Concurrent Jobs = 10
#}
# Generic catalog service
Catalog {
Name = MyCatalog
dbname = "bacula"; dbuser = "bacula"; dbpassword = "123456" #数据库密码
}
# Reasonable message delivery -- send most everything to email address
# and to the console
Messages {
Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
# to replace the %r in the from field (-f part) with a single valid
# email address in both the mailcommand and the operatorcommand.
# What this does is, it sets the email address that emails would display
# in the FROM field, which is by default the same email as they're being
# sent to. However, if you send email to more than one address, then
# you'll have to set the FROM address manually, to a single address.
# for example, a 'no-reply@mydomain.com', is better since that tends to
# tell (most) people that its coming from an automated source.
#
mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
operatorcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
mail = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
#
# WARNING! the following will create a file that you must cycle from
# time to time as it will grow indefinitely. However, it will
# also keep all your messages if they scroll off the console.
#
append = "/opt/bacula/log/bacula.log" = all, !skipped
catalog = all
}
#
# Message delivery for daemon messages (no job).
Messages {
Name = Daemon
mailcommand = "/usr/local/bacula/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula daemon message\" %r"
mail = root@localhost = all, !skipped
console = all, !skipped, !saved
append = "/opt/bacula/log/bacula.log" = all, !skipped
}
# Default pool definition
Pool {
Name = Default
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
}
# File Pool definition
Pool {
Name = File
Pool Type = Backup
Recycle = yes # Bacula can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 365 days # one year
Maximum Volume Bytes = 50G # Limit Volume size to something reasonable
Maximum Volumes = 100 # Limit number of Volumes in Pool
Label Format = "Vol-" # Auto label
}
# Scratch pool definition
Pool {
Name = Scratch
Pool Type = Backup
}
#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
Name = nginx-mon
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t"
CommandACL = status, .status
}
baclu-sd.conf配置如下:红色部分是需要修改的(可以直接复制粘贴我的配置文件个别需要根据自己的配置进行修改)
å#
# Default Bacula Storage Daemon Configuration file
#
# For Bacula release 7.4.0 (16 January 2016) -- redhat
#
# You may need to change the name of your tape drive
# on the "Archive Device" directive in the Device
# resource. If you change the Name and/or the
# "Media Type" in the Device resource, please ensure
# that dird.conf has corresponding changes.
#
#
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
Storage { # definition of myself
Name = 10.0.1.121-sd
SDPort = 9103 # Director's port
WorkingDirectory = "/opt/bacula/working"
Pid Directory = "/var/run"
Maximum Concurrent Jobs = 20
}
#
# List Directors who are permitted to contact Storage daemon
#
Director {
Name = server_10.0.1.121
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t"
}
#
# Restricted Director, used by tray-monitor to get the
# status of the storage daemon
#
Director {
Name = nginx-mon
Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t"
Monitor = yes
}
#
# Note, for a list of additional Device templates please
# see the directory <bacula-source>/examples/devices
# Or follow the following link:
# http://bacula.svn.sourceforge.ne ... a/examples/devices/
#
#
# Devices supported by this Storage daemon
# To connect, the Director's bacula-dir.conf must have the
# same Name and MediaType.
#
#
# Define a Virtual autochanger
#
Autochanger {
Name = FileChgr1
Device = FileChgr1-Dev1, FileChgr1-Dev2
Changer Command = ""
Changer Device = /dev/null
}
Device {
Name = FileChgr1-Dev1
Media Type = File1
Archive Device = /tmp
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 = FileChgr1-Dev2
Media Type = File1
Archive Device = /tmp
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
}
#
# Define a second Virtual autochanger
#
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; # 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 = FileChgr2-Dev2
Media Type = File2
Archive Device = /tmp
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
}
#
# An autochanger device with two drives
#
#Autochanger {
# Name = Autochanger
# Device = Drive-1
# Device = Drive-2
# Changer Command = "/usr/local/bacula/etc/mtx-changer %c %o %S %a %d"
# Changer Device = /dev/sg0
#}
#Device {
# Name = Drive-1 #
# Drive Index = 0
# Media Type = DLT-8000
# Archive Device = /dev/nst0
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# AutoChanger = yes
# #
# # Enable the Alert command only if you have the mtx package loaded
# # Note, apparently on some systems, tapeinfo resets the SCSI controller
# # thus if you turn this on, make sure it does not reset your SCSI
# # controller. I have never had any problems, and smartctl does
# # not seem to cause such problems.
# #
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#Device {
# Name = Drive-2 #
# Drive Index = 1
# Media Type = DLT-8000
# Archive Device = /dev/nst1
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# AutoChanger = yes
# # Enable the Alert command only if you have the mtx package loaded
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#
# A Linux or Solaris LTO-2 tape drive
#
#Device {
# Name = LTO-2
# Media Type = LTO-2
# Archive Device = /dev/nst0
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# Maximum File Size = 3GB
## Changer Command = "/usr/local/bacula/etc/mtx-changer %c %o %S %a %d"
## Changer Device = /dev/sg0
## AutoChanger = yes
# # Enable the Alert command only if you have the mtx package loaded
## Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo
## Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#
# A Linux or Solaris LTO-3 tape drive
#
#Device {
# Name = LTO-3
# Media Type = LTO-3
# Archive Device = /dev/nst0
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# Maximum File Size = 4GB
## Changer Command = "/usr/local/bacula/etc/mtx-changer %c %o %S %a %d"
## Changer Device = /dev/sg0
## AutoChanger = yes
# # Enable the Alert command only if you have the mtx package loaded
## Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo
## Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#
# A Linux or Solaris LTO-4 tape drive
#
#Device {
# Name = LTO-4
# Media Type = LTO-4
# Archive Device = /dev/nst0
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# Maximum File Size = 5GB
## Changer Command = "/usr/local/bacula/etc/mtx-changer %c %o %S %a %d"
## Changer Device = /dev/sg0
## AutoChanger = yes
# # Enable the Alert command only if you have the mtx package loaded
## Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
## If you have smartctl, enable this, it has more info than tapeinfo
## Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#
# An HP-UX tape drive
#
#Device {
# Name = Drive-1 #
# Drive Index = 0
# Media Type = DLT-8000
# Archive Device = /dev/rmt/1mnb
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes;
# RemovableMedia = yes;
# RandomAccess = no;
# AutoChanger = no
# Two EOF = yes
# Hardware End of Medium = no
# Fast Forward Space File = no
# #
# # Enable the Alert command only if you have the mtx package loaded
# Alert Command = "sh -c 'tapeinfo -f %c |grep TapeAlert|cat'"
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#
# A FreeBSD tape drive
#
#Device {
# Name = DDS-4
# Description = "DDS-4 for FreeBSD"
# Media Type = DDS-4
# Archive Device = /dev/nsa1
# AutomaticMount = yes; # when device opened, read it
# AlwaysOpen = yes
# Offline On Unmount = no
# Hardware End of Medium = no
# BSF at EOM = yes
# Backward Space Record = no
# Fast Forward Space File = no
# TWO EOF = yes
# If you have smartctl, enable this, it has more info than tapeinfo
# Alert Command = "sh -c 'smartctl -H -l error %c'"
#}
#
# Send all messages to the Director,
# mount messages also are sent to the email address
#
Messages {
Name = Standard
director = server_10.0.1.121 = all
}
客户端10.0.1.122 bacula-fd.conf 配置文件如下 红色是需要修改的
# Default Bacula File Daemon Configuration file # # For Bacula release 7.4.0 (16 January 2016) -- redhat # # There is not much to change here except perhaps the # File daemon Name to # # # Copyright (C) 2000-2015 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS #
# # List Directors who are permitted to contact this File daemon # Director { Name = server_10.0.1.121 Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" }
# # Restricted Director, used by tray-monitor to get the # status of the file daemon # Director { Name = nginx-mon Password = "ouDao0SGXx/F+Tx4YygkK4so0l/ieqGJIkQ5DMsTQh6t" Monitor = yes }
# # "Global" File daemon configuration specifications # FileDaemon { # this is me Name = 10.0.1.122-fd FDport = 9102 # where we listen for the director WorkingDirectory = /opt/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20 # Plugin Directory = /usr/local/bacula/lib }
# Send all messages except skipped files back to Director Messages { Name = Standard director = server_10.0.1.121 = all, !skipped, !restored } 4.启动bacula #service bacula start 查看端口 #netstat -ntlp |grep 91 tcp 0 0 0.0.0.0:9101 0.0.0.0:* LISTEN 2342/bacula-dir tcp 0 0 0.0.0.0:9102 0.0.0.0:* LISTEN 2329/bacula-fd tcp 0 0 0.0.0.0:9103 0.0.0.0:* LISTEN 2307/bacula-sd 5.运行bconsole #/usr/local/bacula/sbin/bconsole Connecting to Director 10.0.1.121:9101 1000 OK: 102 server_10.0.1.121 Version: 7.4.0 (16 January 2016) 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: BackupClient1 2: BackupCatalog 3: RestoreFiles Select Job resource (1-3):1 Run Backup job JobName: 10.0.1.122_backup Level: Incremental Client: 10.0.1.122-fd FileSet: web Pool: File (From Job resource) Storage: 10.0.1.121-sd (From Job resource) When: 2016-04-21 16:59:51 Priority: 10 OK to run? (yes/mod/no):yes 查看状态命令status 要恢复数据的话请输入restore 客户端启动fd命令 #/usr/local/bacula/etc/bacula-ctl-fd start 6.安装Bacula-Web图形界面(php环境请自行安装) #tar zxvf bacula-web-5.2.12.tgz -C /data/wwwroot/www.webacula.com/ #cd /data/wwwroot/www.webacula.com/application/config/ #cp config.php.sample config.php #vim config.php 参照一下代码修改 // MySQL bacula catalog $config[0]['label'] = 'Backup Server'; $config[0]['host'] = 'localhost'; $config[0]['login'] = 'bacula'; $config[0]['password'] = '123456'; $config[0]['db_name'] = 'bacula'; $config[0]['db_type'] = 'mysql'; $config[0]['db_port'] = '3306'; #chown www -R /data/wwwroot/www.webacula.com/application/view/cache #service nginx restart #service php-fpm restart
|