Operating System - HP-UX
1753792 Members
7542 Online
108799 Solutions
New Discussion юеВ

Re: Copy files & Directories while preserving the same ownership & permission

 
Steven Schweda
Honored Contributor

Re: Copy files & Directories while preserving the same ownership & permission

> No need to cd to fromdir. [...]

Well, not if "-C" works everywhere you do,
but I prefer to use a smaller (more reliably
available) feature set, especially when it
makes things more symmetrical, hence easier
to remember:

( cd src ; tar cf - xxx ) | \
( cd dst ; tar xf - )

Learn it once, then relax.

Using parentheses on the "src" side leaves
the user's environment unchanged, which is
nicer than a bare "cd", I claim. For a good
time, you can also slide an "rsh" onto either
side to add some remoteness without dragging
NFS into the argument.
Yogeeraj_1
Honored Contributor

Re: Copy files & Directories while preserving the same ownership & permission

hi Shaheer,

If you have same users and groups (uid and gid) on both server, you can also try to do a remote copy using: scp


e.g.
scp -p -r ./mydir otherserver:/home/yogeeraj/


hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Steven Schweda
Honored Contributor

Re: Copy files & Directories while preserving the same ownership & permission

> [...] do a remote copy using: scp

Does "scp -r" handle links (hard and soft)
any better than "cp -R"? (See reference
above to previous "cp"-related complaint.)
I'd assume not.

Replace "rsh" (above) with "ssh", if you'd
like an ssh=based method which wouldn't have
the same problems as "cp".
piyush mathiya
Trusted Contributor

Re: Copy files & Directories while preserving the same ownership & permission

You can user rcp (the berkly concept). you have to follow the below steps...
#### In destination server
1). vi /.rhosts
root
save it.
2). vi /etc/hosts
make an entry of source server.

### In source server
3). rcp -p -r
rcp -p -r /mnt server2:/mnt

where /mnt is the name of file system and server2 is the destination server and /mnt is exist on server2.
### In destination server after copied all files.
4). find . -user testadm -print -exec chown testbdm {} \;

it will works...

cheaars!!!!
Steven Schweda
Honored Contributor

Re: Copy files & Directories while preserving the same ownership & permission

> You can user rcp [...]

Ok. I give up. You win. Do whatever you
want. It probably doesn't matter if links
are handled well or not.
Yogeeraj_1
Honored Contributor

Re: Copy files & Directories while preserving the same ownership & permission

hi Steven,

we really appreciate your post and concern. In many cases, we often forget the possibility that links to files might exist.

if the initial poster could give us some feedback of its relevance, then maybe we could come to consensus here :)

We really appreciate your contributions and insights. I have learned a lot from your posts..

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
OldSchool
Honored Contributor

Re: Copy files & Directories while preserving the same ownership & permission

dennis said: "It looks fine in the online tar(1) man pages for 11.11, 11.23 and 11.31."

ah...well I was looking at an 11.0 box
Kunju
Occasional Contributor

Re: Copy files & Directories while preserving the same ownership & permission

TAR is best option. Only concern is the size of the data. It worked for me. Thanks all for the help.