On Fri, Apr 01, 2005 at 08:05:22AM -0500, Ed Curtis wrote:
> I need to create an exact duplicate of a directory structure off one
> server and replicate it on another. Only the directories need to be moved,
> no files. The permissions should remain the same. How would I go about
> doing this?
You can do nice things with 'find'. You can run the following in the
shell (or make a script out of it).
DEST="destination dir"; find . -type d -printf "mkdir --parents --mode=%m \"${DEST}/%P\"; chown %u.%g \"${DEST}/%P\"\n" > tmp.sh
This makes a file with the following lines which can then be sourced
(executed) by the shell. Just transfer tmp.sh to your second server
and run 'source tmp.sh'. I did a small test which resulted in the
following file.
mkdir --parents --mode=755 "destination dir/"; chown maurits.maurits "destination dir/"
mkdir --parents --mode=755 "destination dir/a"; chown maurits.cdrom "destination dir/a"
mkdir --parents --mode=755 "destination dir/a/b"; chown maurits.maurits "destination dir/a/b"
mkdir --parents --mode=755 "destination dir/a/b/c"; chown maurits.maurits "destination dir/a/b/c"
mkdir --parents --mode=751 "destination dir/m v r"; chown maurits.maurits "destination dir/m v r"
I think that basically does what you need. It takes care of
permissions and ownership. Else you can modify the parameters of
'find'. Let it start with 'find /' instead of 'find .' to do this for
all your directories instead of just the current one. Of course you
need to be root to make that work.
HTH,
--
Maurits van Rees | http://maurits.vanrees.org/ [Dutch/Nederlands]
Public GnuPG key: keyserver.net ID 0x1735C5C2
"Let your advance worrying become advance thinking and planning."
- Winston Churchill
Attachment:
signature.asc
Description: Digital signature