1837921 Members
6018 Online
110124 Solutions
New Discussion

rcp

 
Aggy
Frequent Advisor

rcp

I want to copy files from prod server to test server
/etc/passwd
/etc/hosts
/home/* ( need to exclude root )
and /tcb/*
How can I write a script which will do the above task.
Want the owner and perm to be the same
4 REPLIES 4
Chan 007
Honored Contributor

Re: rcp

Hi,
do
rcp -rp /etc/passwd target:/etc
rcp -rp /etc/hosts target:/etc

in scripts from command line

for i in /etc/passwd /etc/hosts /home /tcb
do
echo $i
rcp -rp $i :$i
done

Chan
Aggy
Frequent Advisor

Re: rcp

Thanks Chan

I had used the rcp command but my main issue was to exclude root from /home and copy the rest /home/* to the test prod
RAC_1
Honored Contributor

Re: rcp

Not with rcp. Take tar ball and put it over to another system. tar has option to exclude a particular dir from it.

man tar for details.
There is no substitute to HARDWORK
Chan 007
Honored Contributor

Re: rcp

Hi

Do this getting rid of root from /home

ls -lrt |grep -v root|awk '{print $9}' >/tmp/test

then

for i in $(cat /tmp/test)
do
rcp -rp /home/$i :/home
done

For tcp best way is to cp the "r/root" directory on the target server to /tmp.

once copying is complete mv /tmp/root /r/root

Chan