솔라리스 유틸리티를 사용하여 파일 시스템 뿐만 아니라 디렉토리나 여러 파일까지도 백업하거나 restore할 수 있다. 마그네틱 테이프를 데이터 백업에 사용되지만, 다른 미디어인 하드 디스크, CD, 심지어는 디스켓에도 가능하게 한다.
마그네틱 테이프에는 하나 이상의 데이터 그룹이나, 또는 데이터 셋을 저장할 수 있으며, 데이터 셋이 하나의 파일일 수 도 있다. 통상 데이터 셋이란 하나의 테이프에 기록되는 파일의 집합이다.
데이터 셋은 EOF(End Of File)로 구분되어 지며, 여러 개의 레코드나 블럭으로 구성된다. 블럭의 크기는 테이프에 데이터를 저장할 때 사용하는 명령에 따라 결정된다.
mt 명령어
mt 명령어는 magnetic tape 운영을 제어하는데 사용되는 명령이다. 이 명령에는 데이터 셋이 시작되는 테이프의 위치를 포함하여, 테이프의 rewinding, 테이프의 지움까지도 포함한다.
다음은 mt 명령의 명령과 그 동작이다.
command | description |
---|---|
asf count | positions the tape after the count-1 EOF mark |
bsf count | skips backward over count EOF marks |
bsr count | skips backward over count records |
eof count | writes count EOF marks |
eom | skips forward to a position after the last data set |
erase | erases the entire data |
fsf count | skips forward over count EOF marks |
fsr count | skips forwars over count records |
rewind | rewinds the tape |
status | displays status of tape drive |
대부분의 동작 명령은 표에서 count로 표시된 숫자 만큼 반복하여 동작을 하도록 지정한다
만약 count를 지정하지 않으면, 동작은 한번만 수행한다.
raw tape device에 -f를 지정하지 않으면, tape device의 디폴트는 /dev/rmt/0n으로 간주한다. 다음의 예는 4개의 EOF 마크를 지나서 5번째에 data set을 넣는 경우이다.
ufsdump/ufsrestore 명령어
ufsdump 명령어와 ufsrestore 명령어는 UFS 파일 시스템이나 또는 지정한 파일들이나 디렉토리들을 백업하고 다시 저장하는데 사용하는 명령어 이다.
이 명령은 증가적인 백업과 다시 저장하는데 이는 파일의 날짜 변경과 같은 기준을 따라 실행하게 된다.
dumping a file system using the ufsdump command
ufsdump 명령에는 여러 옵션이 있는데, 그 옵션은 대부분이 디폴트 characteristics를 백업 매체에 변경하기 위한 것들이다. 다음 표에 ufsdump의 옵션을 나타냈다.
argument | description |
---|---|
0 through 9 | dump lebel(0 is the entire file system) |
a archive_file | uses archive_file to store a dump table of the contents |
c | uses cartridge tape instead of standard half-inch reel tape |
f dump_file | uses dump_file instead of /dev/rmt/0 |
u | records the dump level and date in /etc/dumpdates |
v | verifies the dump media after backup |
만약, 덤프할 파일들을 지정하는 것외에 아무런 옵션도 지정하지 않으면, 디폴트는 9uf /dev/rmt/0가 된다. 이는 덤프 레벨 9로 덤프할 파일은 /dev/rmt/0를 백업하여 /etc/dumpdates 파일로 저장하게 된다.
덤프 레벨은 어느 파일들이 백업될지를 결정하는 것이다.
다음 예는 ufsdump를 사용하여 logical raw device name /dev/rdsk/c0t1d0s5의 모든 파일 시스템을 백업하는 것이며, 디폴트로 백업될 테이 장치는 /dev/rmt/0인 경우이다.
Restoring a file system using the ufsrestore command
ufsrestore 명령은 ufsdump로 백업한 파일 시스템을 원래의 장소에 되돌리는 것이다.
• ufsdump 명령에서와 같이 ufsrestore 명령에서도 f dump_file 옵션을 사용하여 백업에서 사용한 미디어 매체를 지정할 수 있다. 만약 미디어 매체를 지정하지 않으면 디폴트는 /dev/rmt/0이다.
다음 예시는 ufsrestore 명령을 사용하여 현재의 디렉토리를 /dev/rmt/1 장치로 백업한 파일 시스템을 restore하는 명령이다.
• ufsrestore 명령에서 옵션으로 i를 사용하면 interactive(대화식)하게 restore를 진행할 수 있다.
Restoring selected files using the ufsrestore command
• ufsrestore 명령에서 옵션으로 x(extract)를 사용하여 온전한 파일 시스템을 restore하는 대신에 백업으로부터 선택한 파일들만 restore할 수 있다. 물론 파일들 뿐만 아니라 디렉토리들도 restore할 수 있다.
다음 예시는 /etc/rmt/1의 root 파일 시스템을 백업한 것으로부터 /etc/passwd 파일과 /etc/default 디렉토리만 추출하여 /etc 디렉토리에 restore하는 예이다.
tar 명령어
tar 명령의 기본 기능함수는 다음과 같다.
function | description |
---|---|
c | tar 파일을 새로 만들거나, overwrite함 |
r | 지정한 파일들은 tar 내에 replace함 |
t | tar 파일에 들어있는 파일 목록을 출력 |
u | tar 파일내의 지장한 파일을 update함 |
x | tar 파일에서 지정한 파일을 추출함(extracts) |
위 표에 명시한 기능함수와 f tar_file 옵션을 함께 사용하여 백업할 파일 이름을 지정하여 사용한다.
만약 f 옵션을 사용하지 않으면, 백업 장치는 TAPE 환경에 지정되어 있거나, 또는 백업 장치가 /etc/default/tar 파일에 지정한 곳에 백업한다.
백업할 파일이나 디렉토리이름을 표의 함수와 f에 이어 지정하면 지정된 곳에 백업이 이루어진다.
v 옵션을 함께 지정하면 archive로 부터 파일을 추출하거나, archive 파일에 추가하는 목록이 출력된다. 즉 verbose로 진행하게 된다.
% cat /etc/default/tar
#ident "@(#)tar.dfl 1.5 92/07/14 SMI" /* SVr4.0 1.1 */ # The block size and the number of blocks are put for completion # purpose. The tape size is infinite and is defined at usage time # directly from tape. Tape size should be non-zero for non-tape devices # (e.g., floppy). # device block size archive0=/dev/rmt/0 20 0 archive1=/dev/rmt/0n 20 0 archive2=/dev/rmt/1 20 0 archive3=/dev/rmt/1n 20 0 archive4=/dev/rmt/0 126 0 archive5=/dev/rmt/0n 126 0 archive6=/dev/rmt/1 126 0 archive7=/dev/rmt/1n 126 0 |
# tar cf htdocs.tar /export/home/apache2/htdocs # tar tf htdocs.tar # tar xf htdocs.tar /export/home/apache2/htdocs # tar cf /dev/rmt/0 /export/home # tar tf /dev/rmt/0 # tar xf /dev/rmt/0 /export/home # file /dev/rmt/0 /dev/rmt/0: USTAR tar 아카이브 # ls -l /dev/rmt/0 -rw-r--r-- 1 root root 178688 12월 17일 17:03 /dev/rmt/0 #
cpio 명령어
cpio 명령도 디렉토리나 파일을 archive로 만드는 명령이다.
cpio 명령은 다음과 같은 3가지 모드가 있다.
기능 | argument | description |
---|---|---|
copy out | -o | reads a list of directory and file names and then copies their contents and control information to an archive format |
copy in | -i | reads an archive to extract the directories and files and re-create them at a specified location on the system |
pass | -p | reads a list of directories/files (along with their contents) and reproduces them at a specified location on the system |
다음은 cpio에서 주로 사용되는 옵션의 기능이다.
argument | description |
---|---|
-a | -i와 함께 사용하여 파일 접근 시간을 리셋함 |
-A | -o와 함께 사용하여 아카이브에 aapend함 |
-d | -i와 -p와 함께 사용하여 필요하면 디렉토리를 생성함 |
-i file | archive로부터 추출하여 copy in함 |
-I file | -i와 함께 사용하여 input archive로 file의 내용을 읽음 |
-L | -o와 -p와 함께 사용하여 심볼릭 링크를 따름 |
-m | -i와 -p와 함께 사용하여 변경된 시간을 그대로 유지함 |
-o | archive를 생성하여 copy out함 |
-O file | -o와 함께 사용하여 output archive로 file을 사용 |
-p | 입력을 출력에 패스시킴 |
-t | -i와 함께 사용하여 내용에 대한 archive table을 출력함; 파일들이 생성되지 않음 |
-u | -i와 -p와 함께 사용하여 무조건 파일들을 카피함; 기존 파일은 새 파일로 덮어 씀 |
-v | verbose 모드로 파일 이름이 출력됨 |
% ls file1 file2 file3 file4 % ls | cpio -ov -O test_archive file1 file2 file3 file4 16 블록 % cpio -ivt -I test_archive -rw-r--r-- 1 jijoe junik 71 12월 18 11:12 2007, file1 -rw-r--r-- 1 jijoe junik 99 12월 18 11:12 2007, file2 -rw-r--r-- 1 jijoe junik 127 12월 18 11:13 2007, file3 -rw-r--r-- 1 jijoe junik 155 12월 18 11:13 2007, file4 16 블록 % cpio -ivum -I test_archive file1 file2 file3 file4 16 블록 %
find 명령어
find 명령어는 지정한 디렉토리내에 존재하는 파일을 찾거나, 찾는 다양한 방법을 지정하여 사용할 수 도 있다.
find 명령을 cpio 명령과 함께 복합적으로 사용하면 유용하게 사용할 수 있다.
find에 따르는 인수는 적어도 디렉토리 이름은 최소한 지정하여야 한다. find 명령에 다양한 인수(argument)가 다음 표와 같이 사용된다.
argument | description |
---|---|
-atime n | n일 전후하여 억세스한 파일만 출력 |
-ctime n | n일 전후하여 status가 변경된 파일만 출력 |
-exec cmd | 각 출력되는 파일에 대해 cmd을 실행함 |
-group grp | GID grp에 속하는 파일만 출력 |
-mtime n | n일 전후하여 변경된 파일만 출력 |
-name pattern | 이름이 pattern과 일치하는 파일만 출력 |
-newer file | file보다 더 최근인 파일만 출력 |
선택된 파일을 print함 | |
-type c | 지정한 타입의 파일만 나열(block, character, directory, Door, fifo, link, plain, or socket) |
-user usr | UID usr나 사용자 이름으로 소유한 파일만 출력 |
find 명령을 효율적으로 사용하기 위해서는 and(-a)나 or(-o) 연산자와 함께 사용하면 보다 강력한 기능을 발휘한다.
예를 들어, -type p -a -user jijoe는 사용자 jijoe가 소유한 plain 파일만 찾을 것이다.
다음 첫 예는 /export/home/jijoe 디렉토리내에 있는 모든 파일을 찾아 jijoe.cpio라는 archive 파일로 저장한다.
# find /export/home/jijoe | cpio -o -O jijoe.cpio 96 블록 #
다음 예는 최근 2일내에 변경된 /etc 디렉토리내에 있는 파일을 출력하는 예이다.
# find /etc -mtime -2 /etc/saf/zsmon/_pmpipe /etc/saf/_sacpipe /etc/svc/volatile /etc/svc/volatile/init.state /etc/utmppipe #
또 다른 방법으로 etc.cpio로 출력하는 예이다.
# find /etc/ -mtime -2 | cpio -o -O etc.cpio 16 블록 #
file System administration
• Creating (making) file systems
• Checking and repairing file systems
• Mounting and unmounting file systems
• Accessing Data on CD-ROMs and Diskette
• Monitoring file system usage
• File and Directory Concept
• Backing up and restoring file systems, directories, and files
• Recovering the root or /usr File System