Thursday, October 22, 2009

Tape Backup With mt And tar Command

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

Backup directory /www and /home with tar command (z - compressed):
# tar -czf /dev/st0 /www /home

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

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

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

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

Display status information about the tape unit:
# mt -f /dev/st0 status

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

BACKWARD or FORWARD on tape with mt command itself:
(a) Go to end of data:
# mt -f /dev/nst0 eod(b) Goto previous record:
# mt -f /dev/nst0 bsfm 1(c) Forward record:
# mt -f /dev/nst0 fsf 1

To restore tape in case of data loss or hard disk failure:
# tar -xlpMzvf /dev/st0 /home

No comments: