[AIX 운영 체제와 장치 관리 3] 시스템 백업 관리 — backup·restore, 원격 아카이브, libc.a 복구, 부트 이미지 재생성, 스냅숏, 압축
https://archive.horanglab.com/posts/aix-osdev-3
핵심 정리
backup -i는 이름 기준(개별 파일),backup -레벨 파일시스템은 i-node 기준(0은 전체, 1~9는 증분, 복원하면 조각 모음됨)입니다. i-node 기준은 UID·GID가 65535를 넘는 파일을 제대로 다루지 못하므로 그때는 이름 기준으로 합니다. 사용 중인 파일 시스템은 마운트 해제하고, 백업한 방식과 같은 방식으로 복원합니다.- 복원은
restore -T(목록),restore -x -v(전체),restore -xv 파일,restore -xdv 디렉터리,smit restore. 원격 테이프는.rhosts를 만들고rsh로dd of=/dev/rmt0 bs=블록크기에 파이프로 보냅니다(9트랙·0.25인치 512, 8 mm·4 mm 1024).rdump·rrestore도 씁니다. - libc.a를 잃으면
LIBPATH=/usr/ccs/lib:/usr/lib로 명령을 살리고ln -s /usr/ccs/lib/libc.a /usr/lib/libc.a로 링크를 되살립니다. 파일 자체가 지워졌으면 같은 수준의 mksysb로 유지 보수 모드에 들어가restbyname으로 되찾습니다. - 부트 이미지가 손상되면 다시 부팅하지 말고
bosboot -a -d /dev/hdisk0. 설치 매체로 유지 보수 모드에 들어가서도 할 수 있습니다. - 온라인 백업: 미러된 JFS는
chfs -a splitcopy=/jfsstaticcopy /home/xyz(되돌리기는 rmfs), JFS2는backsnap -m /tmp/snapshot -s size=16M -if/dev/rmt0 /home/abc/test(외부),backsnap -n 이름(내부,.snapshot아래). 압축은 compress(.Z, Lempel-Ziv)와 pack(.z, Huffman)이며 원본보다 50~100% 여유 공간이 필요합니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1에서 JFS2 외부·내부 스냅숏 절이 더해짐) |
| 원문 | Operating system and device management — 5.3판 142164쪽, 6.1판 2538쪽 |
| 파일 | /dev/rmt0, /dev/rfd0, /etc/dumpdates, .rhosts, /usr/lib/libc.a, /usr/ccs/lib/libc.a, bosinst.data |
| 관련 명령어 | backup, restore, rrestore, rdump, rsh, dd, tctl, cpio, tar, restbyname, bosboot, chfs, rmfs, backsnap, snapshot, compress, pack, uncompress, unpack, zcat |
시스템을 백업하고 시스템 백업을 복원하는 방법은 여러 가지입니다.
사용자 파일이나 파일 시스템 백업
파일과 파일 시스템을 백업하는 절차는 두 가지입니다. SMIT 빠른 경로 smit backfile이나 smit backfilesys, 그리고 backup 명령입니다.
- 사용 중일 수 있는 파일 시스템을 i-node 기준으로 백업한다면 불일치를 막으려고 먼저 마운트 해제합니다. 주의: 마운트된 파일 시스템을 백업하려 하면 경고 메시지가 나옵니다. backup 명령은 계속되지만 파일 시스템에 불일치가 생길 수 있습니다. 이 경고는 루트(
/) 파일 시스템에는 해당하지 않습니다. - 오류를 막으려면 백업 장치를 최근에 청소했는지 확인합니다.
사용자 파일과 파일 시스템을 백업하려면 Web-based System Manager나 SMIT 빠른 경로 smit backfile이나 smit backfilesys를 쓸 수 있습니다.
로컬 시스템의 /home처럼 작은 파일 시스템 하나를 이름 기준으로 백업할 때는 SMIT 인터페이스를 쓸 수 있습니다. SMIT는 backup 명령이 제공하는 형식 말고는 다른 형식의 아카이브를 만들 수 없다는 점에 유의합니다. 또 backup 명령의 모든 플래그를 SMIT로 쓸 수 있는 것도 아닙니다. 백업 중에 테이프나 디스크가 여러 개 필요하면 SMIT가 멈출 수 있습니다. 자세한 정보는 Commands Reference, Volume 1의 backup 명령 설명을 봅니다.
크고 여러 개인 파일 시스템을 백업하려면 backup 명령을 씁니다. 레벨 번호로 백업할 데이터 양을 제어할 수 있습니다(전체는 0, 증분은 1~9). 백업에 레벨 번호를 지정하는 방법은 backup 명령뿐입니다.
backup 명령은 다음 두 백업 형식 가운데 하나로 사본을 만듭니다.
-i플래그로 이름 기준으로 백업한 특정 파일-Level과FileSystem매개변수로 i-node 기준으로 백업한 파일 시스템 전체. 파일 시스템은 백업에서 복원할 때 조각 모음됩니다.
주의: i-node 기준 백업은 사용자 ID(UID)나 그룹 ID(GID)가 65535보다 큰 파일에서 올바르게 동작하지 않습니다. 이런 파일은 UID나 GID가 잘린 채 백업되므로 복원하면 UID나 GID 속성이 틀립니다. 이 경우 이름 기준으로 백업해야 합니다.
| 작업 | SMIT 빠른 경로 | 명령이나 파일 |
|---|---|---|
| 사용자 파일 백업 | smit backfile |
1. 사용자 계정으로 로그인합니다. 2. 백업: find . -print 출력을 backup -ivf /dev/rmt0으로 파이프 |
| 사용자 파일 시스템 백업 | smit backfilesys |
1. 백업할 파일 시스템을 마운트 해제합니다. 예: umount all이나 umount /home /filesys1 2. 파일 시스템을 검사합니다. 예: fsck /home /filesys1 3. i-node 기준으로 백업합니다. 예: backup -5 -uf/dev/rmt0 /home/libr 4. 다음 명령으로 파일을 확인합니다: restore -t |
참고: 이 명령이 오류 메시지를 내면 백업 전체를 다시 해야 합니다.
(원문 표의 명령은 PDF에서 칸이 흩어져 코드 조각으로 남았습니다. 조각은 다음과 같습니다.)
/dev/rmt0
/filesys1
/home /filesys1
-uf/dev/rmt0 /home/libr
관련 개념:
- 시스템 백업: 시스템을 쓰기 시작하면 다음으로 파일 시스템, 디렉터리, 파일을 백업해야 합니다. 파일 시스템을 백업하면 하드 디스크가 고장 났을 때 파일이나 파일 시스템을 복원할 수 있습니다. 정보를 백업하는 방법은 여러 가지입니다.
백업한 파일 복원
데이터를 올바르게 백업했으면, 쓴 백업 명령 종류에 따라 여러 방법으로 데이터를 복원할 수 있습니다.
백업이나 아카이브를 올바르게 복원하려면 그것을 어떻게 만들었는지 알아야 합니다. 각 백업 절차는 데이터 복원에 관한 정보를 줍니다. 예를 들어 backup 명령을 쓰면 파일 시스템 기준이나 이름 기준으로 백업을 지정할 수 있습니다. 그 백업은 만든 방식대로, 곧 파일 시스템 기준이나 이름 기준으로 복원해야 합니다. backup 명령에 관한 정보는 backup을 봅니다.
백업한 데이터를 복원하는 명령은 여러 가지입니다.
| 명령 | 설명 |
|---|---|
| restore | backup 명령으로 만든 파일을 복사해 옵니다. 이 명령의 사용법은 아래 절을 봅니다. |
| rrestore | 원격 기계에서 백업한 파일 시스템을 로컬 기계로 복사해 옵니다. 자세한 정보는 rrestore를 봅니다. |
| cpio | 파일을 아카이브 저장소로 복사하거나 아카이브에서 복사해 옵니다. 자세한 정보는 cpio를 봅니다. |
| tar | tar 아카이브를 만들거나 다룹니다. 자세한 정보는 tar를 봅니다. |
| pax | (POSIX를 따르는 아카이브 유틸리티) tar와 cpio 아카이브를 읽고 씁니다. 자세한 정보는 pax를 봅니다. |
다음 절은 restore와 smit 명령을 설명합니다.
주:
- 파일은 백업한 방법과 같은 방법으로 복원해야 합니다. 예를 들어 파일 시스템을 이름 기준으로 백업했으면 이름 기준으로 복원해야 합니다.
- 디스켓이 여러 장 필요하면 restore 명령은 끼워진 디스켓을 읽고, 새 디스켓을 넣으라고 묻고, 응답을 기다립니다. 새 디스켓을 넣은 뒤 Enter 키를 눌러 파일 복원을 계속합니다.
restore 명령으로 파일 복원
restore 명령으로 backup 명령이 쓴 파일을 읽어 로컬 시스템에 복원합니다.
다음 예를 봅니다.
- 이전에 백업한 파일의 이름을 나열하려면 다음을 입력합니다.
restore -T
정보는 기본 백업 장치 /dev/rfd0에서 읽습니다. 개별 파일을 백업했으면 파일 이름만 나옵니다. 파일 시스템 전체를 백업했으면 i-node 번호도 나옵니다.
- 파일을 주 파일 시스템에 복원하려면 다음을 입력합니다.
restore -x -v
-x 플래그는 백업 매체에서 모든 파일을 꺼내 파일 시스템의 제자리에 복원합니다. -v 플래그는 파일을 하나씩 복원할 때마다 진행 보고를 보여 줍니다. 파일 시스템 백업을 복원하고 있으면 파일이 i-node 번호와 함께 나옵니다. 그렇지 않으면 이름만 나옵니다.
/home/mike/manual/chap1파일을 복사하려면 다음을 입력합니다.
restore -xv /home/mike/manual/chap1
이 명령은 백업 매체에서 /home/mike/manual/chap1 파일을 꺼내 복원합니다. /home/mike/manual/chap1 파일은 restore -T 명령이 보여 줄 수 있는 이름이어야 합니다.
manual이라는 디렉터리의 모든 파일을 복사하려면 다음을 입력합니다.
restore -xdv manual
이 명령은 manual 디렉터리와 그 안의 파일을 복원합니다. 디렉터리가 없으면 복원할 파일을 담을 manual 디렉터리를 현재 디렉터리에 만듭니다.
전체 구문은 Commands Reference, Volume 4의 restore 명령을 봅니다.
smit 명령으로 파일 복원
smit 명령으로 restore 명령을 실행해, backup 명령이 쓴 파일을 읽어 로컬 시스템에 복원합니다.
- 프롬프트에서 다음을 입력합니다.
smit restore
- Target DIRECTORY 필드에 입력합니다. 복원한 파일을 둘 디렉터리입니다.
- BACKUP device or FILE 필드로 가서 출력 장치 이름을 입력합니다. raw 자기 테이프 장치의 예는 다음과 같습니다.
/dev/rmt0
장치를 쓸 수 없으면 다음과 비슷한 메시지가 나옵니다.
Cannot open /dev/rmtX, no such file or directory.
이 메시지는 /dev 디렉터리에 rmtX 파일이 없어 시스템이 장치 드라이버에 닿을 수 없다는 뜻입니다. available 상태인 항목만 /dev 디렉터리에 있습니다.
4. NUMBER of blocks to read in a single input 필드는 기본값을 권합니다.
5. Enter를 눌러 지정한 파일 시스템이나 디렉터리를 복원합니다.
원격 아카이브 만들기
원격 테이프 장치에 파일을 아카이브하는 절차입니다.
실행 중인 AIX 시스템은 원격 테이프 장치를 로컬처럼 마운트할 수 없지만, rsh 명령으로 원격 기계의 테이프 장치에 데이터를 보낼 수 있습니다. 다음 절차는 테이프 한 개에만 씁니다. 여러 테이프에 걸친 아카이브에는 전문 응용 소프트웨어가 필요합니다.
다음 절차에서는 다음을 가정합니다.
| 항목 | 설명 |
|---|---|
| blocksize | 대상 테이프 장치의 블록 크기 |
| remotehost | 대상 시스템(테이프 드라이브가 있는 시스템)의 이름 |
| sourcehost | 원본 시스템(아카이브하는 시스템)의 이름 |
| /dev/rmt0 | 원격 테이프 장치의 이름 |
| pathname | 필요한 디렉터리나 파일의 전체 경로 이름 |
다음 지시에서는 로컬과 원격 사용자 모두 root라고 가정합니다.
- 원격 기계에 접근할 수 있는지 확인합니다. 원본 기계는 테이프 드라이브가 있는 시스템에 접근할 수 있어야 합니다. (대상 시스템에는 그 시스템에 정의된 아무 사용자로나 접근할 수 있지만, 다음 단계 가운데 상당수를 하려면 그 사용자 이름에 root 권한이 있어야 합니다.)
- 좋아하는 편집기로 대상 시스템의
/(root) 디렉터리에 원본 시스템이 대상 시스템에 접근하게 하는.rhosts파일을 만듭니다. 이 파일에 허가할 호스트 이름과 사용자 ID를 더해야 합니다..rhosts파일에 쓸 원본 기계의 이름을 알아내려면 다음 명령을 쓸 수 있습니다.
host SourceIPaddress
이 예에서는 .rhosts 파일에 다음 줄을 더한다고 가정합니다.
sourcehost.mynet.com root
- 파일을 저장한 뒤 다음 명령으로 권한을 바꿉니다.
chmod 600 .rhosts
- rsh 명령으로 원본 기계에서 접근을 시험합니다. 예:
rsh remotehost
모두 올바르게 설정되었으면 원격 기계의 셸 접근을 얻습니다. 사용자 이름을 묻는 로그인 프롬프트가 나오면 안 됩니다. exit을 입력해 이 시험 셸에서 로그아웃합니다.
5. 알맞은 테이프 장치 블록 크기를 정합니다. 권장 값은 다음과 같습니다.
| 매체 | 블록 크기 |
|---|---|
| 9트랙이나 0.25인치 매체 | 512 |
| 8 mm나 4 mm 매체 | 1024 |
테이프 장치의 현재 블록 크기를 확인하려면 tctl 명령을 씁니다. 예:
tctl -f /dev/rmt0 status
테이프 블록 크기를 바꾸려면 chdev 명령을 씁니다. 예:
chdev -l rmt0 -a block_size=1024
- 다음 방법 가운데 하나로 아카이브를 만듭니다.
이름 기준 백업
이름 기준 백업 아카이브를 원격으로 만들려면 다음 명령을 씁니다.
find pathname -print | backup -ivqf- | rsh remotehost \
"dd of=/dev/rmt0 bs= blocksize conv=sync"
i-node 기준 백업
i-node 기준 백업 아카이브를 원격으로 만들려면 먼저 파일 시스템을 마운트 해제한 뒤 backup 명령을 씁니다. 예:
umount /myfs
backup -0 -uf- /myfs | rsh remotehost \
"dd of=/dev/rmt0 bs= blocksize conv=sync"
아카이브를 만들어 원격 테이프에 복사
아카이브를 만들어 원격 테이프 장치에 복사하려면 다음 명령을 씁니다.
find pathname -print | cpio -ovcB | rsh remotehost \
"dd ibs=5120 obs= blocksize of=/dev/rmt0"
tar 아카이브 만들기
tar 아카이브를 원격으로 만들려면 다음 명령을 씁니다.
tar -cvdf- pathname | rsh remotehost \
"dd of=/dev/rmt0 bs= blocksize conv=sync"
원격 덤프 만들기
/myfs 파일 시스템의 원격 덤프를 만들려면 다음 명령을 씁니다.
rdump -u -0 -f remotehost :/dev/rmt0 /myfs
-u 플래그는 /etc/dumpdates 파일의 현재 백업 레벨 기록을 갱신하라고 알립니다. -0은 Level 플래그 설정입니다. 백업 레벨 0은 /myfs 디렉터리의 모든 파일을 백업한다는 뜻입니다. 자세한 정보는 Commands Reference, Volume 4의 rdump 명령 설명을 봅니다.
- 다음 방법 가운데 하나로 원격 아카이브를 복원합니다.
이름 기준 백업 복원
이름 기준 원격 백업 아카이브를 복원하려면 다음 명령을 씁니다.
rsh remotehost "dd if=/dev/rmt0 bs= blocksize " | restore \
-xvqdf- pathname
i-node 기준 백업 복원
i-node 기준 원격 백업 아카이브를 복원하려면 다음 명령을 씁니다.
rsh remotehost "dd if=/dev/rmt0 bs= blocksize " | restore \
-xvqf- pathname
원격 cpio 아카이브 복원
cpio 명령으로 만든 원격 아카이브를 복원하려면 다음 명령을 씁니다.
rsh remotehost "dd if=/dev/rmt0 ibs= blocksize obs=5120" | \
cpio -icvdumB
tar 아카이브 복원
원격 tar 아카이브를 복원하려면 다음 명령을 씁니다.
rsh remotehost "dd if=/dev/rmt0 bs= blocksize " | tar -xvpf- pathname
원격 덤프 복원
/myfs 파일 시스템의 원격 덤프를 복원하려면 다음 명령을 씁니다.
cd /myfs
rrestore -rvf remotehost :/dev/rmt0
백업 이미지에서 사용자 파일 복원
실수로 망가진 파일을 백업 이미지에서 복원해야 한다면 가장 어려운 문제는 어느 백업 테이프에 그 파일이 있는지 알아내는 것입니다. restore -T 명령으로 아카이브의 내용을 나열할 수 있습니다. 사용자의 다른 파일을 실수로 덮어쓰지 않도록 파일을 /tmp 디렉터리에 복원하는 것이 좋습니다.
장치가 연결되어 있고 쓸 수 있는지 확인합니다. 쓸 수 있는지 확인하려면 다음을 입력합니다.
lsdev -C | pg
백업 전략에 증분 백업이 들어 있으면, 파일이 마지막으로 바뀐 때를 사용자에게 알아내는 것이 도움이 됩니다. 그래야 어느 증분 백업에 파일이 있는지 정할 수 있습니다. 이 정보를 얻을 수 없거나 틀리면 증분 백업을 거꾸로(7, 6, 5, …) 찾기 시작합니다. 증분 파일 시스템 백업에서는 restore 명령의 -i 플래그(대화식 모드)가 잃어버린 파일을 찾고 복원하는 데 아주 유용합니다. (대화식 모드는 /home 파일 시스템 백업에서 개별 사용자의 계정을 복원하는 데도 유용합니다.)
다음 표의 절차는 디렉터리나 파일 시스템의 레벨 0(전체) 복원을 하는 방법을 설명합니다.
| 작업 | SMIT 빠른 경로 | 명령이나 파일 |
|---|---|---|
| 개별 사용자 파일 복원 | smit restfile |
restore 명령을 봅니다. |
| 사용자 파일 시스템 복원 | smit restfilesys |
1. mkfs /dev/hd1 2. mount /dev/hd1 /filesys 3. cd /filesys 4. restore -r |
| 사용자 볼륨 그룹 복원 | smit restvg |
restvg -q 명령을 봅니다. |
관련 작업:
- 손상된 파일 시스템 고치기: 파일 시스템 디렉터리 구조의 i-node나 슈퍼블록 정보가 손상되면 파일 시스템이 손상될 수 있습니다.
링크가 끊기거나 지워진 시스템 라이브러리 접근 되살리기
기존 libc.a 라이브러리를 쓸 수 없으면 대부분의 운영 체제 명령이 인식되지 않습니다.
이런 문제의 가장 그럴듯한 원인은 다음과 같습니다.
/usr/lib의 링크가 더는 없습니다./usr/ccs/lib의 파일이 지워졌습니다.
다음 절차는 libc.a 라이브러리 접근을 되살리는 방법을 설명합니다. 이 절차에는 시스템 중단 시간이 필요합니다. 데이터나 기능을 잃을 가능성에 대비해, 되도록 작업 부하에 영향이 가장 적은 때로 중단 시간을 잡습니다.
이 시나리오의 정보는 특정 AIX 버전으로 시험했습니다. 얻는 결과는 AIX 버전과 수준에 따라 크게 다를 수 있습니다.
관련 정보:
- mount 명령, unmount 명령, reboot 명령, Problem Solving and Troubleshooting in AIX
지워진 심볼릭 링크 되살리기
다음 절차로 /usr/lib/libc.a 라이브러리에서 /usr/ccs/lib/libc.a 경로로 가는 심볼릭 링크를 되살립니다.
이 시나리오의 정보는 특정 AIX 버전으로 시험했습니다. 얻는 결과는 AIX 버전과 수준에 따라 크게 다를 수 있습니다.
- root 권한으로 다음 명령을 입력해 LIBPATH 환경 변수가
/usr/ccs/lib디렉터리를 가리키게 합니다.
# LIBPATH=/usr/ccs/lib:/usr/lib
# export LIBPATH
이 시점에서 시스템 명령을 실행할 수 있어야 합니다.
2. /usr/lib/libc.a 라이브러리와 /lib 디렉터리에서 /usr/lib 디렉터리로 가는 링크를 되살리려면 다음 명령을 입력합니다.
ln -s /usr/ccs/lib/libc.a /usr/lib/libc.a
ln -s /usr/lib /lib
이 시점에서 명령이 전처럼 실행되어야 합니다. 그래도 셸에 접근할 수 없으면 이 절차의 나머지를 건너뛰고 다음 절, 지워진 시스템 라이브러리 파일 되살리기로 갑니다. 3. 다음 명령을 입력해 LIBPATH 환경 변수를 해제합니다.
unset LIBPATH
지워진 시스템 라이브러리 파일 되살리기
지워진 시스템 라이브러리 파일을 되살리는 이 절차에는 시스템 중단 시간이 필요합니다. 시스템을 부팅한 뒤 최근 mksysb 테이프에서 라이브러리를 복원합니다.
- 다시 부팅하기 전에
bosinst.data파일의 PROMPT 필드가yes로 설정되어 있는지 확인합니다. - 최근 mksysb 테이프를 테이프 드라이브에 넣습니다. mksysb는 설치된 시스템과 같은 운영 체제와 유지 보수 패키지나 기술 수준이어야 합니다. 설치된 시스템의 수준과 맞지 않는 mksysb에서
libc.a라이브러리를 복원하면 명령을 실행할 수 없게 됩니다. - 기계를 다시 부팅합니다.
- 아이콘 화면이 나오거나 두 번 삑 소리가 나면 System Management Services 메뉴가 나올 때까지 F1 키를 계속 누릅니다.
- Multiboot를 고릅니다.
- Install From을 고릅니다.
- mksysb가 든 테이프 장치를 고르고 Install을 고릅니다. 다음 프롬프트가 나오기까지 몇 분 걸릴 수 있습니다.
- F1 키를 눌러 지금 시스템을 시스템 콘솔로 정하고 Enter를 누릅니다.
- 원하는 언어의 번호를 고르고 Enter를 누릅니다.
3을 입력해 Start Maintenance Mode for System Recovery를 고르고 Enter를 누릅니다.- Access a Root Volume Group을 고릅니다. 이 시점에서 루트 볼륨 그룹을 바꾸면 다시 부팅하지 않고는 설치 메뉴로 돌아갈 수 없다는 메시지가 나옵니다.
0을 입력하고 Enter를 누릅니다.- 목록에서 알맞은 볼륨 그룹 번호를 입력하고 Enter를 누릅니다.
2를 입력해 Access this Volume Group을 고르고 Enter를 누릅니다.- 다음 명령을 입력해
/(root)와/usr파일 시스템을 마운트합니다.
mount /dev/hd4 /mnt
mount /dev/hd2 /mnt/usr
cd /mnt
- 필요하면 다음 명령을 입력해
libc.a라이브러리의 심볼릭 링크를 되살립니다.
ln -s /usr/ccs/lib/libc.a /mnt/usr/lib/libc.a
명령을 실행한 뒤 다음 가운데 하나를 합니다.
- 명령이 성공하면 20단계로 건너뜁니다.
- 링크가 이미 있다는 메시지가 나오면 17단계로 이어 갑니다.
- 다음 명령으로 테이프 드라이브의 블록 크기를 설정합니다. X는 알맞은 테이프 드라이브 번호입니다.
tctl -f /dev/rmt X rewind
tctl -f /dev/rmt X .1 fsf 1
restbyname -xvqf /dev/rmt X .1 ./tapeblksz
cat tapeblksz
cat tapeblksz 명령의 값이 512가 아니면, Y를 cat tapeblksz 명령의 값으로 바꿔 다음 명령을 입력합니다.
ln -sf /mnt/usr/lib/methods /etc/methods
/etc/methods/chgdevn -l rmt X -a block_size= Y
rmtX가 바뀌었다는 메시지를 받아야 합니다. 18. 다음 명령을 입력해(X는 알맞은 테이프 드라이브 번호) 라이브러리를 복원할 수 있도록 테이프를 올바른 위치에 둡니다.
tctl -f /dev/rmt X rewind
tctl -f /dev/rmt X .1 fsf 3
- 다음 명령 가운데 하나로(X는 알맞은 테이프 드라이브 번호) 없어진 라이브러리를 복원합니다.
libc.a라이브러리만 복원하려면 다음 명령을 입력합니다.
restbyname -xvqf /dev/rmt X .1 ./usr/ccs/lib/libc.a
/usr/ccs/lib디렉터리를 복원하려면 다음 명령을 입력합니다.
restbyname -xvqf /dev/rmt X .1 ./usr/ccs/lib
/usr/ccs/bin디렉터리를 복원하려면 다음 명령을 입력합니다.
restbyname -xvqf /dev/rmt X .1 ./usr/ccs/bin
- 다음 명령을 입력해 데이터를 디스크에 씁니다.
cd /mnt/usr/sbin
./sync;./sync;./sync
- 다음 명령을 입력해
/usr과/(root) 파일 시스템을 마운트 해제합니다.
cd /
umount /dev/hd2
umount /dev/hd4
umount 명령 가운데 하나라도 실패하면 이 기계의 전원을 껐다 켜고 이 절차를 처음부터 다시 합니다. 22. 다음 명령을 입력해 시스템을 다시 부팅합니다.
reboot
시스템이 다시 부팅되면 운영 체제 명령을 쓸 수 있어야 합니다.
손상된 부트 이미지 다시 만들기
손상된 부트 이미지를 알아내 다시 만드는 절차입니다.
기계가 지금 실행 중이고 부트 이미지가 손상되었거나 지워졌다는 것을 알면, root 권한으로 bosboot 명령을 실행해 부트 이미지를 다시 만듭니다.
주의: 부트 이미지가 손상되었다고 의심되면 절대로 시스템을 다시 부팅하지 않습니다.
다음 절차는 부트 이미지 손상 때문에 시스템이 올바르게 다시 부팅하지 못한다고 가정합니다. 데이터나 기능을 잃을 가능성에 대비해, 되도록 작업 부하에 영향이 가장 적은 때로 중단 시간을 잡습니다.
이 시나리오의 정보는 특정 AIX 버전으로 시험했습니다. 얻는 결과는 AIX 버전과 수준에 따라 크게 다를 수 있습니다.
- 제품 매체를 알맞은 드라이브에 넣습니다.
- 시스템과 함께 온 지시에 따라 기계를 켭니다.
- System Management Services 메뉴에서 Multiboot를 고릅니다.
- 다음 화면에서 Install From을 고릅니다.
- 제품 매체가 든 장치를 고르고 Install을 고릅니다.
- AIX 버전 아이콘을 고릅니다.
- 설치에 쓸 모드를 고를 수 있을 때까지 화면의 지시를 따릅니다. 그 시점에서 Start Maintenance Mode for System Recovery를 고릅니다.
- Access a Root Volume Group을 고릅니다.
- Access this Volume Group and start a shell을 고를 수 있을 때까지 화면의 지시를 따릅니다.
- bosboot 명령으로 부트 이미지를 다시 만듭니다. 예:
bosboot -a -d /dev/hdisk0
명령이 실패하고 다음 메시지를 받으면:
0301-165 bosboot: WARNING! bosboot failed - do not attempt to boot device.
다음 방법 가운데 하나로 문제를 고친 뒤, 부트 이미지를 성공적으로 만들 때까지 bosboot 명령을 다시 실행합니다.
- 기본 부트 논리 볼륨(hd5)을 지우고 새 hd5를 만듭니다. 또는
- 하드 디스크에 진단을 실행합니다. 필요하면 수리하거나 교체합니다.
bosboot 명령이 계속 실패하면 고객 지원 담당자에게 연락합니다.
주의: bosboot 명령이 부트 이미지를 만들다 실패하면 기계를 다시 부팅하지 않습니다. 11. bosboot 명령이 성공하면 reboot 명령으로 시스템을 다시 부팅합니다.
관련 정보:
- bosboot 명령, Problem Solving and Troubleshooting in AIX
JFS 온라인 백업 만들기
마운트된 JFS(journaled file system)나 JFS2(enhanced journaled file system)의 온라인 백업을 만들면 파일 시스템이 든 논리 볼륨의 정적 이미지가 만들어집니다.
마운트된 JFS의 온라인 백업을 만들려면 파일 시스템이 있는 논리 볼륨과 그 로그가 있는 논리 볼륨이 미러되어 있어야 합니다.
참고: 파일 쓰기가 비동기이므로, 떼어 낸 사본에는 분리 직전에 쓴 데이터가 모두 들어 있지 않을 수 있습니다. 분리가 시작된 뒤에 시작한 수정은 백업 사본에 없을 수 있습니다. 그래서 분리가 일어나는 동안 파일 시스템 활동을 최소로 하기를 권합니다.
이 시나리오의 정보는 특정 AIX 버전으로 시험했습니다. 얻는 결과는 AIX 버전과 수준에 따라 크게 다를 수 있습니다.
/home/xyz 파일 시스템의 미러 사본을 떼어 /jfsstaticcopy라는 새 마운트 지점에 두려면 다음을 입력합니다.
chfs -a splitcopy=/jfsstaticcopy /home/xyz
copy 속성으로 어느 미러 사본을 백업으로 쓸지 제어할 수 있습니다. 사용자가 사본을 지정하지 않으면 두 번째 미러 사본이 기본입니다. 예:
chfs -a splitcopy=/jfsstaticcopy -a copy=1 /home/xyz
이 시점에서 /jfsstaticcopy에 파일 시스템의 읽기 전용 사본이 있습니다. 사본을 떼어 낸 뒤 원본 파일 시스템에 한 변경은 백업 사본에 반영되지 않습니다.
/testcopy 마운트 지점의 JFS 분리 이미지를 미러 사본으로 다시 합치려면 다음 명령을 씁니다.
rmfs /testcopy
rmfs 명령은 파일 시스템 사본을 분리 상태에서 빼내 미러 사본으로 다시 합쳐지게 합니다.
JFS2 스냅숏 만들고 백업하기
마운트된 JFS2의 스냅숏을 만들어 특정 시점의 파일 시스템에 대해 일관된 블록 수준 이미지를 얻을 수 있습니다.
이 시나리오의 정보는 특정 AIX 버전으로 시험했습니다. 얻는 결과는 AIX 버전과 수준에 따라 크게 다를 수 있습니다.
스냅숏을 만드는 데 쓴 파일 시스템(snappedFS라고 함)이 계속 바뀌어도 스냅숏 이미지는 안정된 채로 남습니다. 스냅숏은 만들 때 snappedFS가 가졌던 보안 권한을 그대로 유지합니다.
다음 시나리오에서는 파일 시스템을 마운트 해제하거나 멈추지 않고 backsnap 명령 하나로 스냅숏을 만들어 이동식 매체에 백업합니다. 스냅숏은 스냅숏을 찍은 때의 파일이나 디렉터리에 접근하는 것 같은 다른 목적으로도 쓸 수 있습니다. 여러 스냅숏 절차는 Web-based System Manager, SMIT, backsnap과 snapshot 명령으로 할 수 있습니다.
/home/abc/test 파일 시스템의 스냅숏을 만들어 테이프 장치 /dev/rmt0에 (이름 기준으로) 백업하려면 다음 명령을 씁니다.
backsnap -m /tmp/snapshot -s size=16M -i f/dev/rmt0 /home/abc/test
이 명령은 JFS2 파일 시스템(/home/abc/test)의 스냅숏용으로 16 MB 논리 볼륨을 만듭니다. 스냅숏은 /tmp/snapshot에 마운트되고, 스냅숏의 이름 기준 백업이 테이프 장치로 만들어집니다. 백업이 끝나도 스냅숏은 마운트된 채로 남습니다. 백업이 끝날 때 스냅숏을 지우려면 backsnap 명령에 -R 플래그를 씁니다.
관련 정보:
- backsnap 명령, chfs 명령, rmfs 명령, snapshot 명령
JFS2 외부 스냅숏 만들고 백업하기(6.1)
마운트된 JFS2의 스냅숏을 만들어 특정 시점의 파일 시스템에 대해 일관된 블록 수준 이미지를 얻을 수 있습니다.
스냅숏을 만드는 데 쓴 파일 시스템(snappedFS)이 계속 바뀌어도 스냅숏 이미지는 안정된 채로 남습니다. 스냅숏은 만들 때 snappedFS가 가졌던 보안 권한을 그대로 유지합니다.
다음 시나리오에서는 backsnap 명령으로, 파일 시스템을 마운트 해제하거나 멈추지 않고 외부 스냅숏을 만들어 이동식 매체에 백업합니다. 스냅숏은 스냅숏을 찍은 때의 파일이나 디렉터리에 접근하는 것 같은 다른 목적으로도 쓸 수 있습니다. 여러 스냅숏 절차는 Web-based System Manager, SMIT, backsnap과 snapshot 명령으로 할 수 있습니다.
/home/abc/test 파일 시스템의 외부 스냅숏을 만들어 /dev/rmt0 테이프 장치에 이름 기준으로 백업하려면 다음 명령을 실행합니다.
backsnap -m /tmp/snapshot -s size=16M -if/dev/rmt0 /home/abc/test
이 명령은 /home/abc/test JFS2 파일 시스템의 스냅숏용으로 16 MB 논리 볼륨을 만듭니다. 스냅숏은 /tmp/snapshot 디렉터리에 마운트되고, 스냅숏의 이름 기준 백업이 테이프 장치로 만들어집니다. 백업이 끝나면 스냅숏은 마운트 해제되지만 계속 쓸 수 있습니다. 백업이 끝날 때 스냅숏을 지우려면 backsnap 명령에 -R 플래그를 씁니다.
JFS2 내부 스냅숏 만들고 백업하기(6.1)
마운트된 JFS2의 스냅숏을 만들어 특정 시점의 파일 시스템에 대해 일관된 블록 수준 이미지를 얻을 수 있습니다.
스냅숏을 만드는 데 쓴 파일 시스템(snappedFS)이 계속 바뀌어도 스냅숏 이미지는 안정된 채로 남습니다. 스냅숏은 만들 때 snappedFS가 가졌던 보안 권한을 그대로 유지합니다.
다음 시나리오에서는 backsnap 명령으로, 파일 시스템을 마운트 해제하거나 멈추지 않고 내부 스냅숏을 만들어 이동식 매체에 백업합니다. 스냅숏은 스냅숏을 찍은 때의 파일이나 디렉터리에 접근하는 것 같은 다른 목적으로도 쓸 수 있습니다. 여러 스냅숏 절차는 Web-based System Manager, SMIT, backsnap과 snapshot 명령으로 할 수 있습니다.
/home/abc/test 파일 시스템의 내부 스냅숏을 만들어 /dev/rmt0 테이프 장치에 이름 기준으로 백업하려면 다음 명령을 실행합니다.
backsnap -n mysnapshot -if/dev/rmt0 /home/abc/test
이 명령은 /home/abc/test 파일 시스템의 mysnapshot이라는 내부 스냅숏을 만듭니다. 스냅숏은 /home/abc/test/.snapshot/mysnapshot 디렉터리에서 접근하며, 그런 다음 테이프 장치로 백업이 만들어집니다. 백업이 끝난 뒤 스냅숏을 지우려면 backsnap 명령에 -R 플래그를 씁니다.
파일 압축(compress와 pack 명령)
compress 명령과 pack 명령으로 저장을 위해 파일을 압축합니다.
uncompress 명령과 unpack 명령으로 복원한 파일을 풉니다.
파일을 압축하고 푸는 데는 시간이 걸리지만, 압축하면 데이터가 백업 매체에서 공간을 덜 씁니다.
파일 시스템을 압축하려면 다음 방법 가운데 하나를 씁니다.
- backup 명령에
-p플래그를 씁니다. - compress나 pack 명령을 씁니다.
파일 압축의 장점은 다음과 같습니다.
- 네트워크로 보내기 전에 파일을 압축해 돈과 시간을 아낍니다.
- 저장 공간과 아카이브 시스템 자원을 아낍니다.
- 테이프 공간을 아끼도록 백업하기 전에 파일 시스템을 압축합니다.
- 밤에 실행하는 셸 스크립트가 만드는 로그 파일을 압축합니다. 스크립트가 끝나기 전에 파일을 압축하게 하기 쉽습니다.
- 지금 접근하지 않는 파일을 압축합니다. 예를 들어 오래 자리를 비운 사용자의 파일을 압축해 디스크나 테이프의 tar 아카이브에 넣었다가 나중에 복원할 수 있습니다.
주:
- compress 명령은 압축하는 동안 파일 시스템의 작업 공간이 모자랄 수 있습니다. 이 명령은 압축하지 않은 파일을 지우기 전에 압축 파일을 만들므로 파일 전체 크기보다 약 50% 더 큰 공간이 필요합니다.
- 이미 압축된 파일이면 압축에 실패할 수 있습니다. compress 명령이 파일 크기를 줄일 수 없으면 명령이 실패합니다.
반환값에 관한 자세한 내용은 compress 명령을 보되, 대체로 파일을 압축할 때 만나는 문제는 다음과 같이 요약할 수 있습니다.
- 압축하는 동안 파일 시스템의 작업 공간이 모자랄 수 있습니다. compress 명령은 압축하지 않은 파일을 지우기 전에 압축 파일을 만들므로 파일마다 크기의 50%~100%만큼 추가 공간이 필요합니다.
- 이미 압축된 파일이면 압축에 실패할 수 있습니다. compress 명령이 파일 크기를 줄일 수 없으면 실패합니다.
compress 명령으로 파일 압축
compress 명령으로 적응형 Lempel-Ziv 부호화를 써서 파일 크기를 줄입니다.
File 매개변수로 지정한 각 원본 파일은 이름 끝에 .Z가 붙은 압축 파일로 바뀝니다. 압축 파일은 원본 파일의 소유권, 모드, 접근·수정 시간을 그대로 유지합니다. 파일을 지정하지 않으면 표준 입력을 압축해 표준 출력으로 냅니다. 압축으로 파일 크기가 줄지 않으면 표준 오류에 메시지를 쓰고 원본 파일을 바꾸지 않습니다.
압축한 파일을 원래 형태로 복원하려면 uncompress 명령을 씁니다.
압축 정도는 입력 크기, Bits 변수로 지정한 코드당 비트 수, 공통 부분 문자열의 분포에 따라 다릅니다. 보통 소스 코드나 영어 텍스트는 50~60% 줄어듭니다. compress 명령의 압축은 대체로 적응형 Huffman 부호화를 쓰는 pack 명령의 압축보다 더 작고 계산 시간도 덜 걸립니다.
예를 들어 foo 파일을 압축하고 압축률을 표준 오류에 쓰려면 다음을 입력합니다.
compress -v foo
전체 구문은 Commands Reference, Volume 1의 compress 명령을 봅니다.
pack 명령으로 파일 압축
pack 명령으로 File 매개변수로 지정한 파일을 Huffman 부호화를 써서 압축 형태로 저장합니다.
입력 파일은 원래 파일 이름에서 만든 이름(File.z)의 압축 파일로 바뀌며, 원본 파일과 같은 접근 모드, 접근·수정 날짜, 소유자를 갖습니다. 덧붙는 .z 접미사 자리를 남기려고 입력 파일 이름은 253바이트를 넘을 수 없습니다. pack 명령이 성공하면 원본 파일은 지워집니다.
압축한 파일을 원래 형태로 복원하려면 unpack 명령을 씁니다.
pack 명령이 더 작은 파일을 만들 수 없으면 처리를 멈추고 공간을 아낄 수 없다고 보고합니다. (공간을 아끼지 못하는 경우는 보통 작은 파일이나 문자 분포가 고른 파일입니다.) 아끼는 공간의 양은 입력 파일 크기와 문자 빈도 분포에 따라 다릅니다. 각 .z 파일의 첫 부분은 디코딩 트리이므로 세 블록보다 작은 파일에서는 공간을 아끼지 못합니다. 보통 텍스트 파일은 25~40% 줄어듭니다.
pack 명령의 종료 값은 압축하지 못한 파일 수입니다. 다음 가운데 하나라도 해당하면 압축하지 않습니다.
- 파일이 이미 압축되어 있습니다.
- 입력 파일 이름이 253바이트보다 깁니다.
- 파일에 링크가 있습니다.
- 파일이 디렉터리입니다.
- 파일을 열 수 없습니다.
- 압축해도 저장 블록이 줄지 않습니다.
- File
.z라는 파일이 이미 있습니다. .z파일을 만들 수 없습니다.- 처리 중 I/O 오류가 일어났습니다.
예를 들어 chap1과 chap2 파일을 압축하려면 다음을 입력합니다.
pack chap1 chap2
이렇게 하면 chap1과 chap2가 압축되어 chap1.z와 chap2.z 파일로 바뀝니다. pack 명령은 파일마다 크기가 줄어든 비율을 보여 줍니다.
전체 구문은 Commands Reference, Volume 4의 pack 명령을 봅니다.
압축 파일 풀기(uncompress와 unpack 명령)
uncompress와 unpack 명령으로 압축 파일을 풉니다.
uncompress 명령으로 파일 풀기
uncompress 명령으로 compress 명령이 압축한 원본 파일을 복원합니다. File 변수로 지정한 각 압축 파일은 지워지고 푼 사본으로 바뀝니다. 푼 파일은 압축 버전과 같은 이름이지만 .Z 확장자가 없습니다. 푼 파일은 원본 파일과 같은 소유권, 모드, 접근·수정 시간을 유지합니다. 파일을 지정하지 않으면 표준 입력을 풀어 표준 출력으로 냅니다.
uncompress 명령과 비슷하지만 zcat 명령은 푼 출력을 언제나 표준 출력에 씁니다. 예를 들어 foo 파일을 풀려면 다음을 입력합니다.
uncompress foo
전체 구문은 Commands Reference, Volume 5의 uncompress 명령을 봅니다.
unpack 명령으로 파일 풀기
unpack 명령으로 pack 명령이 만든 파일을 풉니다. 지정한 파일마다 unpack 명령은 File.z라는 파일을 찾습니다. 이 파일이 압축 파일이면 unpack 명령은 그것을 푼 버전으로 바꿉니다. unpack 명령은 File에서 .z 접미사를 떼어 새 파일 이름을 정합니다. 새 파일은 원래 압축 파일과 같은 접근 모드, 접근·수정 날짜, 소유자를 갖습니다. unpack 명령은 .z로 끝나는 파일에만 동작합니다. 그래서 .z로 끝나지 않는 파일 이름을 지정하면 unpack 명령이 접미사를 더해 그 접미사가 붙은 파일 이름을 디렉터리에서 찾습니다.
종료 값은 unpack 명령이 풀지 못한 파일 수입니다. 다음 가운데 하나라도 해당하면 파일을 풀 수 없습니다.
- (
.z를 뺀) 파일 이름이 253바이트보다 깁니다. - 파일을 열 수 없습니다.
- 파일이 압축 파일이 아닙니다.
- 푼 파일 이름의 파일이 이미 있습니다.
- 푼 파일을 만들 수 없습니다.
참고: 푸는 파일에 링크가 있으면 unpack 명령이 표준 오류에 경고를 씁니다. 새로 푼 파일은 그것을 만든 압축 파일과 i-node(index node) 번호가 다릅니다. 그러나 압축 파일의 원래 i-node 번호에 링크된 다른 파일은 그대로 있고 여전히 압축되어 있습니다. 예를 들어 압축 파일 chap1.z와 chap2.z를 풀려면 다음을 입력합니다.
unpack chap1.z chap2
이렇게 하면 압축 파일 chap1.z와 chap2.z가 풀려 chap1과 chap2 파일로 바뀝니다.
참고: unpack 명령에는 .z 접미사가 있든 없든 파일 이름을 줄 수 있습니다.
전체 구문은 Commands Reference, Volume 5의 unpack 명령을 봅니다.
영어 원문
Administering system backups
There are multiple ways to backup your system and restore a system backup.
Backing up user files or file systems
Two procedures can be used to back up files and file systems: the SMIT fast paths smit backfile or smit backfilesys, and the backup command.
If you are backing up by i-node file systems that may be in use, unmount them first to prevent inconsistencies. Attention: If you attempt to back up a mounted file system, a warning message is displayed. The backup command continues, but inconsistencies in the file system may occur. This warning does not apply to the root (
/) file system.To prevent errors, make sure the backup device has been cleaned recently.
To back up user files and file systems, you can use the Web-based System Manager, the SMIT fast paths smit backfile or smit backfilesys.
You can use the SMIT interface for backing up single and small file systems by name, such as /home on your local system. Note that SMIT cannot make archives in any other format than that provided by the backup command. Also, not every flag of the backup command is available through SMIT. SMIT might hang if multiple tapes or disks are needed during the backup. For more information, see the backup command description in Commands Reference, Volume 1.
Use the backup command when you want to back up large and multiple file systems. You can specify a level number to control how much data is backed up (full, 0; incremental, 1-9). Using the backup command is the only way you can specify the level number on backups.
The backup command creates copies in one of the two following backup formats:
Specific files backed up by name using the
-iflag.Entire file systems backed up by i-node using the
-LevelandFileSystemparameters. The file system is defragmented when it is restored from backup.
Attention: Backing up by i-node does not work correctly for files that have a user ID (UID) or a group ID (GID) greater than 65535. These files are backed up with UID or GID truncated and will, therefore, have the wrong UID or GID attributes when restored. For these cases, you must back up by name. Task SMIT Fast Path Command or File Back Up User Files smit backfile
Log in to your user account.
Backup:
find . -print | backup -ivf
/dev/rmt0
Back Up User File Systems smit backfilesys 1. Unmount files systems that you plan to back up. For example: umount all or umount /home
/filesys1
- Verify the file systems. For example:
fsck
/home /filesys1
- Back up by i-node. For example:
backup -5
-uf/dev/rmt0 /home/libr
- Restore the files using the following command: restore -t
Note: If this command generates an error message, you must repeat the entire backup.
Related concepts
System backup Once your system is in use, your next consideration should be to back up the file systems, directories, and files. If you back up your file systems, you can restore files or file systems in the event of a hard disk crash. There are different methods for backing up information.
Restoring backed-up files
After the data has been correctly backed up, there are several different methods of restoring the data based upon the type of backup command you used.
You need to know how your backup or archive was created to restore it correctly. Each backup procedure gives information about restoring data. For example, if you use the backup command, you can specify a backup either by file system or by name. That backup must be restored the way it was done, by file system or by name. For information about the backup command, see backup.
Several commands restore backed up data, such as:
- restore — Copies files created by the backup command. For more information about using this command, see the section below.
- rrestore — Copies file systems backed up on a remote machine to the local machine. For more information, see rrestore.
- cpio — Copies files into and out of archive storage. For more information, see cpio .
- tar — Creates or manipulates tar archives. For more information, see tar.
- pax — (POSIX-conformant archive utility) Reads and writes tar and cpio archives. For more information, see pax.
The following sections discuss the restore and smit commands.
Note
Files must be restored using the same method by which they were backed up. For example, if a file system was backed up by name, it must be restored by name.
When more than one diskette is required, the restore command reads the diskette that is mounted, prompts you for a new one, and waits for your response. After inserting the new diskette, press the Enter key to continue restoring files.
Restoring files using the restore command
Use the restore command to read files written by the backup command and restore them on your local system.
See the following examples:
- To list the names of files previously backed up, type the following:
restore -T
Information is read from the /dev/rfd0 default backup device. If individual files are backed up, only the file names are displayed. If an entire file system is backed up, the i-node number is also shown.
- To restore files to the main file system, type the following:
restore -x -v
The -x flag extracts all the files from the backup media and restores them to their proper places in the file system. The -v flag displays a progress report as each file is restored. If a file system backup is being restored, the files are named with their i-node numbers. Otherwise, only the names are displayed.
- To copy the
/home/mike/manual/chap1file, type the following:
restore -xv /home/mike/manual/chap1
This command extracts the /home/mike/manual/chap1 file from the backup medium and restores it. The /home/mike/manual/chap1 file must be a name that the restore -T command can display.
- To copy all the files in a directory named
manual, type the following:
restore -xdv manual
This command restores the manual directory and the files in it. If the directory does not exist, a directory named manual is created in the current directory to hold the files being restored.
See the restore command in the Commands Reference, Volume 4 for the complete syntax.
Restoring files using the smit command
Use the smit command to run the restore command, which reads files written by the backup command and restores them on your local system.
- At the prompt, type the following:
smit restore
Make your entry in the Target DIRECTORY field. This is the directory where you want the restored files to reside.
Proceed to the BACKUP device or FILE field and enter the output device name, as in the following example for a raw magnetic tape device:
/dev/rmt0
If the device is not available, a message similar to the following is displayed:
Cannot open /dev/rmtX, no such file or directory.
This message indicates that the system cannot reach the device driver because there is no file for rmtX in the /dev directory. Only items in the available state are in the /dev directory.
For the NUMBER of blocks to read in a single input field, the default is recommended.
Press Enter to restore the specified file system or directory.
Creating a remote archive
Use this procedure to archive files to a remote tape device.
Running AIX systems cannot mount a remote tape device as if it were local to the system; however, data can be sent to a remote machine tape device using the rsh command. The following procedure writes to a single tape only. Multiple-tape archives require specialized application software.
In the following procedure, assume the following:
blocksize Represents the target tape device blocksize.
remotehost Is the name of the target system (the system that has the tape drive).
sourcehost Is the name of the source system (the system being archived).
/dev/rmt0
Is the name of the remote tape device
pathname Represents the full pathname of a required directory or file.
When using the following instructions, assume that both the local and remote user is root.
Ensure you have access to the remote machine. The source machine must have access to the system with the tape drive. (The target system can be accessed using any of the defined users on that system, but the user name must have root authority to do many of the following steps.)
Using your favorite editor, create a file in the
/(root) directory of the target system called.rhoststhat allows the source system access to the target system. You need to add the authorized host name and user ID to this file. To determine the name of the source machine for the.rhostsfile, you can use the following command:
host SourceIPaddress
For the purposes of this example, assume you add the following line to the .rhosts file:
sourcehost.mynet.com root
- Save the file and then change its permissions using the following command:
chmod 600 .rhosts
- Use the rsh command to test your access from the source machine. For example:
rsh remotehost
If everything is set up correctly, you should be granted shell access to the remote machine. You should not see a login prompt asking for a user name. Type exit to log out of this test shell.
- Decide on the appropriate tape device blocksize. The following are the recommended values:
- 9-track or 0.25-in. media blocksize: — 512
- 8-mm or 4-mm media blocksize: — 1024
If you are unsure and want to check the current block size of the tape device, use the tctl command. For example:
tctl -f /dev/rmt0 status
If you want to change the tape blocksize, use the chdev command. For example:
chdev -l rmt0 -a block_size=1024
- Create your archive using one of the following methods:
Backup by Name
To remotely create a backup archive by name, use the following command:
find pathname -print | backup -ivqf- | rsh remotehost \
"dd of=/dev/rmt0 bs= blocksize conv=sync"
Backup by inode
To remotely create a backup archive by inode, first unmount your file system then use the
backup command. For example
umount /myfs
backup -0 -uf- /myfs | rsh remotehost \
"dd of=/dev/rmt0 bs= blocksize conv=sync"
Create and Copy an Archive to Remote Tape
To create and copy an archive to the remote tape device, use the following command:
find pathname -print | cpio -ovcB | rsh remotehost \
"dd ibs=5120 obs= blocksize of=/dev/rmt0"
Create a tar Archive
To remotely create a tar archive, use the following command:
tar -cvdf- pathname | rsh remotehost \
"dd of=/dev/rmt0 bs= blocksize conv=sync"
Create a Remote Dump
To remotely create a remote dump of the /myfs file system, use the following command:
rdump -u -0 -f remotehost :/dev/rmt0 /myfs
The -u flag tells the system to update the current backup level records in the /etc/dumpdates file. The -0 is the setting of the Level flag. Backup level 0 specifies that all the files in the /myfs directory are to be backed up. For more information, see the rdump command description in Commands Reference, Volume 4.
- Restore your remote archive using one of the following methods:
Restore a Backup by Name
To restore a remote backup archive by name, use the following command:
rsh remotehost "dd if=/dev/rmt0 bs= blocksize " | restore \
-xvqdf- pathname
Restore a Backup by inode
To restore a remote backup archive by inode, use the following command:
rsh remotehost "dd if=/dev/rmt0 bs= blocksize " | restore \
-xvqf- pathname
Restore a Remote cpio Archive
To restore a remote archive created with the cpio command, use the following command:
rsh remotehost "dd if=/dev/rmt0 ibs= blocksize obs=5120" | \
cpio -icvdumB
Restore a tar Archive
To restore a remote tar archive, use the following command:
rsh remotehost "dd if=/dev/rmt0 bs= blocksize " | tar -xvpf- pathname
Restore a Remote Dump
To restore a remote dump of the /myfs file system, use the following command:
cd /myfs
rrestore -rvf remotehost :/dev/rmt0
Restoring user files from a backup image
If you need to restore a backup image destroyed by accident, your most difficult problem is determining which of the backup tapes contains this file. The restore -T command can be used to list the contents of an archive. It is a good idea to restore the file in the /tmp directory so that you do not accidentally overwrite the user's other files.
Make sure the device is connected and available. To check availability, type:
lsdev -C | pg
If the backup strategy included incremental backups, then it is helpful to find out from the user when the file was most recently modified. This helps to determine which incremental backup contains the file. If
this information cannot be obtained or is found to be incorrect, then start searching the incremental backups in reverse order (7, 6, 5, ...). For incremental file system backups, the -i flag (interactive mode) of the restore command is very useful in both locating and restoring the lost file. (Interactive mode is also useful for restoring an individual user's account from a backup of the /home file system.)
The procedures in the following table describe how to implement a level 0 (full) restoration of a directory or file system.
Restoring from Backup Image Tasks Task SMIT Fast Path Command or File Restore Individual User Files smit restfile See restore command. Restoring a User File System smit restfilesys
mkfs /dev/hd1
mount /dev/hd1 /filesys
cd /filesys
restore -r
Restoring a User Volume Group smit restvg See restvg -q command.
Related tasks
Fixing a damaged file system File systems can get corrupted when the i-node or superblock information for the directory structure of the file system gets corrupted.
Restoring access to an unlinked or deleted system library
When the existing libc.a library is not available, most operating system commands are not recognized.
The most likely causes for this type of problem are the following:
The link in
/usr/libno longer exists.The file in
/usr/ccs/libhas been deleted.
The following procedure describes how to restore access to the libc.a library. This procedure requires system downtime. If possible, schedule your downtime when it least impacts your workload to protect yourself from a possible loss of data or functionality.
The information in this how-to scenario was tested using specific versions of AIX. The results you obtain might vary significantly depending on your version and level of AIX.
Related information
mount command unmount command reboot command
Problem Solving and Troubleshooting in AIX
Restoring a deleted symbolic link
Use the following procedure to restore a symbolic link from the /usr/lib/libc.a library to the /usr/ccs/lib/libc.a path.
The information in this how-to scenario was tested using specific versions of AIX. The results you obtain might vary significantly depending on your version and level of AIX.
- With root authority, set the LIBPATH environment variable to point to the
/usr/ccs/libdirectory by typing the following commands:
# LIBPATH=/usr/ccs/lib:/usr/lib
# export LIBPATH
At this point, you should be able to execute system commands.
- To restore the links from the
/usr/lib/libc.alibrary and the/libdirectory to the/usr/libdirectory, type the following commands:
ln -s /usr/ccs/lib/libc.a /usr/lib/libc.a
ln -s /usr/lib /lib
At this point, commands should run as before. If you still do not have access to a shell, skip the rest of this procedure and continue with the next section, “Restoring a deleted system library file.”
- Type the following command to unset the LIBPATH environment variable.
unset LIBPATH
Restoring a deleted system library file
This procedure to restore a deleted system library file requires system downtime. The system is booted and then the library is restored from a recent mksysb tape.
Before your reboot, ensure the PROMPT field in the
bosinst.datafile is set toyes.Insert a recent mksysb tape into the tape drive. The mksysb must contain the same OS and maintenance package or technology level as the installed system. If you restore a
libc.alibrary from a mksysb that conflicts with the level on the installed system, you will not be able to issue commands.Reboot the machine.
When the screen of icons appears, or when you hear a double beep, press the F1 key repeatedly until the System Management Services menu is displayed.
Select Multiboot.
Select Install From.
Select the tape device that holds the mksysb and then select Install. It can take several minutes before the next prompt appears.
Define your current system as the system console by pressing the F1 key and press Enter.
Select the number of your preferred language and press Enter.
Select Start Maintenance Mode for System Recovery by typing
3and press Enter.Select Access a Root Volume Group. A message displays explaining that you will not be able to return to the Installation menus without rebooting if you change the root volume group at this point.
Type
0and press Enter.Type the number of the appropriate volume group from the list and press Enter.
Select Access this Volume Group by typing
2and press Enter.Mount the
/(root) and/usrfile systems by typing the following commands:
mount /dev/hd4 /mnt
mount /dev/hd2 /mnt/usr
cd /mnt
- To restore the symbolic link for the
libc.alibrary, if needed, type the following command:
ln -s /usr/ccs/lib/libc.a /mnt/usr/lib/libc.a
After the command runs, do one of the following:
If the command is successful, skip to step 20.
If a message displays that the link already exists, continue with step 17.
- Set the block size of the tape drive by issuing the following commands, where X is the number of the appropriate tape drive.
tctl -f /dev/rmt X rewind
tctl -f /dev/rmt X .1 fsf 1
restbyname -xvqf /dev/rmt X .1 ./tapeblksz
cat tapeblksz
If the value from the cat tapeblksz command is not equal to 512, type the following commands, replacing Y with the value from the cat tapeblksz command:
ln -sf /mnt/usr/lib/methods /etc/methods
/etc/methods/chgdevn -l rmt X -a block_size= Y
You should receive a message that rmtX has been changed.
- Ensure the tape is at the correct location for restoring the library by typing the following commands (where X is the number of the appropriate tape drive):
tctl -f /dev/rmt X rewind
tctl -f /dev/rmt X .1 fsf 3
- Restore the missing library using one of the following commands (where X is the number of the appropriate tape drive):
- To restore the
libc.alibrary only, type the following command:
restbyname -xvqf /dev/rmt X .1 ./usr/ccs/lib/libc.a
- To restore the
/usr/ccs/libdirectory, type the following command:
restbyname -xvqf /dev/rmt X .1 ./usr/ccs/lib
- To restore the
/usr/ccs/bindirectory, type the following command:
restbyname -xvqf /dev/rmt X .1 ./usr/ccs/bin
- Flush the data to disk by typing the following commands:
cd /mnt/usr/sbin
./sync;./sync;./sync
- Unmount the
/usrand/(root) file systems by typing the following commands:
cd /
umount /dev/hd2
umount /dev/hd4
If either umount command fails, cycle power on this machine and begin this procedure again.
- Reboot the system by typing the following command:
reboot
After the system is rebooted, operating system commands should be available.
Recreating a corrupted boot image
The following procedure describes how to identify a corrupted boot image and re-create it.
If your machine is currently running and you know the boot image has been corrupted or deleted, recreate the boot image by running the bosboot command with root authority.
Attention: Never reboot the system when you suspect the boot image is corrupted.
The following procedure assumes your system is not rebooting correctly because of a corrupted boot image. If possible, protect your system from a possible loss of data or functionality by scheduling your downtime when it least impacts your workload.
The information in this how-to scenario was tested using specific versions of AIX. The results you obtain might vary significantly depending on your version and level of AIX.
Insert the product media into the appropriate drive.
Power on the machine following the instructions provided with your system.
From the System Management Services menu, select Multiboot.
From the next screen, select Install From.
Select the device that holds the product media and then select Install.
Select the AIX version icon.
Follow the online instructions until you can select which mode you use for installation. At that point, select Start Maintenance Mode for System Recovery.
Select Access a Root Volume Group.
Follow the online instructions until you can select Access this Volume Group and start a shell.
Use the bosboot command to re-create the boot image. For example:
bosboot -a -d /dev/hdisk0
If the command fails and you receive the following message:
0301-165 bosboot: WARNING! bosboot failed - do not attempt to boot device.
Try to resolve the problem using one of the following options, and then run the bosboot command again until you have successfully created a boot image:
Delete the default boot logical volume (hd5) and then create a new hd5. Or
Run diagnostics on the hard disk. Repair or replace, as necessary.
If the bosboot command continues to fail, contact your customer support representative.
Attention: If the bosboot command fails while creating a boot image, do not reboot your machine.
- When the bosboot command is successful, use the reboot command to reboot your system.
Related concepts
System startup When the base operating system starts, the system initiates a complex set of tasks. Under normal conditions, these tasks are performed automatically.
Related information
bosboot command
Problem Solving and Troubleshooting in AIX
Making an online backup of a JFS
Making an online backup of a mounted journaled file system (JFS) or enhanced journaled file system (JFS2) creates a static image of the logical volume that contains the file system.
To make an online backup of a mounted JFS, the logical volume that the file system resides on and the logical volume that its log resides on must be mirrored.
Note: Because the file writes are asynchronous, the split-off copy might not contain all data that was written immediately before the split. Any modifications that begin after the split begins might not be present in the backup copy. Therefore, it is recommended that file system activity be minimal while the split is taking place.
The information in this how-to scenario was tested using specific versions of AIX. The results you obtain might vary significantly depending on your version and level of AIX.
To split off a mirrored copy of the /home/xyz file system to a new mount point named /jfsstaticcopy, type the following:
chfs -a splitcopy=/jfsstaticcopy /home/xyz
You can control which mirrored copy is used as the backup by using the copy attribute. The second mirrored copy is the default if a copy is not specified by the user. For example:
chfs -a splitcopy=/jfsstaticcopy -a copy=1 /home/xyz
At this point, a read-only copy of the file system is available in /jfsstaticcopy. Any changes made to the original file system after the copy is split off are not reflected in the backup copy.
To reintegrate the JFS split image as a mirrored copy at the /testcopy mount point, use the following command:
rmfs /testcopy
The rmfs command removes the file system copy from its split-off state and allows it to be reintegrated as a mirrored copy.
Making and backing up a snapshot of a JFS2
You can make a snapshot of a mounted JFS2 that establishes a consistent block-level image of the file system at a point in time.
The information in this how-to scenario was tested using specific versions of AIX. The results you obtain might vary significantly depending on your version and level of AIX.
The snapshot image remains stable even as the file system that was used to create the snapshot, called the snappedFS, continues to change. The snapshot retains the same security permissions as the snappedFS had when the snapshot was made.
In the following scenario, you create a snapshot and back up the snapshot to removable media without unmounting or quiescing the file system, all with one command: backsnap. You can also use the snapshot for other purposes, such as accessing the files or directories as they existed when the snapshot was taken. You can do the various snapshot procedures using Web-based System Manager, SMIT, or the backsnap and snapshot commands.
To create a snapshot of the /home/abc/test file system and back it up (by name) to the tape device /dev/rmt0, use the following command:
backsnap -m /tmp/snapshot -s size=16M -i f/dev/rmt0 /home/abc/test
This command creates a logical volume of 16 megabytes for the snapshot of the JFS2 file system (/home/abc/test). The snapshot is mounted on /tmp/snapshot and then a backup by name of the snapshot is made to the tape device. After the backup completes, the snapshot remains mounted. Use the -R flag with the backsnap command if you want the snapshot removed when the backup completes.
Related concepts
File systems A file system is a hierarchical structure (file tree) of files and directories.
Related information
backsnap command chfs command rmfs command snapshot command
Making and backing up an external snapshot of a JFS2
You can make a snapshot of a mounted JFS2 that establishes a consistent block-level image of the file system at a point in time.
The snapshot image remains stable even as the file system that was used to create the snapshot, called the snappedFS, continues to change. The snapshot retains the same security permissions as the snappedFS had when the snapshot was made.
In the following scenario, you use the backsnap command to create an external snapshot and back up the snapshot to removable media without unmounting or quiescing the file system. You can also use the snapshot for other purposes, such as accessing the files or directories as they existed when the snapshot was taken. You can do the various snapshot procedures using Web-based System Manager, SMIT, or the backsnap and snapshot commands.
To create an external snapshot of the /home/abc/test file system and back it up, by name, to the /dev/rmt0 tape device, run the following command:
backsnap -m /tmp/snapshot -s size=16M -if/dev/rmt0 /home/abc/test
The previous command creates a logical volume of 16 MB for the snapshot of the /home/abc/test JFS2 file system. The snapshot is mounted on the /tmp/snapshot directory and then a backup of the snapshot, by name, is made to the tape device. After the backup is complete, the snapshot is unmounted but remains available. Use the -R flag with the backsnap command if you want the snapshot removed when the backup is completed.
Related concepts
File systems A file system is a hierarchical structure (file tree) of files and directories.
Making and backing up an internal snapshot of a JFS2
You can make a snapshot of a mounted JFS2 that establishes a consistent block-level image of the file system at a point in time.
The snapshot image remains stable even as the file system that was used to create the snapshot, called the snappedFS, continues to change. The snapshot retains the same security permissions as the snappedFS had when the snapshot was made.
In the following scenario, you use the backsnap command to create an internal snapshot and back up the snapshot to removable media without unmounting or quiescing the file system. You can also use the snapshot for other purposes, such as accessing the files or directories as they existed when the snapshot was taken. You can do the various snapshot procedures using Web-based System Manager, SMIT, or the backsnap and snapshot commands.
To create an internal snapshot of the /home/abc/test file system and back it up, by name, to the /dev/rmt0 tape device , run the following command:
backsnap -n mysnapshot -if/dev/rmt0 /home/abc/test
The previous command creates an internal snapshot, named mysnapshot, of the /home/abc/test file system. The snapshot is accessed from the /home/abc/test/.snapshot/mysnapshot directory and then a backup is made to the tape device. Use the -R flag with the backsnap command if you want the snapshot removed after the backup is completed.
Related concepts
File systems A file system is a hierarchical structure (file tree) of files and directories.
Compressing files (compress and pack commands)
Use the compress command and the pack command to compress files for storage.
Use the uncompress command and the unpack command to expand the restored files.
The process of compressing and expanding files takes time; however, after the files are packed, the data uses less space on the backup medium.
To compress a file system, use one of the following methods:
Use the
-pflag with the backup command.Use the compress or pack commands.
Advantages for compressing files include:
Saving money and time by compressing files before sending them over a network.
Saving storage and archiving system resources: – Compress file systems before making backups to preserve tape space. – Compress log files created by shell scripts that run at night; it is easy to have the script compress the file before it exits. – Compress files that are not currently being accessed. For example, the files belonging to a user who is away for extended leave can be compressed and placed into a tar archive on disk or to a tape and later be restored.
Note
The compress command might run out of working space in the file system while compressing. The command creates the compressed files before it deletes any of the uncompressed files, so it needs a space about 50% larger than the total size of the files.
A file might fail to compress because it is already compressed. If the compress command cannot reduce file sizes, the command fails.
See the compress command for details about the return values but, in general, the problems encountered when compressing files can be summarized as follows:
The command might run out of working space in the file system while compressing. Because the compress command creates the compressed files before it deletes any of the uncompressed files, it needs extra space-from 50% to 100% of the size of any given file.
A file might fail to compress because it is already compressed. If the compress command cannot reduce the file size, it fails.
Compressing files using the compress command:
Use the compress command to reduce the size of files using adaptive Lempel-Zev coding.
Each original file specified by the File parameter is replaced by a compressed file with a .Z appended to its name. The compressed file retains the same ownership, modes, and access and modification times of the original file. If no files are specified, the standard input is compressed to the standard output. If compression does not reduce the size of a file, a message is written to standard error and the original file is not replaced.
Use the uncompress command to restore compressed files to their original form.
The amount of compression depends on the size of the input, the number of bits per code specified by the Bits variable, and the distribution of common substrings. Typically, source code or English text is reduced by 50 to 60 percent. The compression of the compress command is generally more compact and takes less time to compute than the compression achieved by the pack command, which uses adaptive Huffman coding.
For example, to compress the foo file and write the percentage compression to standard error, type the following:
compress -v foo
See the compress command in the Commands Reference, Volume 1 for the complete syntax.
Compressing files using the pack command:
Use the pack command to store the file or files specified by the File parameter in a compressed form using Huffman coding.
The input file is replaced by a packed file with a name derived from the original file name (File.z), with the same access modes, access and modification dates, and owner as the original file. The input file name can contain no more than 253 bytes to allow space for the added .z suffix. If the pack command is successful, the original file is removed.
Use the unpack command to restore packed files to their original form.
If the pack command cannot create a smaller file, it stops processing and reports that it is unable to save space. (A failure to save space generally happens with small files or files with uniform character distribution.) The amount of space saved depends on the size of the input file and the character frequency distribution. Because a decoding tree forms the first part of each .z file, you do not save space with files smaller than three blocks. Typically, text files are reduced 25 to 40 percent.
The exit value of the pack command is the number of files that it could not pack. Packing is not done under any of the following conditions:
The file is already packed.
The input file name has more than 253 bytes.
The file has links.
The file is a directory.
The file cannot be opened.
No storage blocks are saved by packing.
A file named File
.zalready exists.The
.zfile cannot be created.An I/O error occurred during processing.
For example, to compress the files chap1 and chap2, type the following:
pack chap1 chap2
This compresses chap1 and chap2 and replaces them with files named chap1.z and chap2.z. The pack command displays the percent decrease in size for each file.
See the pack command in the Commands Reference, Volume 4 for the complete syntax.
Expanding compressed files (uncompress and unpack commands):
Use the uncompress and unpack commands to expand compressed files.
Expanding files using the uncompress command
Use the uncompress command to restore original files that were compressed by the compress command. Each compressed file specified by the File variable is removed and replaced by an expanded copy. The expanded file has the same name as the compressed version but without the .Z extension. The expanded file retains the same ownership, modes, and access and modification times as the original file. If no files are specified, standard input is expanded to standard output.
Although similar to the uncompress command, the zcat command always writes the expanded output to standard output. For example, to uncompress the foo file, type the following:
uncompress foo
See the uncompress command in Commands Reference, Volume 5 for the complete syntax.
Expanding files using the unpack command
Use the unpack command to expand files created by the pack command. For each file specified, the unpack command searches for a file called File.z. If this file is a packed file, the unpack command replaces it with its expanded version. The unpack command renames the new file by removing the .z suffix from File. The new file has the same access modes, access and modification dates, and owner as the original packed file. The unpack command operates only on files ending in .z. As a result, when you specify a file name that does not end in .z, the unpack command adds the suffix and searches the directory for a file name with that suffix.
The exit value is the number of files that the unpack command was unable to unpack. A file cannot be unpacked if any of the following situations exists:
The file name (exclusive of
.z) has more than 253 bytes.The file cannot be opened.
The file is not a packed file.
A file with the unpacked file name already exists.
The unpacked file cannot be created.
Note: The unpack command writes a warning to standard error if the file it is unpacking has links. The new unpacked file has a different i-node (index node) number than the packed file from which it was created. However, any other files linked to the original i-node number of the packed file still exist and are still packed. For example, to unpack the packed files chap1.z and chap2.z, type the following:
unpack chap1.z chap2
This expands the packed files chap1.z and chap2.z, and replaces them with files named chap1 and chap2.
Note: You can provide the unpack command with file names with or without the .z suffix.
See the unpack command in Commands Reference, Volume 5 for the complete syntax.