Bacula 기반 시스템 백업 환경 구축

Bacula 기반 시스템 백업 환경 구축

 

작성자 : 서진우 (alang@clunix.com)
작성일 : 2016년 4월 21일

 

Bacula(바큘라) 는 백업과 드라큘라의 혼합어로 엔지니어가 신경쓰지 않아도..
밤에 몰래 들어와서 흡혈을하는 드라큘라처럼 필요한 데이터를 알아서 백업해준다..
뭐~ 이런 의미의 이름이라고 함.

주요 구성 요소로는

– 디렉터(Director) : 백업과 복구 작업을 지시하고 제어하는 서버
– 스토리지(Storage) : 백업 파일이 저장되는 서버
– 카탈로그(Catalog) : 백업과 복구와 같은 작업 정보가 저장되는 DB 서버
– 파일데몬(File Deaemon) : 백업 대상 클라이언트 서버

이고, 이밖에 ..

– 콘솔(Console) : 백업 및 복구의 명령을 수행하는 터미널
– 모니터링 : X-Windows 유틸로 제공되는 다양한 모니터링 도구

이 있다.

이 모든 구성은 1대의 서버에 설치될 수도 있고, 역할별로 나누어 설치할 수도
있다.

일반적인 구성은 별도의 백업 서버 1대를 준비해서 백업 디스크나 테잎장치를
연결한 후, 해당 서버에 ..

디렉터, 스토리지, 카탈로그(DB서버), 콘솔, 모니터링 등의 구성요소를 설치
하여, 기타 백업 대상 호스트에 필요한 파일들을 자동으로 백업하게 된다.

간혹 백업 스토리지 공간이 다른 서버를 이용해야하는 경우는 스토리지 관련
패키지를 별도의 다른 서버로 분리하기도 한다.
본 문서에서 구축하는 서버 환경 구성은 다음과 같다.

백업서버 -> BCLMGR01 (RHEL6) : 디렉터, 스토리지, 카탈로그, 콘솔, 모니터링 ..

백업대상서버 -> RNTMGR01 (RHEL6), WRENDER01(Windows 7)

임..
1. 백업 서버 설치 (BCLMGR01 서버..)
rhel6, centos6 기반 yum repo 구성

# vi /etc/yum.repos.d/centos.repo
—————————————————————————-
[base-be]
name=CentOS-6 – Base
repo=os
baseurl=http://ftp.daum.net/centos/6/os/x86_64/
enabled=1
gpgcheck=0
gpgkey=http://ftp.daum.net/centos/6/os/x86_64/RPM-GPG-KEY-CentOS-6

[updates-be]
name=CentOS-6 – Updates
baseurl=http://ftp.daum.net/centos/6/updates/x86_64/
enable=1
gpgcheck=0

[centosplus-be]
name=CentOS-6 – Plus
baseurl=http://ftp.daum.net/centos/6/centosplus/x86_64/
enabled=1
gpgcheck=0

[extras-be]
name=CentOS-6 – Extras
baseurl=http://ftp.daum.net/centos/6/extras/x86_64/
enable=1
gpgcheck=0

[fasttrack-be]
name=CentOS-6 – Fasttrack
baseurl=http://ftp.daum.net/centos/6/fasttrack/x86_64/
enabled=1
gpgcheck=0

————————————————————————–
– 사전 utils 설치

bacula 5.x
# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

bacula 7.x
# cd /etc/yum.repo.d
# wget https://repos.fedorapeople.org/slaanesh/bacula7/epel-bacula7.repo

or

# vi /etc/yum.repos.d/epel-bacula7.repo

[epel-bacula7]
name=Bacula backports from rawhide
baseurl=https://repos.fedorapeople.org/slaanesh/bacula7/epel-6/x86_64/
enabled=1
gpgcheck=0
# yum install -y wget bind-utils vim-enhanced rdate mysql-server mysql-devel

X Windows 에서 제공하는 bacula 관리 프로그램을 사용하기 위해서 필요한 X-Windows 패키지
설치..

# yum groupinstall -y “Desktop” “X Window System” “Fonts” “Graphical Administration Tools” “Internet Browser” “General Purpose Desktop” “kde-desktop” “Legacy X Window System compatibility”
# vi /etc/inittab
init 5

– Bacula 설치

bacula 5.x
# yum install -y bacula-client.x86_64 bacula-common.x86_64 bacula-console.x86_64 \
bacula-console-bat.x86_64 bacula-director-common.x86_64 bacula-director-mysql.x86_64 \
bacula-docs.x86_64 bacula-storage-common.x86_64 bacula-storage-mysql.x86_64 \
bacula-traymonitor.x86_64

bacula 7.x
# yum install bacula-client.x86_64 bacula-common.x86_64 bacula-console.x86_64 \
bacula-console-bat.x86_64 bacula-director.x86_64 bacula-director-mysql.x86_64 \
bacula-docs.x86_64 bacula-storage.x86_64 bacula-traymonitor.x86_64 bacula-devel \
bacula-libs bacula-libs-sql
yum을 통한 rpm 설치 후 주요 디렉토리 및  실행 파일의 위치는 아래와 같다.

* 설정 디렉토리 : /etc/bacula
* sql 관련 파일 : /usr/libexec/bacula
* 로그 및 상태 파일 : /var/spool/bacula
* 시작 스크립트 : /etc/init.d/bacula-*
* 각종 실행 파일 위치 : /usr/sbin
– 카탈로그 DB 서버 환경 구성

# service mysqld start
# chkconfig –add mysqld

# /usr/libexec/bacula/create_bacula_database
Creating MySQL database
Creation of bacula database succeeded.
# /usr/libexec/bacula/make_bacula_tables

Making MySQL tables
Creation of Bacula MySQL tables succeeded.

# /usr/libexec/bacula/grant_bacula_privileges
만일 mysql_secure_installation 명령으로 mysql root password 가 설정된
경우라면 /etc/my.cnf 에 mysql root 패스워드 설정을 해 주거나 아래 방식으로
직접 DB 스키마를 입력해야 한다.

# /usr/libexec/bacula/grant_mysql_privileges -u root -p
# /usr/libexec/bacula/create_mysql_database -u root -p
# /usr/libexec/bacula/make_mysql_tables -u root -p
# /usr/libexec/bacula/grant_bacula_privileges mysql -u root -p
bacula db user 패스워드 변경

# mysql -u root -p
mysql> UPDATE mysql.user SET password=PASSWORD(“bacula///”) WHERE user=’bacula’;
mysql> FLUSH PRIVILEGES;
2. 백업 대상 클라이언트(RNTMGR01) 설치 및 설정

# yum install -y bacula-client.x86_64 bacula-common.x86_64

# vi /etc/bacula/bacula-fd.conf
———————————————————————–
Director {
# // 원하는 백업 시스템 이름을 설정함.
Name = bclmgr01-dir
# // default password 는 반드시 변경해 줘야함.
Password = “xxxxxxxx”
}

Director {
Name = bclmgr01-mon
Password = “xxxxxxxx”
Monitor = yes
}

Messages {
Name = Standard
director = bclmgr01-dir = all, !skipped, !restored
}

# // 백업서버 이름과 IP 설정, 백업대상호스트마다 이부분만 변경됨
FileDaemon {
Name = rntmgr01-fd
FDport = 9102
WorkingDirectory = /var/spool/bacula
Pid Directory = /var/run
Maximum Concurrent Jobs = 20
FDAddress = 192.168.201.50
}

————————————————————————

# /etc/init.d/bacula-fd start
# chkconfig –level 345 bacula-fd on
3. 스토리지(BCLMGR01) 서버 설치 및 설정

전용 스토리지 서버가 디렉터와 별도로 존재할 경우는 아래 패키지만 설치한다.

# yum install -y bacula-common.x86_64 bacula-storage-common.x86_64 \
bacula-storage-mysql.x86_64
# vi /etc/bacula/bacula-sd.conf
————————————————————————
# // 아래 3가지 설정은 bacula 모든 구성 호스트에 공통적으로 지정되는 설정

Director {
Name = bclmgr01-dir
Password = “xxxxxxxx”
}

Director {
Name = bclmgr01-mon
Password = “xxxxxxxx”
Monitor = yes
}

Messages {
Name = Standard
director = bclmgr01-dir = all
}

# // 여기서 부터 스토리지 관련 설정임
# // 스토리지 이름과 스토리지 서버 IP 지정, 대부분 스토리지호스트이름
# 뒤에 -sd를 붙임.

Storage {
Name = bclmgr01-sd
SDPort = 9103
WorkingDirectory = “/var/spool/bacula”
Pid Directory = “/var/run”
Maximum Concurrent Jobs = 20
SDAddress = 192.168.201.68
}

# // 백업 데이터가 저장되는 장치이름과 저장 경로 지정
# 아래는 백업 데이터가 데이터 성격별로 3군대로 나누어 저장되도록
# 설정한 것임.

Device {
Name = BackupStorage1
Media Type = File
Archive Device = /backup/pool1
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}

Device {
Name = BackupStorage2
Media Type = File
Archive Device = /backup/pool2
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}

Device {
Name = BackupStorage3
Media Type = File
Archive Device = /backup/pool3
LabelMedia = yes;
Random Access = Yes;
AutomaticMount = yes;
RemovableMedia = no;
AlwaysOpen = no;
}

————————————————————————

# /etc/rc.d/init.d/bacula-sd start
# chkconfig –level 345 bacula-sd on
4. 디렉터 설정

Bacula 설정은 각 구성 역할 별로 고유 정보 (이름, IP, 데이터저장소정보..)에
해당하는 설정을 정의한 후, 디렉터 설정에서 대응되는 설정을 통합하는 형태이다.

그렇기 때문에 디렉터 설정이 제일 복잡하고 중요하다.

# vi /etc/bacula/bacula-dir.conf

———————————————————————–
# 디렉터 이름 정의 ############################################################

Director {
Name = bclmgr01-dir
DIRport = 9101
QueryFile = “/usr/libexec/bacula/query.sql”
WorkingDirectory = “/var/spool/bacula”
PidDirectory = “/var/run”
Maximum Concurrent Jobs = 5
Password = “xxxxxxxx”
Messages = Daemon
}

# 콘솔 정의  ###################################################################

Console {
Name = bclmgr01-mon
Password = “xxxxxxxx”
CommandACL = status, .status
}

# 백업 정보 저장 DB 서버 관련 설정  ############################################

Catalog {
Name = MyCatalog
dbname = “bacula”; dbuser = “bacula”; dbpassword = “xxxxxxxxx”
}

# 이벤트 발생 시 백업 콘솔에 표시되는 출력 메세지 레벨 정의 ###################

Messages {
Name = Standard
mailcommand = “/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 = root@localhost = all, !skipped
operator = root@localhost = mount
console = all, !skipped, !saved
append = “/var/spool/bacula/log” = all, !skipped
catalog = all
}

Messages {
Name = Daemon
mailcommand = “/usr/sbin/bsmtp -h localhost -f \”\(Bacula\) \<%r\>\” -s \”Bacula daemon message\” %r”
mail = root@localhost = all, !skipped
}

# 작업 환경 정의 ###############################################################

JobDefs {
Name = “OS Backup JobDefs”
Type = Backup
Level = Incremental
FileSet = “OS Backup FileSet”
Schedule = “WeeklyCycle”
Storage = “OS Backup”
Messages = Standard
Pool = “OS Backup Pool”
Priority = 10
Write Bootstrap = “/var/spool/bacula/%c.bsr”
}

JobDefs {
Name = “Data Backup JobDefs”
Type = Backup
Level = Incremental
FileSet = “Data Backup FileSet”
Schedule = “WeeklyCycle”
Storage = “Data Backup”
Messages = Standard
Pool = “Data Backup Pool”
Priority = 10
Write Bootstrap = “/var/spool/bacula/%c.bsr”
}

JobDefs {
Name = “Windows Backup JobDefs”
Type = Backup
Level = Incremental
FileSet = “Windows Backup FileSet”
Schedule = “WeeklyCycle”
Storage = “Windows Backup”
Messages = Standard
Pool = “Windows Backup Pool”
Priority = 10
Write Bootstrap = “/var/spool/bacula/%c.bsr”
}

# 단위 작업 정의 ###############################################################

Job {
Name = “rntmgr01 os backup”
JobDefs = “OS Backup JobDefs”
Client = “rntmgr01-fd”
}

Job {
Name = “rntmgr01 data backup”
JobDefs = “Data Backup JobDefs”
Client = “rntmgr01-fd”
}

Job {
Name = “windows os backup”
JobDefs = “Windows Backup JobDefs”
Client = “WRENDER01-fd”
}

Job {
Name = “rntmgr01 data full restore”
Type = Restore
FileSet = “Data Backup FileSet”
Client = “rntmgr01-fd”
Pool = “Data Backup Pool”
Messages = “Standard”
Where = /tmp
}

# 단위 백업 대상 파일 정의 #####################################################

FileSet {
Name = “OS Backup FileSet”
Include {
Options {
signature = MD5
compression = GZIP
}
File = /etc
File = /root
}
Exclude {
File = /.fsck
}
}

FileSet {
Name = “Data Backup FileSet”
Include {
Options {
signature = MD5
compression = GZIP
}
File = /home
}
Exclude {
File = /home/muchun.201605090959.old
}
}

FileSet {
Name = “Windows Backup FileSet”
Include {
Options {
signature = MD5
compression = GZIP
}
File = “C:/Windows/System32”
}
Exclude {
}
}

# 백업 스케줄 정책 정의 ######################################################

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
#  Run = Level=Incremental hourly at 0:00
#  Run = Level=Incremental hourly at 0:20
#  Run = Level=Incremental hourly at 0:40
}

# 백업 대상 호스트 정보 정의 #################################################

Client {
Name = rntmgr01-fd
Address = 192.168.201.50
FDPort = 9102
Catalog = MyCatalog
Password = “xxxxxxxx”
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}

Client {
Name = WRENDER01-fd
Address = 192.168.201.55
FDPort = 9102
Catalog = MyCatalog
Password = “xxxxxxxx”
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}

# 백업 스토리지 정의 #########################################################

Storage {
Name = “OS Backup”
Address = 192.168.201.68
SDPort = 9103
Password = “xxxxxxxx”
Device = BackupStorage1
Media Type = File
}

Storage {
Name = “Data Backup”
Address = 192.168.201.68
SDPort = 9103
Password = “xxxxxxxx”
Device = BackupStorage2
Media Type = File
}

Storage {
Name = “Windows Backup”
Address = 192.168.201.68
SDPort = 9103
Password = “xxxxxxxx”
Device = BackupStorage2
Media Type = File
}
# 스토리지 저장 풀 정의 ####################################################

Pool {
Name = “OS Backup Pool”
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
Maximum Volume Bytes = 1000M
Maximum Volumes = 100
Storage = “OS Backup”
# 아래 설정을 통해 Volume이 사이즈가 1000Mbyte가 넘어가면 Vol001,
# Vol002 식의 이름으로 자동생성된다.
LabelFormat = “Vol”
}

Pool {
Name = “Data Backup Pool”
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
Maximum Volume Bytes = 5000M
Maximum Volumes = 100
Storage = “Data Backup”
# 아래 설정을 통해 Volume이 사이즈가 1000Mbyte가 넘어가면 Vol001,
# Vol002 식의 이름으로 자동생성된다.
LabelFormat = “Vol”
}

Pool {
Name = “Windows Backup Pool”
Pool Type = Backup
Recycle = yes
AutoPrune = yes
Volume Retention = 365 days
Maximum Volume Bytes = 5000M
Maximum Volumes = 100
Storage = “Windows Backup”
LabelFormat = “Vol”
}
Console {
Name = bclmgr01-mon
Password = “xxxxxxxx”
CommandACL = status, .status
}

——————————————————————————–
bacula 구성 요소별 설정 파일을 열고 반드시 default password 를 변경한다.
변경하지 않으면 아래 데몬 시작이 안됨

# /etc/init.d/bacula-dir start
# chkconfig –level 345 bacula-dir on
5. 기타 설정

# vi /etc/bacula/bconsole.conf
——————————
#
# Bacula User Agent (or Console) Configuration File
#

Director {
Name = bclmgr01-dir
DIRport = 9101
address = 192.168.201.68
Password = “xxxxxxxx”
}
—————————–

# vi /etc/bacula/bat.conf
—————————–
Director {
Name = bclmgr01-dir
DIRport = 9101
address = 192.168.201.68
Password = “xxxxxxxx”
}
—————————–

# vi /etc/bacula/tray-monitor.conf
—————————–
Monitor {
Name = bclmgr01-mon
Password = “xxxxxxxx”         # password for the Directors
RefreshInterval = 5 seconds
}

Client {
Name = rntmgr01-fd
Address = 192.168.201.50
FDPort = 9102
Password = “xxxxxxxx”          # password for FileDaemon
}

Client {
Name = WRENDER01-fd
Address = 192.168.201.55
FDPort = 9102
Password = “xxxxxxxx”          # password for FileDaemon
}

Storage {
Name = bclmgr01-sd
Address = 192.168.201.68
SDPort = 9103
Password = “xxxxxxxx”          # password for StorageDaemon
}

Director {
Name = bclmgr01-dir
Address = 192.168.201.68
DIRport = 9101
}
——————————
6. bacula-web 모니터링 설정
# yum -y install php php-gd php-gettext php-mysql php-pdo httpd wget

# mkdir /var/www/html/bacula-web
# cd /var/www/html/bacula-web
# wget http://www.bacula-web.org/files/bacula-web.org/downloads/bacula-web-latest.tgz
# tar zxvf bacula-web-latest.tgz
# chmod 700 -R /var/www/html/bacula-web
# chown -R apache.apache /var/www/html/bacula-web

cd /var/www/html/bacula-web/application/config
cp config.php.sample config.php
vi config.php
.
// MySQL bacula catalog
$config[0][‘label’] = ‘Backup Server’;
$config[0][‘host’] = ‘localhost’;
$config[0][‘login’] = ‘bacula’;
$config[0][‘password’] = ”;
$config[0][‘db_name’] = ‘bacula’;
$config[0][‘db_type’] = ‘mysql’;
$config[0][‘db_port’] = ‘3306’;
.

vi /etc/php.ini
date.timezone = “Asia/Seoul”

vi /etc/httpd/conf.d/bacula-web.conf
ServerName 127.0.0.1
<Directory /var/www/html/bacula-web>
AllowOverride All
</Directory>
# /etc/rc.d/init.d/httpd restart

http://bacula-web
7. bconsole 로 백업/복구 하기

– 백업

# bconsole
Connecting to Director 192.168.201.242:9101
* run
Automatically selected Catalog: MyCatalog
Using Catalog “MyCatalog”
A job name must be specified.
The defined Job resources are:
1: vdi-m os backup
2: clxbacula os backup
3: vdi-m doc backup
4: rntmgr01 home backup
Select Job resource (1-4): 2

Run Backup job
JobName:  clxbacula os backup
Level:    Incremental
Client:   clxbacula-fd
FileSet:  OS Backup FileSet
Pool:     OS Backup Pool (From Job resource)
Storage:  OS Backup (From Pool resource)
When:     2016-05-27 15:10:41
Priority: 10
OK to run? (yes/mod/no): yes

* status dir
clxbacula-dir Version: 5.0.0 (26 January 2010) x86_64-redhat-linux-gnu redhat
Daemon started 27- 52016 06:01, 0 Jobs run since started.
Heap: heap=270,336 smbytes=111,935 max_bytes=154,238 bufs=349 max_bufs=350

Scheduled Jobs:
Level          Type     Pri  Scheduled          Name               Volume
===================================================================================
Incremental    Backup    10  27- 52016 23:05  vdi-m os backup    OS_Vol0001
Incremental    Backup    10  27- 52016 23:05  clxbacula os backup OS_Vol0001
Incremental    Backup    10  27- 52016 23:05  vdi-m doc backup   OS_Vol0001
Incremental    Backup    10  27- 52016 23:05  rntmgr01 home backup OS_Vol0001
====

Running Jobs:
Console connected at 27- 52016 06:06
Console connected at 27- 52016 06:06
Console connected at 27- 52016 06:07
Console connected at 27- 52016 15:08
JobId Level   Name                       Status
======================================================================
1 Full    clxbacula_os_backup.2016-05-27_15.11.44_08 is running
====
No Terminated Jobs.
====
* restore
8. bat 으로 관리하기

bat(Bacula Admin Tool) 로 X-Windows 상에서 제공하는 Bacula 관리툴임.
백업/복구 작업 수행, 모니터링, 클라이언트, FileSet, Job, Pools, Media, Stoage 상태
를 모니터링 관리할 수 있다.

9. webmin

Linux OS, Server 설정 관리 프로그램인 Webmin 을 통해 Bacula 설정 및 기타 관리
가 가능함.
wget http://sourceforge.net/projects/webadmin/files/webmin/1.660/webmin-1.660-1.noarch.rpm
rpm -Uvh webmin-1.660-1.noarch.rpm
/etc/rc.d/init.d/webmin start
chkconfig –add webmin

http://<IP>:10000
10. TIP

– volume 일괄 삭제

echo “list of volumes” | bconsole | grep Doc | cut -f 3 -d \| > doc_list

for vol in `cat doc_list` ; do echo “delete volume=$vol yes”; done | bconsole

– volume 생성 및 백업

*label pool=”Doc Backup Pool” Storage=”Doc Backup” volume=”Doc_Vol0142″
*run job=”vdi-m doc backup” fileset=”Doc Backup FileSet” client=”vdi-m-fd” storage=”Doc Backup” Level=”Full”

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

3 Responses

  1. 2022년 5월 6일

    […] + 여기서 자세히 보기 […]

  2. 2022년 6월 20일

    3lustful

  3. 2023년 1월 26일

    1moderator