backup 관련 명령어 요약
1. mt 명령어
blue# mt -f /dev/rmt/0 status -> backup device의 상태를 표시
HP JetStore 6000 C1533 tape drive:
sense key(0x6)= Unit Attention residual= 0 retries= 0
file no= 0 block no= 0
blue# mt -f /dev/rmt/0 status
HP JetStore 6000 C1533 tape drive:
sense key(0x13)= EOT residual= 0 retries= 0
file no= 1 block no= 0
blue# mt -f /dev/rmt/0n status
HP JetStore 6000 C1533 tape drive:
sense key(0x0)= No Additional Sense residual= 0 retries= 0
file no= 4 block no= 0
blue# mt -f /dev/rmt/0n eom -> tape의 맨끝으로 이동
blue# mt -f /dev/rmt/0 rewind -> tape를 제일 처음으로 되감는다.
blue# mt -f /dev/rmt/0n fsf [count] -> count 갯수 만큼 화일뒤로 건너 띈다.
blue# mt -f /dev/rmt/0n bsf [count] -> count 갯수 만큼 화일 앞으로 건너 띈다.
blue# mt -f /dev/rmt/0 erase -> tape의 모든 내용을 지운다. tape나 device에 따라다르나 시간이 많이 걸린다.
blue# mt -f /dev/rmt/0 offline -> tape가 eject 된다.
2. tar 명령어
blue# tar tvf /dev/rmt/0 -> tape의 내용을 확인함
-rw-r--r-- 0/3 6434 1997년 7월 16일 12:47 st.conf
blue# tar xvf /dev/rmt/0 -> tape에있는 내용를 Hard disk로 내림
x st.conf, 6434 bytes, 13 테이프 블럭
blue# tar cvf /dev/rmt/0 /etc/hosts -> Hard disk에있는 file 이나 directory를 tape로 받음
/etc/hosts는 ./inet/hosts와 기호 링크됨
blue# tar tvf /dev/rmt/0
lrwxrwxrwx 0/0 12 1998년 3월 5일 10:01 hosts ./inet/hosts로 심볼릭 링크됨
-r--r--r-- 0/3 558 1998년 4월 16일 19:15 passwd
-r-------- 0/3 333 1998년 4월 16일 19:15 shadow
blue# tar rvf /dev/rmt/0 group -> replace, tarfile의 끝에 추가한다.
a group 1 테이프 블럭
blue# tar tvf /dev/rmt/0
lrwxrwxrwx 0/0 12 1998년 3월 5일 10:01 hosts ./inet/hosts로 심볼릭 링크됨
-r--r--r-- 0/3 558 1998년 4월 16일 19:15 passwd
-r-------- 0/3 333 1998년 4월 16일 19:15 shadow
-rw-r--r-- 0/3 295 1998년 4월 16일 19:12 group
blue# tar cvfb - 20 files | rsh host dd of=/dev/rmt/0 obs=20b -> remote host에있는 drive로 backup 받기
blue# rsh -n host dd if=/dev/rmt/0 bs=20b |tar xvBfb - 20 files -> remote host에있는 drive로 backup 내리기
3. ufsdump 명령어
3.1 한개의 화일 시스템을 받을경우
blue# ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0 -> full dump
DUMP: Writing 63 Kilobyte records
DUMP: Date of this level 0 dump: 1998년 4월 29일 수요일 오전 11시 03분 20초
DUMP: Date of last level 0 dump: the epoch
DUMP: Dumping /dev/rdsk/c0t0d0s0 (blue:/) to /dev/rmt/0n.
DUMP: Mapping (Pass I) [regular files]
DUMP: Mapping (Pass II) [directories]
DUMP: Estimated 1703122 blocks (831.60MB).
DUMP: Dumping (Pass III) [directories]
DUMP: Dumping (Pass IV) [regular files]
DUMP: 63.88% done, finished in 0:05
DUMP: 1703014 blocks (831.55MB) on 1 volume at 793 KB/sec
DUMP: DUMP IS DONE
3.2 ufsdump option
- 0 - 9 : 덤프레벨로 "0"은 full dump를 의미하고 "1 - 9"는 점진적인 백업을 말한다. /etc/dumpdate를 기준으로 백업한다.
- u : /etc/dumpdate에 기록한다.
- c : Catridge, 이옵션은 1000BPI density 와 126 blocking factor로 맞춘다.
- l : Autoload , dump가 끝나기전에 tape의 끝을 만나면 다음 테이프를 load한다.
- v : verify
- S : 용량을 계산한다. 실제로 백업받지는 않는다.
- f dump_file : 화일 이미지를 dump_file에 기록한다. dump_file은 /dev/rmt/0 대신에 file이 될 수있다. 만약 dump_file이 "-" 이라면 표준 출력으로 dump된다. hostname:device 표기법으로 원격시스템에 있는 장치를 사용할 수도있다. ex) ufsdump 0ucf blue:/dev/rmt/0 /dev/rdsk/c0t0d0s0
- w : /etc/dumpdate를 기준으로 가장 최근에 백업되지 않은 /etc/vfstab내의 ufs 화일 시스템을 모두 출력한다.
blue# ufsdump 0Sf /dev/rmt/0 /dev/rdsk/c0t0d0s0
873689088
blue# ufsdump w
Dump these file systems:
/dev/rdsk/c0t0d0s0 ( /) Last dump: Level 0, Date Wed Apr 29 12:50
/dev/rdsk/c0t0d0s7 (/export/home) Last dump: Level 0, Date Sat May 2 12:57
/dev/rdsk/c0t1d0s0 ( ) Last dump: Level 0, Date Wed Apr 29 11:23
blue# cat dumpdates
/dev/rdsk/c0t0d0s0 0 Wed Apr 29 12:50:50 1998
/dev/rdsk/c0t0d0s7 0 Sat May 2 17:20:01 1998
/dev/rdsk/c0t1d0s0 0 Wed Apr 29 11:23:19 1998
- Sample Dump Schedule
0 once a month 0 once a month
월 화 수 목 금 토 월 화 수 목 금 토
5 5 5 5 5 3 3 4 5 6 7 2
5 5 5 5 5 3 3 4 5 6 7 2
5 5 5 5 5 3 3 4 5 6 7 2
5 5 5 5 5 3 3 4 5 6 7 2
월 화 수 목 금 토 월 화 수 목 금 토
0 <--| 0 <---|
<--------| <----|
<--------------| <----|
<-------------------| <---|
<------------------------| <---|
<------------------------------| <--------------------------------|
3.3 여러개의 filesystem을 하나의 테이프에 받을경우
blue# ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0;ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s7
DUMP: Writing 63 Kilobyte records
DUMP: Date of this level 0 dump: 1998년 4월 29일 수요일 오전 11시 03분 20초
DUMP: Date of last level 0 dump: the epoch
DUMP: Dumping /dev/rdsk/c0t0d0s0 (blue:/) to /dev/rmt/0n.
DUMP: Mapping (Pass I) [regular files]
DUMP: Mapping (Pass II) [directories]
DUMP: Estimated 1703122 blocks (831.60MB).
DUMP: Dumping (Pass III) [directories]
DUMP: Dumping (Pass IV) [regular files]
DUMP: 63.88% done, finished in 0:05
DUMP: 1703014 blocks (831.55MB) on 1 volume at 793 KB/sec
DUMP: DUMP IS DONE
DUMP: Level 0 dump on 1998년 4월 29일 수요일 오전 11시 03분 20초
DUMP: Writing 63 Kilobyte records
DUMP: Date of this level 0 dump: 1998년 4월 29일 수요일 오전 11시 21분 18초
DUMP: Date of last level 0 dump: the epoch
DUMP: Dumping /dev/rdsk/c0t0d0s7 (blue:/export/home) to /dev/rmt/0n.
DUMP: Mapping (Pass I) [regular files]
DUMP: Mapping (Pass II) [directories]
DUMP: Estimated 303300 blocks (148.10MB).
DUMP: Dumping (Pass III) [directories]
DUMP: Dumping (Pass IV) [regular files]
DUMP: 303280 blocks (148.09MB) on 1 volume at 1269 KB/sec
DUMP: DUMP IS DONE
4. ufsrestore 명령어
4.1 Restoring Entire File System
blue# mount /dev/dsk/c0t0d0s7 /export/home
blue# cd /export/home
blue# mt -f /dev/rmt/0n fsf 1 -> 다음 point로 이동
blue# ufsrestore rvf /dev/rmt/0n
Verify volume and initialize maps
Media block size is 126
Dump date: Sat May 02 12:57:43 1998
Dumped from: the epoch
Level 0 dump of /export/home on blue:/dev/dsk/c0t0d0s7
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Warning: ./lost+found: File exists
Make node ./cyberguy
Make node ./dsw
Make node ./dsw/core
Make node ./crash
Make node ./crash/blue
Make node ./test
Extract new leaves.
Check pointing the restore
extract file ./.CPR
extract file ./dsw/core/unix.2
extract file ./dsw/core/vmcore.2
extract file ./dsw/core/threadlist.0
extract file ./dsw/core/threadlist.2
extract file ./crash/blue/vmcore.0
extract file ./crash/blue/unix.0
extract file ./crash/blue/bounds
extract file ./crash/blue/threadlist.0.org
extract file ./crash/blue/threadlist.0
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
blue# pwd
/export/home
blue# ls
crash dsw restoresymtable
cyberguy lost+found test
blue# rm restoresymtable
4.2 ineractive restore
blue# cd /var/tmp
blue# ufsrestore ivf /dev/rmt/0
Verify volume and initialize maps
Media block size is 126
Dump date: Mon May 11 14:33:16 1998
Dumped from: the epoch
Level 0 dump of /user on blue:/dev/dsk/c0t1d0s3
Label: none
Extract directories from tape
Initialize symbol table.
ufsrestore > ls
.:
2 *./ 2 *../ 3 lost+found/ 4 passwd
ufsrestore > cd lost+found
ufsrestore > cd /
ufsrestore > add passwd lost+found
ufsrestore > verbose
verbose mode off
ufsrestore > verbose
verbose mode on
ufsrestore> delete lost+found
ufsrestore > ls
.:
2 *./ 2 *../ 3 lost+found/ 4 *passwd
ufsrestore > extract
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./passwd
Add links
Set directory mode, owner, and times.
set owner/mode for '.'? [yn] n
ufsrestore > quit
4.3 restore files
# ufsrestore xvf /dev/rmt/0 ./etc/passwd
4.4 display the content of the tape
# ufsrestore tvf /dev/rmt/0
5. cpio commands
blue# find . -print | cpio -ovcB > /dev/rmt/0 -> 현디렉토리의 내용을 tape로 backup 받는다.
.
upgrade
upgrade/Agree.ps
upgrade/Announcement.ps
upgrade/Program.ps
upgrade/Refund.ps
upgrade/URCFORM.ps
array
array/DECptscII
array/DECptscII/pkgmap
array/DECptscII/pkginfo
array/DECptscII/root
array/DECptscII/root/kernel
array/DECptscII/root/kernel/drv
array/DECptscII/root/kernel/drv/classes
array/DECptscII/root/kernel/drv/ptscII.52
array/DECptscII/root/kernel/drv/ptscII.53
array/DECptscII/install
array/DECptscII/install/copyright
array/DECptscII/install/postinstall
array/DECptscII/install/preremove
array/DECstgwks
array/DECstgwks/pkgmap
array/DECstgwks/pkginfo
array/DECstgwks/root
array/DECstgwks/root/$TRANSDIR
array/DECstgwks/root/$TRANSDIR/sd.conf
array/DECstgwks/root/$TRANSDIR/trans.Z
array/DECstgwks/root/$TRANSDIR/trans.conf
blue# cpio -ivcB array/DECstgwks/install/space < /dev/rmt/0 -> tape에서 space file을 extract한다.
array/DECstgwks/install/space
8550 blocks
blue# find . -mtime -7 -print | cpio -ovcB > /dev/rmt/0n -> 최근 일주일내에 수정된 file을 tape로 받는다.
.
upgrade
upgrade/Agree.ps
upgrade/Announcement.ps
upgrade/Program.ps
upgrade/Refund.ps
blue# find . -name 'file*' -print | cpio -ovcB > file.list
blue# cpio -ivt < file.list
6. Backup script sample
#!/bin/csh
set verbose
set day = `date +%y%m%d`
mt -f /dev/rmt/0n rew
ufsdump 0uf /dev/rmt/0bn /
ufsdump 0uf /dev/rmt/0bn /usr
ufsdump 0uf /dev/rmt/0bn /var
ufsdump 0uf /dev/rmt/0bn /export/home
ufsdump 0uf /dev/rmt/0bn /opt
echo "now test the backups."
mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 1 > /export/home/bert/dumpfile1.${day}
mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 2 > /export/home/bert/dumpfile2.${day}
mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 3 > /export/home/bert/dumpfile3.${day}
mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 4 > /export/home/bert/dumpfile4.${day}
mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 5 > /export/home/bert/dumpfile5.${day}
7. Sun O/S backup parameter
High density Fujitsu/Xylogics 1/2" tape
# dump 0uf /dev/rmt8 /dev/rxy0
600' QIC-24 9 track 1/4" cartridge tape
# dump 0ucf /dev/nrst8 /dev/rds0h
QIC-150 18 track 1/4" catridge tape:
# dump 0ucsf 1500 /dev/rst0 /dev/rsd0h
Exabyte 8mm catridge tape:
# dump 0usf 145000 /dev/rst0 /dev/rid001h
대상 O/S : Solaris 2.x , Sun O/S
'IT > Unix' 카테고리의 다른 글
vmstat 필드 설명 (0) | 2009.04.21 |
---|---|
Network 관련된 11개 파일 (0) | 2009.02.26 |
DNS 설정 (0) | 2009.02.05 |
메모리 사용량 (0) | 2009.01.09 |
fuser (0) | 2009.01.07 |