Friday, May 06, 2011

Tape Drive Linux Commands: -

Check if tapedrive is online:
mt -f /dev/st0 status

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

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

Copy some content to a tapedrive:
tar -cvf /dev/st0 /content_path/content.archive

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

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

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

Restore from the tape
tar -xvf /dev/st0

Restore a specific archive
tar -xvf /dev/st0 /folder/archive.dmp

Extract the entire archive into current directory:
# tar xvpf /dev/st0

Extract only certain files or dirs into current directory.
For example. Extract only home/sukhi directory
# tar xvpf /dev/st0 home/ sukhi

You can also restore one file:
# tar xvpf /dev/st0 home/vivek/app/src/main.c

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

You can go 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

Replace /dev/st0 with your actual tape drive name.

Linux Tape Backup Example

To backup to multiple tape use the following command (backup /home file system):
# tar -clpMzvf /dev/st0 /home

To compare tape backup, enter:
# tar -dlpMzvf /dev/st0 /home

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

• d : find differences between archive and file system
• x : extract files from an archive
• l : list the contents of an archive
• p : ignore umask when extracting files
• M : create/list/extract multi-volume archive (multiple tapes)
• z : Compress backup using gzip
• v : verbosely list files processed
• f /dev/st0 : Tape device name
• /home : Backup /home file system


Sukhwinder Singh

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

There was an error in this gadget