UNIX Tip of the Week

Easy backup


This example assumes that the raw device name for the tape drive is /dev/st0, which is a pretty safe bet for a SCSI tape drive on a Linux system.


Creating the backup

Suppose you want to commit /forest/trees/oak (and everything below it) to tape.
Just cd to /forest/trees and incant
tar -cf /dev/st0 oak

Restoring the backup

Load the tape in the drive, cd to wherever you want to restore oak, then incant
tar -xf /dev/st0
The tar command will create the directory oak in whatever directory you're in.


Log file options

If you want to see what's going to or from tape, you can use the -v option to tar:
tar -cvf /dev/st0 oak
And if you want to create a log file (oak.log in this example) as well as to display the files to the screen, you can
tar -cvf /dev/st0 oak | tee oak.log
And as always, please man tar.


Revised: February 16, 2000