Unix Shell - Checking tarfile's created date from tape?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2005 > Checking tarfile's created date from tape?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Checking tarfile's created date from tape?
John F.

2005-09-26, 6:02 pm

I have written a tarfile to tape and need to read its create date to
std out so that I can compare it to the dated of my last good backup
(Checking to be sure that I'm not overwriting my latest backup) Sorry
for this simplistic question but it's giving me fits for some reason.
How can I get the tarfile's create date?

This very broken example shows what I'm *trying* to do...
tar -xf0 /dev/st0 | stat %y | grep Modify

Thanks
JF

Bill Marcum

2005-09-26, 6:02 pm

On 26 Sep 2005 09:32:47 -0700, John F.
<hikenboots@gmail.com> wrote:
> I have written a tarfile to tape and need to read its create date to
> std out so that I can compare it to the dated of my last good backup
> (Checking to be sure that I'm not overwriting my latest backup) Sorry
> for this simplistic question but it's giving me fits for some reason.
> How can I get the tarfile's create date?
>

tar tvf /dev/st0
When a tar file is written to a device, I'm not sure if there is a time
stamp for the entire archive. You can grep the "tar tvf" output to look
for a file that is known to be newer than the previous backup.


--
"In matrimony, to hesitate is sometimes to be saved."
-- Butler
Enrique Perez-Terron

2005-09-26, 6:02 pm

On Mon, 26 Sep 2005 19:50:12 +0200, Bill Marcum <bmarcum@iglou.com> wrote:

> On 26 Sep 2005 09:32:47 -0700, John F.
> <hikenboots@gmail.com> wrote:
> tar tvf /dev/st0
> When a tar file is written to a device, I'm not sure if there is a time
> stamp for the entire archive. You can grep the "tar tvf" output to look
> for a file that is known to be newer than the previous backup.


Right, a tar archive does not contain a creation date.
You should create a time-stamp file just before you write the tape, and
ensure that this file is among the first files copied to the archive.

If you are backing up the directory /dev (crazy thing to do) tar will
only write a record describing each device node, not back up the contents
of all devices in /dev (thank god). But there is /dev/st0, and it will
have its date continuously changing as the tape is written. So, you
could extract the device node from the tape:

tar tvf /dev/st0 /dev/st0 | command-to-check-the-date-in-the-line

If you are not backing up /dev, you can allways include /dev/st0
as a first object to back up:

tar cf /dev/st0 /dev/st0 directory-to-back-up

(Notice that the device name appears twice, once as an argument to
the f flag, and once as the first object to back up.)

Another simple way to achieve a date is, if to touch the top directory
you are backing up:

touch directory-to-back-up
tar cf0 /dev/stty directory-to-back-up

Then you only need to read the stat data of the top directory off the
tape, as before:

tar tvf /dev/st0 | head -1 | command-to-check-the-date-in-the-line

-Enrique
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com