Buscar este blog

viernes, 15 de julio de 2011

Linux Tape Backup With mt And tar Command Howto

Magnetic tape is a non-volatile storage medium consisting of a magnetic coating on a thin plastic strip. Nearly all recording tape is of this type, whether used for video, audio storage or general purpose digital data storage using a computer. How do I make backup using tapes under Linux operating systems?


Linux (and other Unixish system) use mt command to control magnetic tape drive operation. You need to use mt command while working with tape drive. It allows you to reading and writing to tape.


The default tape drive under Linux is /dev/st0 (first SCSI tape device name). You can read more about tape drives naming convention used under Linux here. Following paragraph summaries command you need to use control tape drive for backup/restore purpose.



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

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

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

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

Fast format:
# dd if=/dev/zero of=/dev/st0 bs=512 count=1

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

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(b)

Goto previous record:
# mt -f /dev/nst0 bsfm 1(c)
Forward record:#
# mt -f /dev/nst0 fsf 1


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
Where,


    * 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

No hay comentarios:

Publicar un comentario