이번 편부터는 실제로 수동백업을 해보자.  수동백업의 의미는, bacula-dir.conf 디렉터 데몬 설정파일에서 이미 Job, FileSet, Schedule 등으로 "자동화" 해놨으므로 백업작업은 스케쥴에 정의된 시간에 자동으로 실행이 될 예정이다.  하지만, 지정된 시간이 아닌 수동으로 백업을 할 수 있어야하며 이때 제공되는 CLI와 GUI툴이 있다. 

일단은 GUI보다 CLI로 먼저 실습을 해볼건데, 왜냐하면 GUI는 기본적으로 CLI 툴에서 나오는 메시지를 예쁘게 포장한 것에 불과하기 때문이며, 리눅스 프로그램들이 다들 그렇듯 자세한 설정은 결국 CLI를 통해야만 하기 때문이다.  따라서, CLI툴에 익숙해져야 응급상황에 빠르게 대처할 수 있다.

Bacula의 CLI툴은 bconsole이라고 하는데, apt-get install bacula-console 명령을 통해서 설치할 수 있다.  디렉터 서버는 이 예제에서는 DBserver에서 운영 중이므로 DBserver에서 설치한다 (물론 다른 서버에 설치해도 된다.  그게 Bacula의 장점이다).  설치가 끝나면 /etc/bacula/bconsole.conf 파일을 열어서 name과 주소, 그리고 패스워드를 DIR 설정에 맞게 변경해주자.

Director {
  Name = dbserver-dir
  DIRport = 9101
  address = 10.211.55.33
  Password = "dir"
}

다 됐으면 루트권한으로 bconsole을 실행하자.  다음과 같은 화면이 나올거다.

root@dbserver:/etc/bacula# bconsole
Connecting to Director 10.211.55.33:9101
1000 OK: dbserver-dir Version: 5.2.5 (26 January 2012)
Enter a period to cancel a command.
*

bconsole은Tab키를 이용한 자동완성을 지원하므로 명령어가 생각이 나지않거나 파일셋, 클라이언트 이름 등이 해깔릴 때 요긴하게 사용할 수 있다.  먼저, DIR의 상태를 확인해보자.

*status dir
dbserver-dir Version: 5.2.5 (26 January 2012) x86_64-pc-linux-gnu ubuntu 12.04
Daemon started 25-Jun-13 04:09. Jobs: run=0, running=0 mode=0,0
Heap: heap=405,504 smbytes=49,275 max_bytes=51,814 bufs=220 max_bufs=232

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

Running Jobs:
Console connected at 25-Jun-13 04:21
No Jobs running.
====

Terminated Jobs:
JobId Level Files Bytes Status Finished Name
====================================================================
1 Full 0 0 Error 25-Jun-13 03:34 BackupClient1

====
*

글쓴이가 이 글을 작성하는 시점에서 백업 스케쥴이 실행되는 시간이 되는 바람에 Job이 하나 취소됐다.  그래서 Terminated Jobs에 하나 떴다.

일단 DIR을 처음 실행하고 bconsole에 들어오면 가장 먼저 해야할 일이 볼륨을 생성해주는 일이다.  그래서, unknown이라는 메시지가 보이는 이유는 현재 DIR 데몬이 어디에 백업을 해야하는지 모르는 상태이다.  서버백업용 볼륨을 하나 생성해보자.

*label pool=Server storage="Server Backup" volume=Server-1
Connecting to Storage daemon Server Backup at 10.211.55.34:9103 ...
Sending label command for Volume "Server-1" Slot 0 ...
3000 OK label. VolBytes=193 DVD=0 Volume="Server-1" Device="FileStorage-1" (/mnt/backup-1/bacula)
Catalog record for Volume "Server-1", Slot 0 successfully created.
Requesting to mount FileStorage-1 ...
3906 File device ""FileStorage-1" (/mnt/backup-1/bacula)" is always mounted.
*

메시지를 보면 "successfully created"라고 나온걸 봐서 제대로 생성됐음을 알 수 있다.  그럼 이제 본격적으로 백업을 해보자.  우리가 지정한 파일셋이 제대로 적용됐는지 확인부터 해보자.

*show fileset="Full Set"
FileSet: name=Full Set
O M
N
I /
N
E /var/lib/bacula
E /nonexistant/path/to/file/archive/dir
E /proc
E /tmp
E /.journal
E /.fsck
N
*

제대로 나온다.  이제 클라이언트들이 제대로 응답하는지 확인해볼 차례다.  FTP 서버를 확인해보자.

*status client="FTP Server"
Connecting to Client FTP Server at 10.211.55.34:9102

ftp-fd Version: 5.2.5 (26 January 2012) x86_64-pc-linux-gnu ubuntu 12.04
Daemon started 25-Jun-13 02:29. Jobs: run=0 running=0.
Heap: heap=270,336 smbytes=15,781 max_bytes=15,928 bufs=48 max_bufs=49
Sizeof: boffset_t=8 size_t=8 debug=0 trace=0
Running Jobs:
Director connected at: 25-Jun-13 02:29
No Jobs running.
====

Terminated Jobs:
====
*

제대로 응답한다.  만약 명령어를 입력하고 "즉시" 응답이 없으면 설정이 잘못된 거다.  이 경우 십중팔구는 DIR 이름과 패스워드가 달라서 생기는 거다.  클라이언트에 SSH로 접속해서 /etc/bacula/bacula-fd.conf 파일을 열고 Director {} 섹션의 Name 항목이 dbserver-dir로 되어있는지, 그리고 Passwordftpserver로 되어있는지 확인하자.

이제 백업할 준비가 다 끝났다.  백업을 진행해보자.

*run job="FTP Backup" fileset="Full Set" client="FTP Server" storage="Server Backup" level="Full"
Using Catalog "MyCatalog"
Run Backup job
JobName: FTP Backup
Level: Full
Client: FTP Server
FileSet: Full Set
Pool: User Data (From Job resource)
Storage: Server Backup (From command line)
When: 2013-06-25 04:55:23
Priority: 10
OK to run? (yes/mod/no): 

여기서 위의 내용을 자세히 보면, Pool이 User Data라고 되어있는 것을 볼 수 있다.  이것은 bacula-dir.conf 파일에 정의된 Job 항목에 Pool이 User Data로 되어있기 때문인데, 일단 우리는 유저 데이터를 백업하려는게 아니라 서버 자체를 백업하려고 하는 것이므로 이것을 수정해서 Server Pool을 이용하도록 하자.

OK to run? (yes/mod/no): mod
Parameters to modify:
  1: Level
  2: Storage
  3: Job
  4: FileSet
  5: Client
  6: When
  7: Priority
  8: Pool
  9: Plugin Options
Select parameter to modify (1-9): 8
The defined Pool resources are:
  1: Server
  2: User Data
Select Pool resource (1-2): 1
Run Backup job
JobName: FTP Backup
Level: Full
Client: FTP Server
FileSet: Full Set
Pool: Server (From User input)
Storage: Server Backup (From command line)
When: 2013-06-25 04:58:16
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=5
*

Job이 제대로 접수됐는지 DIR의 상태를 확인해보자.  참고로, 위의 예제에서 JobID가 5인 이유는 글쓴이가 테스트를 위해서 여러번 실행했다 취소했다를 반복해서 그런 것이니 신경쓰지 말자.

*status dir
dbserver-dir Version: 5.2.5 (26 January 2012) x86_64-pc-linux-gnu ubuntu 12.04
Daemon started 25-Jun-13 04:47. Jobs: run=2, running=0 mode=0,0
Heap: heap=405,504 smbytes=91,751 max_bytes=117,401 bufs=277 max_bufs=309

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 05:01
JobId Level Name Status
======================================================================
5 Full FTP_Backup.2013-06-25_05.03.07_03 is 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

====
You have messages.
*

메시지 중간을 보면 running이라고 나온다.  실행 중이다.  잘 되고있다는 말이다.  마지막에 보면 You have messages.라고 나오면서 메시지가 있다고 나온다.  메시지를 확인해보자.

*messages
25-Jun 05:03 dbserver-dir JobId 5: Start Backup JobId 5, Job=FTP_Backup.2013-06-25_05.03.07_03
25-Jun 05:03 dbserver-dir JobId 5: Using Device "FileStorage-1"
25-Jun 02:41 FTPServer-sd JobId 5: Volume "Server-1" previously written, moving to end of data.
25-Jun 02:41 FTPServer-sd JobId 5: Ready to append to end of Volume "Server-1" size=9594
25-Jun 02:41 ftp-fd JobId 5: /sys is a different filesystem. Will not descend from / into it.
25-Jun 02:41 ftp-fd JobId 5: /dev is a different filesystem. Will not descend from / into it.
25-Jun 02:41 ftp-fd JobId 5: /run is a different filesystem. Will not descend from / into it.
25-Jun 02:41 ftp-fd JobId 5: /mnt/backup-2 is a different filesystem. Will not descend from / into it.
25-Jun 02:41 ftp-fd JobId 5: /mnt/backup-1 is a different filesystem. Will not descend from / into it.
*

잘 읽어보면 특수 파일시스템, sys, dev, run 등은 백업하지 않는다고 써있다.  또한, 추가로 붙인 하드디스크 역시 다른 파일시스템이라고 백업하지 않겠단다.  이것을 백업하려면 FileSet에 Include항목을 이용하면 된다.  다만, 본 테스트 한정으로, 백업 볼륨이 저 위치에 저장되므로 그것을 유의해서 스스로 백업하는 일이 없도록 하자.  대충 써보면 다음과 같다고 본다.

Include {
  File = /
  File = /mnt/backup-1
}
Exclude {
  File = /mnt/backup-1/bacula
}

 

백업이 어떻게 진행되가는지 궁금하다.  이럴 때는 status dir을 해도 되고 그냥 엔터키만 쳐도 된다.  그냥 엔터키를 쳐보자.

*
You have messages.
*

메시지가 와있다.  messages를 입력하면 보여주는데, bconsole에서 autodisplay on을 입력하면 엔터키를 입력할 때마다 추가생성되는 메시지를 자동으로 보여준다.  이것을 이용해보자.

*autodisplay on
25-Jun 02:44 ftp-fd JobId 5: /media/cdrom is a different filesystem. Will not descend from / into it.
25-Jun 02:45 FTPServer-sd JobId 5: Job write elapsed time = 00:03:32, Transfer rate = 4.671 M Bytes/second
25-Jun 05:06 dbserver-dir JobId 5: Bacula dbserver-dir 5.2.5 (26Jan12):
Build OS: x86_64-pc-linux-gnu ubuntu 12.04
JobId: 5
Job: FTP_Backup.2013-06-25_05.03.07_03
Backup Level: Full
Client: "FTP Server" 5.2.5 (26Jan12) x86_64-pc-linux-gnu,ubuntu,12.04
FileSet: "Full Set" 2013-06-25 05:03:08
Pool: "Server" (From User input)
Catalog: "MyCatalog" (From Client resource)
Storage: "Server Backup" (From Pool resource)
Scheduled time: 25-Jun-2013 05:02:57
Start time: 25-Jun-2013 05:03:10
End time: 25-Jun-2013 05:06:45
Elapsed time: 3 mins 35 secs
Priority: 10
FD Files Written: 55,461
SD Files Written: 55,461
FD Bytes Written: 982,708,126 (982.7 MB)
SD Bytes Written: 990,268,085 (990.2 MB)
Rate: 4570.7 KB/s
Software Compression: None
VSS: no
Encryption: no
Accurate: no
Volume name(s): Server-1
Volume Session Id: 3
Volume Session Time: 1372163033
Last Volume Bytes: 992,591,109 (992.5 MB)
Non-fatal FD errors: 0
SD Errors: 0
FD termination status: OK
SD termination status: OK
Termination: Backup OK

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

*

입력을 해보니 벌써 전체 백업이 모두 끝났다.  여기서 가장 중요한 항목은 Termination: Backup OK인데, OK냐 아니냐에 따라서 이 job이 제대로 끝났는지 아닌지를 알 수 있기 때문이다.  위의 메시지를 자세히 읽어보면 별로 어려운 것이 없다.  총 기록된 용량이 얼마며 날짜(가상머신이라 날짜가 다른건 신경쓰지 말자), 파일셋 등 여러가지 정보를 보여준다.

이로서 백업실습이 끝났다.  참고로, 증분백업은 명령어

run job="FTP Backup" fileset="Full Set" client="FTP Server" storage="Server Backup" level="Full"

에서 

run job="FTP Backup" fileset="Full Set" client="FTP Server" storage="Server Backup" level="Incremental"

이라고 변경해주면 된다.  어떤 백업방식이 가능한지 알아보고 싶으신 분은 

run job="FTP Backup" fileset="Full Set" client="FTP Server" storage="Server Backup" level=

까지만 입력된 상태에서 Tab키를 입력하면 되겠다.

 

다음 편에서는 복원을 실습해보자.

 

블로그 이미지

jswlinux

Seowon Jung의 잡동사니 보관소

,