Operating System - HP-UX
1753523 Members
9180 Online
108795 Solutions
New Discussion юеВ

copying dir & preserving ownership

 
SOLVED
Go to solution
Rosli Ahmad
Frequent Advisor

copying dir & preserving ownership

Hi,
I need to copy huge directories to another areas. I did:

#find . -depth|cpio -pdm /target

but it didn't preserve the ownership. What other way can use to copy my directories to other areas and preserving all the right ownership & permission.

Thanking everyone in advance.
-rosli-
7 REPLIES 7
Thierry Poels_1
Honored Contributor

Re: copying dir & preserving ownership

hi,

"cp -p" preserves permissions, so does tar, fbackup, ...

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Ranjith_5
Honored Contributor

Re: copying dir & preserving ownership

Hi rosli,

do cp -rp when u copy a directory.

regards,
Syam
bhavin asokan
Honored Contributor

Re: copying dir & preserving ownership

hi,

try the following

find . -depth | cpio -pdlmuva /target

see the link for the same type of problem.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=45352


regds,
Radhakrishnan Venkatara
Trusted Contributor

Re: copying dir & preserving ownership

As mentioned above cp -pr will work. But if u want to do for huge data use tar,fbackup and dd.
Negative thinking is a highest form of Intelligence
Jannik
Honored Contributor
Solution

Re: copying dir & preserving ownership

This is the way for you:
cd fromdir ; tar cf - . | ( cd todir ; tar xf - )

I have just tested it and it retains all user and group information.

Best Regards!
jaton
Rosli Ahmad
Frequent Advisor

Re: copying dir & preserving ownership

Thank you guys.
Rashid Hamid
Regular Advisor

Re: copying dir & preserving ownership

Hi Rosli

Use cp -r to copy directories and sub directories.
If the ownership change, use chown -R


Regards
Rashid Hamid
I'm Parit Madirono/Parit Betak Boyz