Friday, December 26, 2008

WORKING WITH TAPE DRIVES


Naming of SCSI tape device

The st driver provides the interface to a variety of SCSI tape devices under Linux.

  • First (auto rewind) SCSI tape device name: /dev/st0
  • Second (auto rewind) SCSI tape device name: /dev/st1
  • First the non-rewind SCSI tape devices: /dev/nst0
  • Second the non-rewind SCSI tape devices: /dev/nst1


Naming of IDE tape device

The ht driver provides the interface to a variety of IDE tape devices under Linux.

  • First (auto rewind) IDE tape device name: /dev/ht0
  • Second (auto rewind) IDE tape device name: /dev/ht1
  • First the non-rewind IDE tape devices: /dev/nht0
  • Second the non-rewind IDE tape devices: /dev/nht1

 

Find out at which block you are with mt command:

 

# mt -f /dev/st0 tell

 

 

Check if tape drive is online: # mt -f /dev/st0 status

OUTPUT :

SCSI 2 tape drive:

File number=0, block number=0, partition=0.

Tape block size 0 bytes. Density code 0x40 (DLT1 40 GB, or Ultrium).

Soft error count since last status=0

General status bits on (41010000):

BOT ONLINE IM_REP_EN

 

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

 

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

Copy some content to a tape drive : # tar -cvf /dev/st0 /content_path/content.archive

List files on a tape
: # tar -tvf /dev/st0

Restore from the tape: # tar -xvf /dev/st0

Restore an specific archive: # tar xvf /dev/st0 /folder/archive.dmp

 

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

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

 

Restore /www directory:

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

 

Unload the tape:

# mt -f /dev/st0 offline

 

You can go BACKWARD or FORWARD on tape with mt command itself:
Go to end of data:# mt -f /dev/nst0 eod

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

Forward record:# mt -f /dev/nst0 fsf 1

 

tar backup on tape through ssh

# tar -cvzf /www | ssh root@station.domain.com "cat > /backup/www.tar.gz"

OR

# tar zcvf - /www | ssh root@192.168.1.101 "cat > /backup/www.tar.gz"

Output:

tar: Removing leading `/' from member names
/www/
/www/n/xx.in/
/www/c/zasx.asd/
....
..
 

You can also use dd command for clarity purpose:

# tar cvzf - /www | ssh root@192.168.1.101 "dd of=/backup/www.tar.gz"

It is also possible to dump backup to remote tape device:

# tar cvzf - /www | ssh ssh root@192.168.1.101 "cat > /dev/st0"

OR

you can use mt to rewind tape and then dump it using cat command:

# tar cvzf - /www | ssh ssh root@192.168.1.101 $(mt -f /dev/st0 rewind; cat > /dev/st0)$

You can restore tar backup over ssh session:

# ssh root@192.168.1.101 "cat /backup/www.tar.gz" | tar zxvf - 

1 comment:

Anonymous said...

nice site, like to see more information.