SUMM: Easiest way to move a directory tree

From: Guy Dallaire <dallaire_at_total.net>
Date: Wed, 07 May 1997 10:36:57 -0400

Thanks for your many replies:
Dan Bowman <dbowman_at_sph.jhu.edu>,
Lucio Chiappetti <lucio_at_ifctr.mi.cnr.it>,
Olle Eriksson <olle_at_cb.uu.se>,
And everyone else that I could forget

Most of you told me that I was almost right with my command, but that I
neglected to put the 'p' option for the extraction. Also, in order to
preserve setuid and setgid permissions, you have to be root when you copy
the directory.

Someone also suggested that I use the 'cp -pR' command to copy the tree,
this should preseve the sym links.

Here is the original question:
---------------------------
I have to move a HUGE directory tree (oracle software installation) to a
different file system. I made some preliminary tests and I am not satisfied
with the results. I don't want to ressort to a backup/restore of the
directory.

Here is my problem: The various subdirectories contains symbolic links, I
had problems moving it with mv, got error messages. I also tried with the
following command:

    cd fromdir; tar -cf . | (cd todir; tar xf -)

In this case, the file timestamps changed (when I do an ls -l). Is there a
way to move that directory tree somewhere else and:

        a) Preserve the same file protections
        b) Preserve the files timestamps
        c) Preserve file ownership
---------------------------

And (some) answers:

---------------------------
  You did it almost. What is missing is the "p" (preserve) flag.
  The way I use to move a tree is

  tar cmpf - -C origin . | (cd destination ; tar xvmpf -)

  the use of -C is the same as your first cd ; the p flag makes the
  difference (probably it is needed only on one side, but this way works
  anyhow)
---------------------------
Have you tried using "cp -pR <directory>"

The -p option retains files information
The -R makes the new links that correspond with the new tree.

Then just delete the old tree. Check out the man page for cp.
----------------------------------------------

This is what I use to move directory structures around:

        (cd fromdir; tar cf - . ) | (cd todir; tar xpf -)

-----------------------------------------------------------

Guy Dallaire
dallaire_at_total.net

"God only knows if god exists"
Received on Wed May 07 1997 - 16:57:41 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:36 NZDT