Operating System - HP-UX
1834481 Members
3106 Online
110067 Solutions
New Discussion

Re: copy directories with link files

 
yc_2
Regular Advisor

copy directories with link files

Hi,

Is there a way to copy directories with soft link files in it. I used "cp -r and it failed to copy link files.



Thanks in advance,
YC
3 REPLIES 3
S.K. Chan
Honored Contributor

Re: copy directories with link files

I usually do this .. example to copy everything (keeping the sym links, ownerships and permissions) from /opt/apps to /opt/apps2..

# cd /opt/apps
# find . -xdev -depth -print | cpio -pvdumx /opt/apps2

Check "man cpio" for all the options.
Michael Tully
Honored Contributor

Re: copy directories with link files

Hi,

Instead of using 'cp -r', use 'cp -R'
The man page cover this area.
You can also use 'cpio' to do this job as well.

# cp -R

HTH
Michael
Anyone for a Mutiny ?
Bill Hassell
Honored Contributor

Re: copy directories with link files

The best cpio option list is:

cd /old_directory
find . | cpio -pudlmv /new_directory

also known as the 'puddle-move' option list. The -x option should not be used since device files are very unique and maeningless on another system.

However, cpio is not (and cannot be made) compatible with large files (files greater than 2Gb) so be aware of this when you use the cpio copy. It is much faster than cp since cpio -p reads large blocks of data. cp is, however, fully largefile compatible.


Bill Hassell, sysadmin