1821539 Members
2194 Online
109633 Solutions
New Discussion

Copy or cpio command

 
Qcheck
Super Advisor

Copy or cpio command

I am using cpio –pdm to copy the directory which has so many sub folders and files to the new NFS directory. It is copying everything but the dates are not consistent and also the ownership of the symbolic links changing to root:system and the dates on the symbolic links are changing to the current date of copying.

Then I used cp command with the option –h –p –R –f, which did better than cpio –pdm command but still the dates on the symbolic link files is changing to the current date of copy.

Please give me the appropriate command to copy the symbolic links as is with the modification dates and the ownership, along with the following:

My motive is:

1) To keep the mode(including bits)

2) To keep the modification date

3) Should copy the symbolic link as symbolic link with the source ownership and dates.

4) And also the user and group

Thanks in an advance.
11 REPLIES 11
James R. Ferguson
Acclaimed Contributor

Re: Copy or cpio command

Hi:

The modication timestamp, ownership and permissions of symbolic links is immaterial.

It is the ownership and the permission of the file or directory that is pointed to by the symbolic link that matters for file access.

Regards!

...JRF...
Qcheck
Super Advisor

Re: Copy or cpio command

James,

I know, but I just wanna make sure that I use the best option to copy over the files, which it is going to be a massive NFS project. So just wanna discuss this and go in right direction.

Thanks
James R. Ferguson
Acclaimed Contributor

Re: Copy or cpio command

Hi (again):

For replicating filesystems with 'cpio' I use:

# cd srcdir && find . -depth -print | cpio -pudlmv dstdir

Regards!

...JRF...
Paul Sperry
Honored Contributor

Re: Copy or cpio command

I have done the same thing using cpio


find . â print | cpio â ocxa | remsh â cd /target/dir;cpio â icxvdmuâ

Paul Sperry
Honored Contributor

Re: Copy or cpio command

Wow I guess word dosent past too well.

cd to source top level directory

find . -print | cpio -ocxa | remsh target_server "cd /target/dir;cpio -icxvdmu"

make sure the .rhost is set on the target system and test it first.
Qcheck
Super Advisor

Re: Copy or cpio command

Paul and James, thank you for the responses, I really appreciate. I tested what James said but still cp -h -p -R -f is doing great job than cpio with your option.

Again I will try on Monday and will let you all inform my progress.

Thanks again.
Dennis Handly
Acclaimed Contributor

Re: Copy or cpio command

As JRF says, the info with a symlink other than the target is ignored. If you want to see something more useful, you can use "ll -L" to get the properties of the target.

You might try tar to see if it works better?
You could also use fbackup/frestore.

>the ownership of the symbolic links changing to root:system

Possibly because these tools don't know that now chown(1) has a -l option, lchown(2) to change the ownership?
Rasheed Tamton
Honored Contributor

Re: Copy or cpio command

>3) Should copy the symbolic link as symbolic link with the source ownership and dates.

>ownership and dates.

All your 4 options should be working except the date on the symbolic link. Even with fbackup or pax and other tools like tar/cpio/vxdump it does not work.

Regards.
Qcheck
Super Advisor

Re: Copy or cpio command

Nope, I know even if that is not a big deal, still I couldn't make it work with the date thing to be consistent on destination like the source with any command.
Jon M Zellhoefer
Valued Contributor

Re: Copy or cpio command

The most consistent way I have found to keep all of the atributes and links is:

find . -depth -print -xdev | cpio -pdlmax /dest

Jon
Márcio Rezende
New Member

Re: Copy or cpio command

Seems it works.
Divide in two parts!

Supose you are in curdir and would cpio to dstdir (create dstdir in advance).

cd curdir
## first not dirs
find -depth -not -type d -print0 | cpio -0pudlmv dstdir

## after... just dirs
find -depth -type d -print0 | cpio -0pudlmv dstdir

{}'s
MaRZ