본문 바로가기

넋두리/linux 이야기

Bacula 설정과 사용하기 -Part I

opensource backup 솔루션인 Bacula 설치와 사용하기.

설치환경

백업서버
IP: 59.29.142.85
Hostname: fox1
OS: Ubuntu 12.04

백업 클라이언트(백업대상 서버)
IP: 59.29.142.120
Hostname: ubuntu-1
OS: ubuntu 12.04

1. Bacula의 구성

director : 백업, 리스토어, 아카이브 등의 동작을 담당.
console : director와의 통신을
storage : 물리 매체에 데이타를 저장, 복구하는 프로그램
file : 백업 클라이언트
catalog:
monitor: director, storage, file 데몬을 모니터링.

2. Bacult 서버 설치

# yun install bacula

3. 백업서버 및 클라이언트 설정

백업디렉토리: /backup/archive
리스토어디렉토리: /backup/restore

# mkdir -p /backup/archive
# mkdir -p /backup/restore
# chown -R bacula:bacula /backup

/etc/bacula/bacula-dir.conf 수정

Director { # define myself
Name = fox1-dir
DIRport = 9101 # where we listen for UA connections
QueryFile = “/etc/bacula/scripts/query.sql”
WorkingDirectory = “/var/lib/bacula”
PidDirectory = “/var/run/bacula”
Maximum Concurrent Jobs = 1
Password = “vOchjaYxGgFnKdbE5me5a3Tp5vs763FyoIhXdqUF733A” # Console pa
ssword
Messages = Daemon
#DirAddress = 127.0.0.1
DirAddress = 59.29.142.85
}

JobDefs {
Name = “DefaultJob”
Type = Backup
Level = Incremental
Client = fox1-fd
FileSet = “Full Set”
Schedule = “WeeklyCycle”
Storage = File
Messages = Standard
Pool = File
Priority = 10
Write Bootstrap = “/var/lib/bacula/%c.bsr”
}

Job {
Name = “BackupClient1″
JobDefs = “DefaultJob”
}

Job {
Name = “RestoreFiles”
Type = Restore
Client=fox1-fd
FileSet=”Full Set”
Storage = File
Pool = Default
Messages = Standard
#Where = /nonexistant/path/to/file/archive/dir/bacula-restores
Where = /backup/restore
}

FileSet {
Name = “Full Set”
Include {
Options {
signature = MD5
}

# File = /usr/sbin
File = /home

}

Exclude {
File = /var/lib/bacula
File = /backup
File = /proc
File = /tmp
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
}

# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
Name = “WeeklyCycleAfterBackup”
Run = Full sun-sat at 23:10
}

FileSet {
Name = “Catalog”
Include {
Options {
signature = MD5
}
File = “/var/lib/bacula/bacula.sql”
}
}

Client {
Name = fox1-fd
Address = 59.29.142.85
FDPort = 9102
Catalog = MyCatalog
Password = “UfuZihWIUNJpt6DluctDXbueCwsnl3cE9″ # password for FileDae
mon
File Retention = 30 days # 30 days
Job Retention = 6 months # six months
AutoPrune = yes # Prune expired Jobs/Files
}

Storage {
Name = File
# Do not use “localhost” here
Address = 59.29.142.85 # N.B. Use a fully qualified name here
SDPort = 9103
Password = “hamtKHNE27OB7AwGFy5ZfyLzs5ml8OoY4″
Device = FileStorage
Media Type = File
}

Catalog {
Name = MyCatalog
# Uncomment the following line if you want the dbi driver
# dbdriver = “dbi:sqlite3″; dbaddress = 127.0.0.1; dbport =
dbname = “bacula”; DB Address = “localhost”; dbuser = “bacula”; dbpassword = “bacula”
}

Messages {
Name = Standard

mailcommand = “/usr/lib/bacula/bsmtp -h localhost -f \”\(Bacula\) \<%r\>\” -s
\”Bacula: %t %e of %c %l\” %r”
operatorcommand = “/usr/lib/bacula/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/lib/bacula/log” = all, !skipped
catalog = all
}

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 reasonabl
e
Maximum Volumes = 100 # Limit number of Volumes in Pool
}

Pool {
Name = Scratch
Pool Type = Backup
}

Console {
Name = fox1-mon
Password = “8XbAVNy7mm1_YEXmrgavMBAhZXeTsIaTp”
CommandACL = status, .status
}

/etc/bacula-sd.conf 수정

Storage { # definition of myself
Name = fox1-sd
SDPort = 9103 # Director’s port
WorkingDirectory = “/var/lib/bacula”
Pid Directory = “/var/run/bacula”
Maximum Concurrent Jobs = 20
# SDAddress = 127.0.0.1
SDAddress = 59.29.142.85
}

Director {
Name = fox1-mon
Password = “W0AUWl0nc7FXfuqC8wHP3Gp1u93IRrV33″
Monitor = yes
}

Device {
Name = FileStorage
Media Type = File
# Archive Device = /nonexistant/path/to/file/archive/dir
Archive Device = /backup/archive
LabelMedia = yes; # lets Bacula label unlabeled media
Random Access = Yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
}

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

/etc/bacula/bacula-fd.conf 수정

Director {
Name = fox1-dir
Password = “UfuZihWIUNJpt6DluctDXbueCwsnl3cE9″
}

Director {
Name = fox1-mon
Password = “iJnxPgnJ6sg5cF1NZoS57RMlSHS_-Raoe”
Monitor = yes
}

FileDaemon { # this is me
Name = fox1-fd
FDport = 9102 # where we listen for the director
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run/bacula
Maximum Concurrent Jobs = 20
# FDAddress = 127.0.0.1
FDAddress = 59.29.142.85
}

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

/etc/bacula/bconsole.conf

Director {
# Name = localhost-dir
Name = fox1-dir
DIRport = 9101
# address = localhost
address = 59.29.142.85
Password = “vOchjaYxGgFnKdbE5me5a3Tp5vs763FyoIhXdqUF733A”
}

설정후 각 서비스(디렉터, 스토리지, 클라이언트)를 재 실행한다

# /etc/init.d/bacula-director restart
* Stopping Bacula Director… [ OK ]
* Starting Bacula Director… [ OK ]
# /etc/init.d/bacula-sd restart
* Stopping Bacula Storage daemon… [ OK ]
* Starting Bacula Storage daemon… [ OK ]
# /etc/init.d/bacula-fd restart
* Stopping Bacula File daemon… [ OK ]
* Starting Bacula File daemon…

4. 백업 실행

설정이 이상없이되었다면, bconsole 실행하면 아래와 같은 화면이 나온다.

# bconsole
Connecting to Director 59.29.142.85:9101
1000 OK: fox1-dir Version: 5.2.5 (26 January 2012)
Enter a period to cancel a command.

*
*help
Command Description
======= ===========
add Add media to a pool
autodisplay Autodisplay console messages
automount Automount after label
cancel Cancel a job
create Create DB Pool from resource
delete Delete volume, pool or job
disable Disable a job
enable Enable a job
estimate Performs FileSet estimate, listing gives full listing
exit Terminate Bconsole session
gui Non-interactive gui mode
help Print help on specific command
label Label a tape
list List objects from catalog
llist Full or long list like list command
messages Display pending messages
memory Print current memory usage
mount Mount storage
prune Prune expired records from catalog
purge Purge records from catalog
python Python control commands
quit Terminate Bconsole session
query Query catalog
restore Restore files
relabel Relabel a tape
release Release storage
reload Reload conf file
run Run a job
status Report status
setdebug Sets debug level
setip Sets new client address — if authorized
show Show resource records
sqlquery Use SQL to query catalog
time Print current time
trace Turn on/off trace to file
unmount Unmount storage
umount Umount – for old-time Unix guys, see unmount
update Update volume, pool or stats
use Use catalog xxx
var Does variable expansion
version Print Director version
wait Wait until no jobs are running

When at a prompt, entering a period cancels the command.

*

볼륨을 생성한다.

*add
You probably don’t want to be using this command since it
creates database records without labeling the Volumes.
You probably want to use the “label” command.

Defined Pools:
1: Default
2: File
3: Scratch
Select the Pool (1-3): 2
Automatically selected Storage: File
Enter number of Volumes to create. 0=>fixed name. Max=99: 0
Enter Volume name: vol_2
1 Volumes created in pool File

생성한 볼륨의 레이블링 작업

*label
Automatically selected Storage: File
Enter new Volume name: vol_2
Defined Pools:
1: Default
2: File
3: Scratch
Select the Pool (1-3): 2
Connecting to Storage daemon File at 59.29.142.85:9103 …
Sending label command for Volume “vol_2″ Slot 0 …
3000 OK label. VolBytes=184 DVD=0 Volume=”vol_2″ Device=”FileStorage” (/backup/archive)
Requesting to mount FileStorage …
3906 File device “”FileStorage” (/backup/archive)” is always mounted.

백업은 정해진 시간에 실행되지만, bconsole에서 실행 할 수 있다.

*run
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: BackupClient1
Level: Incremental
Client: fox1-fd
FileSet: Full Set
Pool: File (From Job resource)
Storage: File (From Job resource)
When: 2013-06-12 23:25:23
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=10
You have messages.
*

실행한 백업의 상태 확인

*status
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 1
fox1-dir Version: 5.2.5 (26 January 2012) x86_64-pc-linux-gnu ubuntu 12.04
Daemon started 12-Jun-13 23:17. Jobs: run=1, running=1 mode=0,0
Heap: heap=405,504 smbytes=90,618 max_bytes=91,597 bufs=288 max_bufs=300

Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 13-Jun-13 23:05 BackupClient1 vol_1
Full Backup 11 13-Jun-13 23:10 BackupCatalog vol_1
====

Running Jobs:
Console connected at 12-Jun-13 23:17
JobId Level Name Status
======================================================================
10 Full BackupClient1.2013-06-12_23.31.48_05 is running
====

백업이 끝나면 아래와 같은 상태가된다.

*st
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 3
Automatically selected Client: fox1-fd
Connecting to Client fox1-fd at 59.29.142.85:9102

fox1-fd Version: 5.2.5 (26 January 2012) x86_64-pc-linux-gnu ubuntu 12.04
Daemon started 12-Jun-13 23:30. Jobs: run=1 running=0.
Heap: heap=270,336 smbytes=104,496 max_bytes=365,565 bufs=80 max_bufs=190
Sizeof: boffset_t=8 size_t=8 debug=0 trace=0
Running Jobs:
Director connected at: 12-Jun-13 23:50
No Jobs running.
====

Terminated Jobs:
JobId Level Files Bytes Status Finished Name
======================================================================
5 Full 208 23.06 M OK 12-Jun-13 20:47 BackupClient1
6 Incr 0 0 OK 12-Jun-13 23:05 BackupClient1
10 Full 28,965 9.570 G OK 12-Jun-13 23:46 BackupClient1
====

5. 백업 화일의 복구

여기서는 이름을 알고 있는 화일(/home/snowfox/apache-cloudstack-4.0.1-incubating-src.tar.bz2)을 복구해 보도록 한다.

*restore

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): 7
Defined Clients:
1: fox1-fd
2: ubuntu-1
Select the Client (1-2): 1
Enter file names with paths, or < to enter a filename
containing a list of file names with paths, and terminate
them with a blank line.
Enter full filename: /home/snowfox/apache-cloudstack-4.0.1-incubating-src.tar.bz2
Enter full filename:
Bootstrap records written to /var/lib/bacula/fox1-dir.restore.3.bsr

The job will require the following
Volume(s) Storage(s) SD Device(s)
===========================================================================

vol_1 File FileStorage

Volumes marked with “*” are online.
1 file selected to be restored.

Run Restore job
JobName: RestoreFiles
Bootstrap: /var/lib/bacula/fox1-dir.restore.3.bsr
Where: /backup/restore
Replace: always
FileSet: Full Set
Backup Client: fox1-fd
Restore Client: fox1-fd
Storage: File
When: 2013-06-13 00:05:04
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=11
*

*st
Status available for:
1: Director
2: Storage
3: Client
4: All
Select daemon type for status (1-4): 1
……생략 …..

10 Full 28,965 9.570 G OK 12-Jun-13 23:46 BackupClient1
11 1 9.223 M OK 13-Jun-13 00:05 RestoreFiles

====
*

/backup/restore 에 복구된 화일이 있는것을 볼 수 있다. (패스 포함)

# ls -al
total 9016
drwxrw-r– 2 snowfox snowfox 4096 Jun 13 00:05 .
drwxr-x–x 3 root root 4096 Jun 13 00:05 ..
-rw-rw-r– 1 snowfox snowfox 9223743 Jan 29 04:37 apache-cloudstack-4.0.1-incubating-src.tar.bz2

# pwd
/backup/restore/home/snowfox

 

'넋두리 > linux 이야기' 카테고리의 다른 글

Autoboot: failed, BOOT string is empty  (0) 2013.10.01
nmon 소개  (0) 2013.10.01
CentOS 6.4 x86_64 ISPConfig  (0) 2013.10.01
클라우드스택에서 젠서버(agent) 설치 방법  (0) 2013.10.01
서버 랜(hardware) 포트 확인 시  (0) 2013.10.01