몇 가지 가정을 하고 실제 백업을 해 보자.
Amanda 패키지는 2절에서 설명한대로 configure의 사용자 옵션을 바꾸어서 설치한다.
테잎 장치가 제대로 작동한다.
테잎 장치는 IBM 3581 autoloader를 사용한다.
백업을 실행할 테잎서버의 사용자는 styoo이다.
SpaceWar라는 프로젝트의 데이타를 백업한다.
테잎서버의 호스트네임은 backupsvr이다.
프로젝트 SpaceWar의 데이타는 파일서버 gmfs1과 gmfs2에 저장된다.
gmfs1의 OS는 윈도우 2000 Server이고, gmfs2는 리눅스이다.
프로젝트 SpaceWar와 관련된 각 파일서버의 디렉토리는 아래와 같다.
gmfs1 : E:\SpaceWar1\Program-Sources gmfs1 : E:\SpaceWar1\Graphic-Sources gmfs2 : /SpaceWar2/Prototype gmfs2 : /SpaceWar2/Schedule |
gmfs1의 E:\SpaceWar1 디렉토리를 backupsvr의 /SpaceWar1디렉토리에 SMB 마운트한다.
파일서버와 테잎서버는 서로 호스트네임을 알 수 있도록 /etc/hosts 파일에 기록해 두는 것이 좋다.
mailto "styoo" dumpuser "styoo" etimeout 3600 dtimeout 3600 tapedev "/dev/nst0" tpchanger "mtx-changer" tapetype IBM-LTO columnspec "HostName=0:13,Disk=1:40,OrigKB=1:9,OutKB=1:9,DumpRate=1:7,TapeRate=1:7" holdingdisk hd1 { comment "main holding disk" directory "/backup-image/Image" use -10Mb chunksize 0 } define tapetype IBM-LTO { comment "just produced by tapetype program" length 101376 mbytes filemark 0 kbytes speed 13500 kps } define dumptype global { program "GNUTAR" compress server fast index yes record yes } |
autoloader를 구동하는데 사용할 mtx-changer 스크립트는 mtx 패키지에 포함되어 있는 것을 사용하였으나, IBM 3581 autoloader에 적용하기에는 일부 작동에 문제가 있어 필자가 일부를 수정하였다. 수정된 스크립트는 에 있으니 10절을 참고하기 바란다.
includefile "/etc/amanda/amanda.conf" org "SpaceWar" inparallel 4 runtapes 2 dumpcycle 4 weeks runspercycle 4 tapecycle 4 tapes maxdumps 4 labelstr "^SpaceWar-[0-9][0-9][0-9]*$" infofile "/var/lib/amanda/SpaceWar/curinfo" logdir "/var/log/amanda/SpaceWar/log" indexdir "/var/lib/amanda/SpaceWar/index" tapelist "/var/lib/amanda/SpaceWar/tapelist" define dumptype always-full { global comment "Full dump of this filesystem always" priority high dumpcycle 0 } define dumptype incr-only { global comment "Incremental dump only" priority high strategy nofull } |
localhost /SpaceWar1/Program-Sources always-full localhost /SpaceWar1/Graphic-Sources always-full gmfs2 /SpaceWar2/Prototype always-full gmfs2 /SpaceWar2/Schedule always-full |
/Spacewar1의 하위 디렉토리는 윈도우 2000 서버인 gmfs1에 있으므로 samba를 이용하여 백업해야 한다. amanda는 윈도우 머신의 데이타를 백업하기 위해 smbclient를 사용하여 백업을 진행한다. 그러나 그렇게 하지 않고, 윈도우의 디스크를 테잎서버에 SMB 마운트하여 마치 로컬디스크를 백업하듯이 할 수도 있다. 여기서는 SMB 마운트하여 로컬디스크를 백업하듯이 할 것이다. samba를 이용하여 백업을 진행한다면, localhost를 gmfs1으로 바꾸고 /etc/amandapass 파일에 공유이름과 해당 공유를 액세스 할 수 있는 사용자 그리고 암호를 적어주어야 한다. 그 포맷은 Amanda man page를 참고하기 바란다.
백업을 진행할 사용자는 styoo이며 관련된 파일에 대한 쓰기 권한이 있어야 함은 두 말할 나위도 없다. /etc/amanda디렉토리 및 그 하위 디렉토리와 파일에 대한 읽기쓰기 권한이 styoo에게 있어야 할 것이다. 뿐만 아니라, /var/lib/amanda 디렉토리 및 그 하위의 파일들 그리고 /var/log/amanda 디렉토리 및 그 하위의 파일들에 대한 읽기쓰기 권한이 필요하다. 또한, /dev/nst0, /dev/sg0에 대한 읽기쓰기 권한도 당연히 있어야 할 것이다.
이제, 백업을 진행해 보자. Amanda를 설치하고 위와 같이 설정을 끝마친 후 Amanda 명령어를 이용하여 백업을 진행할 때 흔히 발생할 수 있는 에러 상황도 함께 취급할 것이다.
테잎 장치에 빈 테잎을 하나 넣고 amlabel 명령으로 테잎에 라벨을 붙이자. -f 옵션을 붙여서 강제로 라벨을 써 넣도록 하자.
$ amlabel -f SpaceWar SpaceWar-001 rewinding, reading label, not an amanda tape rewinding, writing label SpaceWar-001, checking label amlabel: couldn't write tapelist: No such file or directory |
테잎에 라벨을 써 넣은 후, amadmin 명령으로 사용할 테잎 목록을 살펴보자.
$ amadmin SpaceWar tape The next Amanda run should go onto a new tape. The next Amanda run should go onto a new tape. |
0 SpaceWar-004 reuse 0 SpaceWar-003 reuse 0 SpaceWar-002 reuse 0 SpaceWar-001 reuse |
$ amadmin SpaceWar tape The next Amanda run should go onto tape SpaceWar-001 or a new tape. The next Amanda run should go onto tape SpaceWar-002 or a new tape. |
amcheck 명령으로 설정에 이상이 없는지 확인해 보자. 데비안의 경우, amanda 명령어들이 /usr/sbin 디렉토리에 있는데 amcheck 명령의 실행 권한이 root와 backup에게만 있을 수도 있으니 실행 권한을 추가해 주어야 할 것이다.
$ amcheck SpaceWar ERROR: program /usr/lib/amanda/planner: not executable Holding disk /backup-image/Image: 6636356 KB disk space available, using 6626116 KB ERROR: log dir /var/log/amanda/SpaceWar: not writable NOTE: skipping tape-writable test Tape SpaceWar-001 label ok NOTE: info dir /var/lib/amanda/SpaceWar/curinfo: does not exist NOTE: it will be created on the next run NOTE: index dir /var/lib/amanda/SpaceWar/index: does not exist Server check took 0.010 seconds Amanda Backup Client Hosts Check -------------------------------- ERROR: gmfs2: [access as styoo not allowed from styoo@backupsvr] amandahostsauth failed WARNING: localhost: selfcheck request timed out. Host down? Client check: 2 hosts checked in 30.018 seconds, 2 problems found |
"ERROR: program /usr/lib/amanda/planner: not executable" 여기서 planner라는 것은 amdump 명령어가 실행된 후 amdump의 부름을 받고 실행되는 명령어이다. 이 외에도 몇 가지 다른 명령어가 있는데 데비안의 경우, 이들 명령어는 /usr/lib/amanda 디렉토리에 존재한다. 실행 권한이 root 또는 backup에게만 있을 수 있으니 다른 사용자에게 실행 권한이 없는 명령어를 찾아서 실행 권한을 부여해야 할 것이다.
"ERROR: log dir /var/log/amanda/SpaceWar: not writable" 이것은 SpaceWar 디렉토리가 없기 때문이니 디렉토리를 만들어 준다. 그 밑에 표시된 curinfo와 index가 없다는 메세지도 마찬가지로 /var/lib/amanda 디렉토리 밑에 SpaceWar를 만들어 준다.
"ERROR: gmfs2: [access as styoo not allowed from styoo@backupsvr] amandahostsauth failed" 이 메세지는 backupsvr의 사용자 styoo에게 파일서버 gmfs2(리눅스 머쉰임)의 amandad에 접근할 권한이 없기 때문에 발생한다. gmfs2의 /etc/amandahosts 파일에
backupsvr styoo |
"WARNING: localhost: selfcheck request timed out. Host down?" 이 메세지는 amandad(Amanda 데몬)가 다른 사용자의 권한으로 실행되었기 때문이다. /etc/inetd.conf을 열어보면 아래와 같은 내용이 있을 것이다.
amanda dgram udp wait backup /usr/sbin/tcpd /usr/lib/amanda/amandad amandaidx stream tcp nowait backup /usr/sbin/tcpd /usr/lib/amanda/amindexd amidxtape stream tcp nowait backup /usr/sbin/tcpd /usr/lib/amanda/amidxtaped |
위 문제가 해결되면 다음과 같은 에러가 발생할 수도 있다. "ERROR: localhost: [access as styoo not allowed from styoo@localhost] open of /home/styoo/.amandahosts failed" 이것은 말 그대로 /home/styoo/.amandahosts을 열 수 없다는 뜻이다. /etc/amandahosts 파일을 /home/styoo/.amandahosts에 링크를 시켜주면 된다.
위 문제가 해결되면 다음과 같은 에러가 발생할 수도 있다. "ERROR: localhost: [access as styoo not allowed from styoo@localhost] amandahostsauth failed" 이것은 gmfs2에 접근할 수 없다는 에러와 유사한 것으로 테잎서버(backupsvr)의 /etc/amandahosts 파일에
localhost styoo |
autoloader와 같은 미디어 체인저가 없는 경우, 다음과 같은 경고 메세지가 나타날 수도 있다. "WARNING: if a tape changer is not available, runtapes must be set to 1" 이것은 autoloader와 같은 미디어 체인저가 없기 때문에 runtape 파라메타 값이 1로 세팅되어야 한다는 뜻이다. 현재는 2로 설정되어 있다. 이 경고는 무시해도 좋다.
amcheck 명령으로 이상이 없는 것을 확인하였으면, 이제 백그라운드로 amdump 명령을 실행시켜 백업을 해 보자.
$ amdump SpaceWar & |
$ amstatus SpaceWar Using /var/log/amanda/SpaceWar/amdump from 토 9월 14 14:51:50 KST 2002 localhost:/SpaceWar1/Program-Sources getting estimate localhost:/SpaceWar1/Graphic-Sources getting estimate gmfs2:/SpaceWar2/Prototype getting estimate gmfs2:/SpaceWar2/Schedule getting estimate SUMMARY part real estimated size size partition : 4 estimated : 0 0k failed : 0 0k ( 0.00%) wait for dumping: 0 0k ( 0.00%) dumping to tape : 0 0k ( 0.00%) dumping : 0 0k 0k ( 0.00%) ( 0.00%) dumped : 0 0k 0k ( 0.00%) ( 0.00%) wait for writing: 0 0k 0k ( 0.00%) ( 0.00%) writing to tape : 0 0k 0k ( 0.00%) ( 0.00%) failed to tape : 0 0k 0k ( 0.00%) ( 0.00%) taped : 0 0k 0k ( 0.00%) ( 0.00%) all dumpers active taper idle |
$ amstatus SpaceWar Using /var/log/amanda/SpaceWar/amdump from 토 9월 14 15:06:33 KST 2002 localhost:/SpaceWar1/Program-Sources 0 no estimate localhost:/SpaceWar1/Graphic-Sources 0 no estimate gmfs2:/SpaceWar2/Prototype 0 [dump larger than tape, but cannot incremental dump new disk] gmfs2:/SpaceWar2/Schedule 0 14585k dumping 4832k ( 33.13%) (15:06:36) SUMMARY part real estimated size size partition : 4 estimated : 2 14585k failed : 3 0k ( 0.00%) wait for dumping: 0 0k ( 0.00%) dumping to tape : 0 0k ( 0.00%) dumping : 1 4832k 14585k ( 33.13%) ( 6.42%) dumped : 0 0k 0k ( 0.00%) ( 0.00%) wait for writing: 0 0k 0k ( 0.00%) ( 0.00%) writing to tape : 0 0k 0k ( 0.00%) ( 0.00%) failed to tape : 0 0k 0k ( 0.00%) ( 0.00%) taped : 0 0k 0k ( 0.00%) ( 0.00%) 3 dumpers idle : start-wait taper idle network free kps: 270 holding space : 6611460k ( 99.78%) |
그리고 윈도우 서버 gmfs1의 디렉토리를 SMB 마운트한 디렉토리는 "no estimate" 라고 되어 있다. 이 문제는 대개는 퍼미션 문제이다. Amanda 패키지를 빌드할 때 styoo라는 사용자로 옵션을 주었는데, 막상 실행할 때는 엉뚱한 사용자로 amdump를 실행했기 때문이다. 제공되는 패키지 그대로 설치했다면 root 또는 backup 사용자의 권한으로 백업을 실행해야 할 것이다.
웬만한 에러 상황은 체크를 했으니 백업이 잘 완료되었다고 하자. 그리고 1 개의 테잎을 백업에 사용했다고 하자. 이제 다시 한 번 amadmin 명령으로 사용할 수 있는 테잎 목록을 살펴보자.
$ amadmin SpaceWar tape The next Amanda run should go onto tape SpaceWar-002 or a new tape. The next Amanda run should go onto tape SpaceWar-003 or a new tape. |
amadmin SpaceWar no-reuse SpaceWar-001 |
백업된 데이타를 테잎에 쓰는 중에 에러가 발생한다면 다음 테잎에 데이타를 다시 써 넣으려 할 것이다. 그러나 사용할 다음 테잎이 없다면 백업 데이타는 로컬디스크에 남게되며 백업은 종료된다. 이런 경우에는 새로운 테잎을 준비하여 라벨을 붙인 다음, amflush 명령으로 로컬디스크의 데이타를 테잎에 옮겨 놓을 수 있다.
$ amflush SpaceWar |
$ amcleanup SpaceWar |
복원을 해 보자. 복원은 amrecover와 amrestore 두 가지를 이용할 수 있다. 여기서는 amrecover를 사용하기로 한다. 복원은 root의 권한으로 실행되어야 한다.
gmfs2의 /SpaceWar2/Schedule 디렉토리 밑에 있던 200206-Prog 이란 디렉토리와 200206-Mail 디렉토리를 하위 디렉토리를 포함하여 모두 복원한다고 하자. /tmp에 복구한다고 가정하자.
# cd /tmp # amrecover SpaceWar -d /dev/nst0 |
amrecover> |
220 backupsvr AMANDA index server (2.4.2p2) ready. 500 Access not allowed: [access as styoo not allowed from root@localhost] amandahostsauth failed |
localhost root |
amrecover> sethost gmfs2 amrecover> setdisk /SpaceWar2/Schedule |
amrecover> cd 200206-Prog amrecover> add * amrecover> cd .. amrecover> cd 200206-Mail amrecover> add * |
amrecover> extract |
여기까지는 테잎서버의 테잎 장치를 이용하여 복원하는 방법이다. 그러나 이런 경우가 있을 수도 있다. 미디오 호환이 가능한 두 대의 테잎 장치를 각각 다른 리눅스 서버에 장착하여 한 대는 백업 전용으로, 다른 한 대는 복원 전용으로 사용하고자 하는 경우도 있을 것이다. 이제 백업 전용 서버에서 백업한 것을 복원 전용 서버에서 백업하는 경우를 살펴보자.
백업 전용 서버의 호스트네임은 backupsvr라 하고, 복원 전용 서버의 호스트 네임은 restoresvr이라 하자. 그리고 /SpaceWar2/Schedule 을 /tmp에 복원한다고 가정하자.
# cd /tmp # amrecover SpaceWar -s backupsvr -d /dev/nst0 |
이것으로 복원에 대한 것도 대략 알아 보았다. 더 자세한 것은 Amanda man page를 참고하면서 그리고 실제로 사용하면서 하나씩 익히는 것이 최선의 방법인 듯 싶다.
dump라는 백업 프로그램은 0에서 9까지의 백업 레벨을 지원한다. Amanda가 내부적으로 사용하는 백업 프로그램은 dump 또는 tar이다. Amanda도 0에서 9까지의 백업 레벨을 제공하며 백업 레벨은 사용자의 설정을 근거로 Amanda가 스스로 결정한다.
백업 레벨 0은 전체백업을 의미하며 백업 레벨 1은 전체 백업 이후 변경된 내용에 대한 백업을 뜻한다. 백업 레벨 2는 백업 레벨 1 이후 변경된 내용에 대한 백업이다. 나머지 백업 레벨도 비슷하게 생각하면 될 것이다.
필자는 한 달에 1회 전체 백업을 하고 주간 단위로 레벨 1의 백업을 실시한다. 9월 첫째 일요일에 전체 백업을 실시했다면 둘째 일요일에 백업할 내용은 전체 백업 이후 변경, 추가된 파일들일 것이다. 세번째 일요일에 백업할 내용도 레벨 1의 백업이므로 전체 백업 이후 변경, 추가된 파일들일 것이다. 따라서 세번째 일요일에 증분 백업을 하게되면 두번째 일요일에 증분 백업한 내용은 필요없게 되며 그 때 사용한 테잎은 재활용이 가능하게 된다.
강제로 레벨 1의 백업을 실시하기 위해서는 8.2절에서 정의한 dumptype 중에서 incr-only를 사용하면 된다.
localhost /SpaceWar1/Program-Sources incr-only localhost /SpaceWar1/Graphic-Sources incr-only gmfs2 /SpaceWar2/Prototype incr-only gmfs2 /SpaceWar2/Schedule incr-only |
이제 amcheck 명령으로 이상 유무를 확인한 후, amdump 명령으로 백업을 실행시키면 될 것이다.
Amanda는 백업을 진행하는 중에 로컬디스크(holdingdisk)의 공간이 부족하면 공간에 여유가 생길 때까지 일부 디렉토리에 대한 백업을 일시 중단하고 있다가, 공간에 여유가 생기면 그때 다시 백업을 진행한다. 이때 시간의 지연으로 인해 백업에 걸리는 시간이 늘어나게 된다. 이 경우는 일부 디렉토리를 테잎에 바로 쓰는 것이 유리할 수도 있다. writetotape이라는 dumptype을 정의하고 테잎에 바로 쓰기를 원하는 디렉토리의 dumptype을 writetotape으로 지정하면 될 것이다.
define dumptype wtritetotape { global comment "write directly to tape" priority high dumpcycle 0 holdingdisk no } |
localhost /SpaceWar1/Program-Sources writetotape localhost /SpaceWar1/Graphic-Sources always-full gmfs2 /SpaceWar2/Prototype always-full gmfs2 /SpaceWar2/Schedule always-full |
백업할 필요가 없는 파일이 있을 수도 있다. 이 때는 dumptype에 exclude 또는 exclude list를 지정하여 해결할 수 있다. exclude list에 대해 알아보자. dumptype은 아래와 같은 모양이 될 것이다.
define dumptype always-full { global comment "write directly to tape" priority high dumpcycle 0 exclude list "/etc/amanda/SpaceWar/exclude-files" } |
AUTOEXEC.BAT NTDETECT.COM arcsetup.exe ntldr WINNT Documents and Settings System Volume Information arcldr.exe bootfont.bin RECYCLED Recycled *.SYS *.sys *.ini |