[Howto] - Linux Tape Backup 指令
2011/10/04
檢查是系統是否有抓到
[root@example ~]# cat /proc/scsi/scsi Attached devices: Host: scsi0 Channel: 00 Id: 05 Lun: 00 Vendor: HP Model: Ultrium 3-SCSI Rev: G6D Type: Sequential-Access ANSI SCSI revision: 03 .... ....
SCSI TapeDrive 命名規則
Ex: /dev/[n]stX{l,m,a} => l,m,a 代表壓縮比率 l: low m: medium a: high
自動迴帶(rewind) /dev/stX
每次將資料備入磁帶後,會做自動回帶動作。First auto rewind SCSI tape device name: /dev/st0 Second auto rewind SCSI tape device name: /dev/st1
[root@example ~]# ls -l /dev/nst0* crw-rw---- 1 root disk 9, 128 Oct 4 08:37 /dev/nst0 crw-rw---- 1 root disk 9, 224 Oct 4 08:37 /dev/nst0a crw-rw---- 1 root disk 9, 160 Oct 4 08:37 /dev/nst0l crw-rw---- 1 root disk 9, 192 Oct 4 08:37 /dev/nst0m
非自動迴帶(no-rewind) /dev/nstX
每次的磁帶寫入後,不做迴帶動作,將讀寫頭(tape head)停留在最後寫入資料的位置.First non-rewind SCSI tape device: /dev/nst0 Second non-rewind SCSI tape device: /dev/nst1
[root@example ~]# ls -l /dev/nst0* crw-rw---- 1 root disk 9, 128 Oct 4 08:37 /dev/nst0 crw-rw---- 1 root disk 9, 224 Oct 4 08:37 /dev/nst0a crw-rw---- 1 root disk 9, 160 Oct 4 08:37 /dev/nst0l crw-rw---- 1 root disk 9, 192 Oct 4 08:37 /dev/nst0m
相關操作指令
Check status(檢查狀態)
# mt -f /dev/st0 status SCSI 2 tape drive: File number=0, block number=0, partition=0. Tape block size 0 bytes. Density code 0x44 (no translation). Soft error count since last status=0 General status bits on (41010000): BOT ONLINE IM_REP_EN
狀態值說明:
- ONLINE: 磁帶機狀態正常且已載入磁帶
- DR_OPEN: 磁帶機上沒有磁帶
- BOT: 目前位置在Tape的最開頭(beginning of the tape)
- EOF: 目前的位置在檔案的開頭(beginning of a file), 容易搞混,就字面而言,是代表(End of file)
- EOT: 目前位置在Tape的最尾端(end of the tape)
- EOD: 目前位置在已寫入資料的最尾端(end of recorded media)
- WR_PROT: 此磁帶狀況為唯讀(read-only)
Erase tape drive(清除)
# mt -f /dev/st0 erase
Unload the tape drive(卸載):
# mt -f /dev/st0 offline
Rewind tape drive(迴帶)
# mt -f /dev/st0 rewind
Backup directory /etc and /var/www 備份資料
# tar -cvf /dev/nst0 /etc /var/www # tar -zcvf /dev/nst0 /etc /var/www => 加上壓縮
Display list of files on tape drive(顯示備份資料):
# tar -tvf /dev/nst0 # tar -tzvf /dev/nst0
Restore /etc drectory(還原備份):
# cd / # mt -f /dev/st0 rewind # tar -x[z]vf /dev/nst0 etc
Tape device 也可以往前(Forward)或是往後退(Backward)
- Go to end of data(到備份磁帶最後端)
- Go to previous record(往後)
- Forward record(往前):
# mt -f /dev/nst0 eod
# mt -f /dev/nst0 bsfm 1
# mt -f /dev/nst0 fsf 1
Reference:
標籤:
Linux