이번 편에서는 복원에 대해서 알아보자.  방법 자체는 백업과 크게 다르진 않은데, DIR에 Job으로 정의해놓을 경우 지정된 시간에 지정된 복원을 수행하는 것이 가능하다.  예를 들자면, 매일 같은 상태로 복원되어야만 하는 컴퓨터들이 여러대 혹은 수십 수백대가 있다면 이것들을 일괄처리할 수 있다는 장점이 있다.  설정은 전부 다 같고 Job {} 섹션에서 Type = Backup을 Type = Restore로 넣어주기만 하면 되니까 이것의 실습은 생략하고, bconsole을 이용한 복원을 실습해보도록 한다.

일단 Bacula는 최소 하나 이상의 복원 Job을 정의해야만 수동 복원작업이 작동가능하도록 되어있다.  /etc/bacula/bacula-dir.conf 파일을 열어서 최소한의 설정만 넣어주면 되므로, 다음의 내용을 삽입하고 데몬을 재시작해주자.

Job {
  Name = "Restore"
  Type = Restore
  Messages = Standard
  Pool = Server
  Client = "DBServer"
  FileSet = "Full Set"
}

sudo service bacula-director restart

 

위에 정의해놓은대로만 복원작업이 작동되는건 아니다.   bconsole을 이용하여 원하는 클라이언트에 원하는 파일을 복원할 수 있다.  Bacula의 복원은 원하는 파일을 원하는 위치에 꽂아넣을 수 있다는 장점이 있다.  bconsole에서 restore를 입력해보자.  

*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):

차례대로 보자.

1. 마지막 20개 작업 나열
2. 파일이 백업된 장소로 작업 나열
3. 작업별 ID 번호를 콤마 기호로 나열하여 입력
4. SQL 쿼리를 사용한 목록 나열
5. 클라이언트의 가장 최근 작업을 선택 => 가장 많이 쓰인다.
6. 클라이언트의 특정 시간대 이전 작업 선택
7. 복원할 파일명을 직접 입력
8. 특정 시간대 이전에 백업된 파일 중 복원할 파일명을 직접 입력
9. 클라이언트의 가장 최근 백업 ID 찾기
10. 특정 시간대 이전 클라이언트의 가장 최근 백업 ID 찾기
11. 특정 백업 ID에 백업된 디렉토리명 입력
12. 특정 일자로 전체 복원
13.  취소

 

이전의 예제에서 우리는 FTP 서버를 백업했으므로 5번 메뉴를 이용하여 복원을 해보자.  참고로 입력을 잘못 했을 경우 점 (.)을 찍으면 언제든지 취소할 수 있다.

Select item: (1-13): 5
Defined Clients:
  1: DBServer
  2: Desktop
  3: FTP Server
  4: Web Server
  5: dbserver-fd
Select the Client (1-5): 3
Automatically selected FileSet: Full Set
+-------+-------+----------+-------------+---------------------+------------+
| JobId | Level | JobFiles |  JobBytes   |     StartTime       | VolumeName |
+-------+-------+----------+-------------+---------------------+------------+
|   5   |   F   |  55,461  | 982,708,126 | 2013-06-25 05:03:10 |  Server-1  |
+-------+-------+----------+-------------+---------------------+------------+
You have selected the following JobId: 5

Building directory tree for JobId(s) 5 ... +++++++++++++++++++++++++++++++++++++++++++
48,147 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

bin/
boot/
dev
etc/
home/
initrd.img
lib/
lib64/
lost+found
media/
mnt/
opt
root/
run
sbin/
selinux
srv
sys
usr/
var/
vmlinuz
$

실습에서는 /etc/bacula/bacula-fd.conf 파일을 /tmp 위치로 복원하는 것을 해보자.

$ cd etc/bacula
cwd is: /etc/bacula/
$ ls
bacula-fd.conf
bacula-sd.conf
bacula-sd.conf.dist
common_default_passwords
scripts/
$ mark bacula-fd.conf
1 file marked.
$ done
Bootstrap records written to /var/lib/bacula/dbserver-dir.restore.1.bsr

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

  Server-1 Server Backup FileStorage-1

Volumes marked with "*" are online.


1 file selected to be restored.

Run Restore job
JobName: Restore
Bootstrap: /var/lib/bacula/dbserver-dir.restore.1.bsr
Where: *None*
Replace: always
FileSet: Full Set
Backup Client: FTP Server
Restore Client: FTP Server
Storage: Server Backup
When: 2013-06-25 06:31:54
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*

OK to run? (yes/mod/no): mod
Parameters to modify:
  1: Level
  2: Storage
  3: Job
  4: FileSet
  5: Restore Client
  6: When
  7: Priority
  8: Bootstrap
  9: Where
  10: File Relocation
  11: Replace
  12: JobId
  13: Plugin Options
Select parameter to modify (1-13): 9
Please enter path prefix for restore (/ for none): /tmp
Run Restore job
JobName: Restore
Bootstrap: /var/lib/bacula/dbserver-dir.restore.1.bsr
Where: /tmp
Replace: always
FileSet: Full Set
Backup Client: FTP Server
Restore Client: FTP Server
Storage: Server Backup
When: 2013-06-25 06:31:54
Catalog: MyCatalog
Priority: 10
Plugin Options: *None*
OK to run? (yes/mod/no): yes
Job queued. JobId=6

이제 제대로 실행되는지 보자.

*status dir
dbserver-dir Version: 5.2.5 (26 January 2012) x86_64-pc-linux-gnu ubuntu 12.04
Daemon started 25-Jun-13 06:15. Jobs: run=1, running=0 mode=0,0
Heap: heap=286,720 smbytes=77,288 max_bytes=9,888,526 bufs=270 max_bufs=295

Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Incremental Backup 10 25-Jun-13 23:05 DBServer Backup Server-1
Incremental Backup 10 25-Jun-13 23:05 FTP Backup *unknown*
Incremental Backup 10 25-Jun-13 23:05 WEB Backup Server-1
Incremental Backup 10 25-Jun-13 23:05 Desktop Backup Server-1
Full Backup 11 25-Jun-13 23:10 BackupCatalog Server-1
====

Running Jobs:
Console connected at 25-Jun-13 06:17
No Jobs running.
====

Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
1 Full 0 0 Error 25-Jun-13 03:34 BackupClient1
3 Full 0 0 Cancel 25-Jun-13 04:56 FTP_Backup
4 Full 10 7.737 K OK 25-Jun-13 04:58 FTP_Backup
5 Full 55,461 982.7 M OK 25-Jun-13 05:06 FTP_Backup
6 1 974 OK 25-Jun-13 06:32 Restore

====
You have messages.
*

Running에는 아무 것도 뜨지않았지만 message가 있다고 나오는걸 보니 작업이 끝난 것 같다.  확인해보자.

*messages
25-Jun 06:32 dbserver-dir JobId 6: Start Restore Job Restore.2013-06-25_06.32.45_03
25-Jun 06:32 dbserver-dir JobId 6: Using Device "FileStorage-1"
25-Jun 04:11 FTPServer-sd JobId 6: Ready to read from volume "Server-1" on device "FileStorage-1" (/mnt/backup-1/bacula).
25-Jun 04:11 FTPServer-sd JobId 6: Forward spacing Volume "Server-1" to file:block 0:9594.
25-Jun 06:32 dbserver-dir JobId 6: Bacula dbserver-dir 5.2.5 (26Jan12):
Build OS: x86_64-pc-linux-gnu ubuntu 12.04
JobId: 6
Job: Restore.2013-06-25_06.32.45_03
Restore Client: FTP Server
Start time: 25-Jun-2013 06:32:47
End time: 25-Jun-2013 06:32:48
Files Expected: 1
Files Restored: 1
Bytes Restored: 974
Rate: 1.0 KB/s
FD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Restore OK

25-Jun 06:32 dbserver-dir JobId 6: Begin pruning Jobs older than 6 months .
25-Jun 06:32 dbserver-dir JobId 6: No Jobs found to prune.
25-Jun 06:32 dbserver-dir JobId 6: Begin pruning Files.
25-Jun 06:32 dbserver-dir JobId 6: No Files found to prune.
25-Jun 06:32 dbserver-dir JobId 6: End auto prune.

*

성공적으로 복원되었다.  이제 파일을 확인하러 가보자.   FTP 서버로 접속해서 /tmp 에 있는 파일을 확인하면 된다.

root@ftp:~# ls -l /tmp/etc/bacula/bacula-fd.conf
-rw-r----- 1 root root 974 Jun 25 02:29 /tmp/etc/bacula/bacula-fd.conf
root@ftp:~#

파일 소유권과 날짜까지 제대로 복원되었다.

 

Bacula에 대해 혹평하는 몇몇 외국 유저들의 이야기를 보면 그들 전부가 "어떻게 쓰는줄을 모르기 때문에" 생겨나는 불평이다.  백업이 안되느니 복원이 안되느니 하면서 사용을 포기하는 유저들을 몇몇 봤는데, 글쓴이 경험상 Bacula 자체에 버그가 있어서 안된 경우는 아직 못봤다.  처음 접하기 어려운 툴인 것만은 분명 사실이다.  하지만 작동원리만 알고나면 정말 쓰기 쉬운 프로그램인 것도 분명 사실이다.



다음 편에서는 GUI로 Bacula를 제어해보자.

블로그 이미지

jswlinux

Seowon Jung의 잡동사니 보관소

,