Monday, August 30, 2004

Tape Backups in Linux / Unix

Comming to the topic of backups

To begin with here are some wordings from Linus Torvalds Himself :

Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it. -- Linus Torvalds, about his failing hard drive on

Another Cool Link describing backup is :

The most important concept with tape drives under Linux is rewinding and non-rewinding tape devices. Typically, /dev/st0 is your rewinding tape device, while /dev/nst0 is your non-rewinding tape device


Dump is a sourceforge project available on :

Dump examines files on an ext2/3 filesystem and determines which files need to be backed up. Either a mountpoint of a filesystem or a list of files and directories can be specified for backup. The target filesystem can be specified by its raw device name if it is unmounted (which is actually preferrable). The target is copied to the given disk, tape or other storage medium for safe keeping. A dump that is larger than the output medium is broken into multiple volumes.

Dump recognizes different levels of incremental backups in addition to performing a full backup. At one point in the past, incremental backups made sense for a variety of economic reasons. However the cost of media is low enough today to warrant the reduced headache of performing a full backup each and every time.

Dump is instructed to perform a level 0 full backup which guarantees the entire file system is copied (-0), to bypass all tape length calculations and write until an end-of-media indication is returned (-a), update the file /usr/local/etc/dumpdates after a successful dump (-u), abort the entire dump in the case of write errors rather than entering into an interactive prompt (-q), use 64 KB per dump record (-b 64), and write to the non-rewinding tape device (-f /dev/nst0).

A simple script to backup your whole system would be

#dump -0auqb 64 -f /dev/nst0 /dev/sda3

where 0 specifies Full Backup of file system /dev/sda3

To backup say a certain directory then

#dump -0uf /dev/st0 /home/neo

A simple script to restore your backup would be

mt -f /dev/st0 rewind
echo "Restore from which session number?"
read number
restore -ivf /dev/nst0 -b 64 -s $number
But i guess dump has either been deprecated from Rh AS 2.1 or mebe my friend forgot to add it.

Then comes into help our favourite utility *tar*

#tar -cvf /dev/st0 /home /opt

This would back up directories /home and /opt (and their sub directories roo) on the tape device /dev/st0

To restore the backup :

#tar -xvf /dev/st0

Some additional commands
1. zip the tar file to save on space : tar -z -cvf /dev/st0 /home /opt
2. List contents of tape: tar -tf /dev/st0
3. List contents of compressed backup tape: tar -tzf /dev/st0

Incremental backups are also possible with tar.

Please do a man tar to know more about it.

.... Nitin ....


Post a Comment

<< Home