[techtalk]tar hell, help!

bsweeney at physics.ucsb.edu bsweeney at physics.ucsb.edu
Sat Aug 4 10:04:04 EST 2001


'Lo all,

I discovered what I guess is a "feature" of the find-tar combo, which is
illustrated by my current situation.

I have a disk with a bunch of users data on it.  The folder structure is as
follows:

MAINDIR
  |
  |
  -SUBDIR1
  |    |
  |    - USERDIR1
  |    |     |
  |    |     -mail
  |    |     -other data
  |    -USERDIR2
  |          |
  |          -mail
  |          -otherdaatasut
  -SUBDIR2
       |
       -USERDIR3
             |
             -mail
             -still more data

...etc.

Now, what I want to do is extract the mailfolder along with the appropriate
folder and path to a new MAINDIR2 folder, which currently has nothing in
it.  So, I figured find/tar would be able to do this.  So I executed the
following command while in MAINDIR:

	find . -name mail -exec tar --preserve --same-owner -r -v -
f /MAINDIR2/somearchivefile.tar {} \;

And it created the archive nicely with all the folders and paths and
whatnot.  Then, in MAINDIR2, I did the following to extract:
	tar -xv --preserve --same-owner -f somearchivefile.tar

And viola! It extracted all the mail folders and subfolders with
appropriate paths, so now I have:

MAINDIR2
  |
  |
  -SUBDIR1
  |    |
  |    - USERDIR1
  |    |     |
  |    |     -mail
  |    |
  |    -USERDIR2
  |          |
  |          -mail
  |
  -SUBDIR2
       |
       -USERDIR3
             |
             -mail

The problem here is that though tar kept the permissions and file
ownerships for the mail directories and sub directories, it DID NOT keep
them for the preceeding directories (i.e., USERDIRS or SUBDIRS).  I'm
guessing that that's because it was told to archive the maildirectories,
and is only creating the paths itself, so it creates them as whoever the
user executing the tar extraction is.

This, however, doesn't help me.  I've got 300+ USERDIRS, and can't
(obviously) chown them all by hand afterwords.

Any suggestions?  CPIO maybe (I'm looking at that now)?

Sorry if there's an obvious answer here I'm not seeing.  I would normally
do more research BEFORE asking, but the mailserver is down (which is why
I'm dealing with this), and the users are screaming.  Yuk.

Which brings me to my next point: please reply to
bsweeney at webmail.physics.ucsb.edu (my backup mailserver) and NOT JUST to
the list, 'cause I can't get mail for the address I have subscribed to the
list right now.

Thanks is advance all,
Brian

"Don't tell me you're on salary?  And you're working on Saturday?"
-My roomate





More information about the Techtalk mailing list