Linux Tape Backup With mt And tar Command

Working with “mt” Commands: reading and writing to tape.

The following assumes the tape device is “/dev/st0”
Display status information about the tape unit:

Install MT command on Linux 
Download the rmp files
Then install as below
Log in to server as root
copy downloaded  mt rpm file to Linux server using  wincp  or related software
[root@localhost ~]# rpm -ivh mt-st-0.5-1.i386.rpm
I have tested with oracle Linux 5.4
Now you will be able to access mt command as bellows
# mt -f /dev/st0 status

Unload the tape:
# mt -f /dev/st0 offline

Rewind tape drive:
# mt -f /dev/nst0 rewind

Find out what block you are at with mt command:
# mt -f /dev/nst0 tell

Backup directory /www and /home with tar command (z – compressed):

# tar -czf /dev/nst0 /www /home

Display list of files on tape drive:
# tar -tzf /dev/nst0

Restore /www directory:
# cd /
# mt -f /dev/nst0 rewind
# tar -xzf /dev/nst0 www

Erase the tape:
# mt -f /dev/nst0 erase

You can go FORWARD or BACKWARD on tape with mt command itself:
(a) Forward record:
# mt -f /dev/nst0 fsf 1

(b) Goto previous record:
# mt -f /dev/nst0 bsfm 1

(c) Go to end of data:
# mt -f /dev/nst0 eod


电子邮件地址不会被公开。 必填项已用*标注