Preserving symbol link dirs 

> > I found that the 'tar' command has the following limitation:
> >
> > Say my tar archive contains the following directory structure:
> >
> > dir1/dir11
> > dir1/dir12
> > dir1/dir13
> >
> > And, the dir1/dir12 is very big. Bigger than what the current volume can
> > hold. As a way to workaround, I created the above directory structure
> > manually, and the dir1/dir12 is actually a symbol link into a bigger
> > volume that can hold the content.
> >
> > However, when I expend my tar archive into my created directory
> > structure, the symbol link dir1/dir12 get overwritten, and recreated as
> > a directory.
> >
> > Is there any way for tar, or any other commands (e.g., cpio, rsync) to
> > preserve my created directory structure, expand/copy files into it, not
> > trying to recreate every directory even it is there?
> >
> > This is only a simple example, for illustration purpose only. If tar can
> > do so, it would be greatly enhance its versatility.
>
> Are you preserving permissions when you pack and unpack the tar file?
>
> tar cpvf  filename.tar directory
> tar xpvf  filename.tar

hmm, no I didn't. I thought tar preserves permissions by default. Anyway, I gave it a try, but preserving permissions doesn't help:

$ find
./dir1
./dir1/dir11
./dir1/dir12
./dir1/dir12/aa
./dir1/dir13
$ tar cpvf test.tar dir1
dir1/
dir1/dir11/
dir1/dir12/
dir1/dir12/aa
dir1/dir13/

Now recreate dir1/dir12 as a symbol link!

rm -rf ./dir1/dir12
mkdir dirnew
ln -s ../dirnew ./dir1/dir12
$ ls -l ./dir1/dir12
lrwxrwxrwx    1 tong     tong   9 Oct 24 09:55 ./dir1/dir12 -> ../dirnew

Hmmm, yeah, it is there. Now, expand the tar.

$ tar xpvf test.tar
dir1/
dir1/dir11/
dir1/dir12/
dir1/dir12/aa
dir1/dir13/
$ ls -ld ./dir1/dir12
drwxrwx--x    2 tong     tong         4096 Oct 24 09:54 ./dir1/dir12

See, the previously manually created directory dir1/dir12 (a symbol link) is gone. Instead, it has changed back to a normal directory, which defeats what I was trying to do.

Any other suggestion? Thanks

Preserving symbol link dirs 

rsync is not a solution either. Even using the most basic -r swith instead of full fledged -a swith will cause the symbol link directory be overwritten as a normal directory.

Preserving symbol link dirs 

cpio is also nok:

mkdir -p dir1/dir1{1,2,3}
touch ./dir1/dir12/aa
 find
tar cpvf test.tar dir1
rm -rf ./dir1
mkdir -p dirnew/dir1{1,2}
ln -s dirnew/dir11 dir1
ln -s ../../dirnew/dir12 ./dir1
lrwxrwxrwx    1 tong     tong  18 Oct 24 10:41 dir1/dir12 -> ../../dirnew/dir12/
lrwxrwxrwx    1 tong     tong  12 Oct 24 10:48 dir1 -> dirnew/dir11/
mkdir dirs
cd dirs
tar xvf ../test.tar
find dir1
$ find dir1 | cpio  -vpdm ../
cpio: ..//dir1 not created: newer or same age version exists
..//dir1/dir11
cpio: ..//dir1/dir12 not created: newer or same age version exists
..//dir1/dir12/aa
..//dir1/dir13
0 blocks
$ find dir1 | cpio  -vpdmu ../
..//dir1
..//dir1/dir11
..//dir1/dir12
..//dir1/dir12/aa
..//dir1/dir13
0 blocks
-rw-rw----    1 tong     tong            0 Oct 24 09:54 dir1/dir12/aa
drwxrwx--x    2 tong     tong         4096 Oct 24 10:46 dir1/dir12/
drwxrwx--x    5 tong     tong         4096 Oct 24 10:46 dir1/