The way your shell program is written, the first argument to the
tar command ($TAR) is the tape drive ($TAPE); i.e.,
/dev/IBMtape0. So, the tape
is the tape archive (that's what
tar means, an acronym of
tape
archive. So, what you see on the tape is a list of directory and file names that are a copy of the location (directory) and content (file).
The other way to look at that is if you used
tar to create a file named, say,
2012-06-14.tar (for example) somewhere on your disk drive(s) then compress that into what's called a
tarball (say,
2012-06-14.tar.gz) then copy that to the tape as one big (but compressed)
tar archive. You'd do that something like this
Code:
tar cvf 2012-06-14.tar $DIR $BACKUP_ROOT_DIR
<wait a while>
gzip 2012-06-14.tar
<which compresses the archive into 2012-06-14.tar.gz>
cp 2012-06-14.tar.gz /dev/IBMtape0
You can do that in a pipeline (see below) but those are the basic steps to get a date stamped compressed archive on tape (or CD-ROM or DVD or Blu-ray disc media for that matter). The way your shell program is doing it, the archive is not compressed or date stamped.
You have to consider, though, whether you have sufficient room on the tape for more than one back up of the system root (or whatever file tree on the disk drive) directory (some tape systems do, some don't, some will write on more than one cartridge, some won't). It may be simpler to, you know, write the date on the label and be done with it.
A slick way to create the archive file name is
Code:
tar -cvf `date +%F`.tar.gz <other arguments>
If you want to add a directory name to that
Code:
tar -cvf /tmp/`date +%F`.tar <other arguments>
Those "`...` are "sideways pipes," they can also be done
$(date +%F) (definitely in KornShell, pretty sure in BASH too).
Now, let's combine stuff.
You can compress on-the-fly by adding
z for
gzip or
j for
bzip2 in the
tar arguments:
Code:
tar -czvf /tmp/`date +%F`.tar.gz <other arguments>
for
gzip (replace the
z with
j for
bzip2.
You might want to avoid the
v (which shows you the file names) unless you're keeping a log.
So, all in one go
Code:
# Create a date stamp name for the archive
FILE_NAME=/tmp/`date +%F`.tar.gz
# Create a gzip tar archive in /tmp/yyyy-mm-dd.tar.gz
tar czf $FILE_NAME $DIR $BACKUP_ROOT_DIR
# Copy the archive file to tape
cp $FILE_NAME $TAPE
# Remove the archive file
rm $FILE_NAME
You can do the entire thing in one line but you have to use
dd to do it which means that you have to know the input block size of the tape and some other stuff. Just as easy to use two line to accomplish the job.
Hope this helps some.