Operating System - HP-UX
1832204 Members
2576 Online
110039 Solutions
New Discussion

"copy" the entire directories structure from another server

 
SOLVED
Go to solution
Hanry Zhou
Super Advisor

"copy" the entire directories structure from another server

I have a directory structure, and total of 6 level of sub-directories underneath the top directory, each level of sub-diretory also has mulitiple subdirectories.

Now, I want to "copy" (create) the entire structure over to another system. Is there any script I can use or any more automatic way I can use to achieve that? instead of manually creating each one of them?

Thanks,
none
10 REPLIES 10
Navin Bhat_2
Trusted Contributor

Re: "copy" the entire directories structure from another server

You can do a "cp -r .." or you can tar the entire directory structure and untar it.
Sanjay_6
Honored Contributor

Re: "copy" the entire directories structure from another server

Hi,

If possible you can create a tar archive on one system and then take it to the other system and extract it. This gets everything. Or you can do rcp -r if using rcp.

There are other choices too, but it depends on how much data are we talking about and what choices we have.

Hope this helps.

Regds
harry d brown jr
Honored Contributor

Re: "copy" the entire directories structure from another server

cd /mainDIR (on local machine)
rcp -rp ./sourceDIR othermachine:/mainDIR

Make sure your "othermachine" has a ".rhosts" file under your login. Which means you need a login on both machines!

live free or die
harry
Live Free or Die
Navin Bhat_2
Trusted Contributor

Re: "copy" the entire directories structure from another server

sorry I miss typed.. should have been rcp -r not cp -r. - Thx
Siddhartha M
Frequent Advisor

Re: "copy" the entire directories structure from another server

If you are planning on doing this copying regularly you could also consider using "rdist".
Please check the man page rdist(1) for more details on directory synchronization.

-Siddhartha
Marvin Strong
Honored Contributor

Re: "copy" the entire directories structure from another server

Also if you want ownership and permissions to be identical, that may not happen with cp or rcp. But tar or cpio will retain all permissions.

tar and ftp it.
setup rhosts and use either tar or cpio across the network.

use nfs to mount it then copy it with tar or cpio.

you can try cp -p -r but you may still lose ownership of files.







Geoff Wild
Honored Contributor

Re: "copy" the entire directories structure from another server

If I understand you, you just want the directory structure - not the contents...

On the server with the current structure:

find /yourmountpoint -type d -print >/tmp/dir.list

then copy that to new server...

then on new server:

for i in `cat /tmp/dir.list`
do
mkdir -p $i
done

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Scott J. Showalter
Frequent Advisor

Re: "copy" the entire directories structure from another server

Do you by any chance have Legato Networker?

If so, there is a real nice utility called uasm that is suited perfectly for this. If you do use Legato, I will post the specifics to the command, no use in posting the specifics if not.
In a world without fences, who needs Gates?
Rodney Hills
Honored Contributor

Re: "copy" the entire directories structure from another server

Any time I copy a directory from one server to another, I compress the data. This way large directories use less band width on the network (and copy faster). Example-

cd /fromdir
tar cf - . | compress -c | ssh otherhost "zcat - | ( cd /to_dir ; tar xf - )"

HTH

-- Rod Hills
There be dragons...
Robert-Jan Goossens
Honored Contributor
Solution

Re: "copy" the entire directories structure from another server

Hi,

How about find in combination with cpio.
Only the directory structure will be created.

# find /source -type d | cpio -ov | remsh server " cd /copy ; cpio -idvum "

Regards,
Robert-Jan