Re: Use tar to append?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09Mar2007 10:17, Mike McCarty <Mike.McCarty@xxxxxxxxxxxxx> wrote:
| Cameron Simpson wrote:
| >Presuming the latter, why not use one tar?
| >A plain "tar cf tarfile" or "tar czf tarfile.gz" will be nice and silent 
| >and
| 
| That's the way it works now. I don't want silence, I want progress
| reports of the top level directories.

Yes, I gathered.

| >Regarding progress reporting, "tar cvf" reports nicely but interleaves any
| >error message with the TOC, which is annoying and also hides the errors. I
| I don't want to watch the xterm it's running in. I want a wall.

Easily done. Read each line from the TOC, and hand the interesting few
to wall.

| >have a suggestion for this, which is a little tacky but may work quite
| >nicely:
| >
| >  >tarfile
| 
| This line looks like a syntax error to me. What is it
| supposed to accomplish?

It is not a syntax error. It truncates the tarfile, ensuring it exists before
the tail starts. It is otherwise possible for the tail to commence before the
tar creates the file. Unlikely, but possible.

| >  tar cf tarfile ... &
| >  tarpid=$!       
| >
| >  tailpid=`
| >          exec 3>&1 1>&2
| >          ( tail -f tarfile 3>&- & 
| >            echo $! >&3
| >          ) | ( exec 3>&-; tar tvf - | cat >/dev/tty ) &
| >          ` 
| >
| >  wait          # ... for the "tar cf"
| >  kill $tailpid # kill the tail
| [snip]
| 
| >The "cat >/dev/tty" is for demo purposes, writing the TOC to the terminal. 
| >Do
| >as you wish. Grepping for '/$' lists just the directories, for example.
| 
| Umm, two points. (1) Having one process writing and another reading
| the same archive results in a "chase", eating lots of resources
| while the reader tries to catch up with the writer.

Yes. Like I said, it's a little tacky.
Measured the load? How nasty is it?

| (2) I don't
| want a detailed report, I want a progress report so I can know
| approx. how much has been done.

Which is why I suggested you do something other than "cat", like "grep".
You post process the tvf output as you see fit.

| >How far does that go towards solving your problem?
| 
| I sure appreciate the effort. I don't want a detailed TOC.
| I generate that while verifying that the backup looks
| intact, and put that on the last CDROM. Just a little
| bit every once in a while to let me know how far it's
| gotten.

So grep with a pattern that matches your top level directories and hand each
interesting line to wall. Not hard.

The other way, which is a little harder, is to run a "tar cvf" and post
process its output as it goes. Have a look at "entar", a script of mine which
does exactly that:

  http://www.cskk.ezoshosting.com/cs/css/bin/entar

It writes the tar to stdout and and monitors the TOC as it comes past.
It could easily be adapted to report whatever process you wanted to
a wall.

I didn't mention it before because it's more complicated than the shell
script.

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Sorry, baby, I can't take you to the pizza joint tonight, I've got to go
back to the lab and split the atom.     - Ayn Rand, "What is Romanticism?"


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux