1834312 Members
2703 Online
110066 Solutions
New Discussion

Re: RCP

 
SOLVED
Go to solution
Ahmed_41
Super Advisor

RCP

Dear All

i want to do rcp for a directory containing lots of directories and files from machine x in /tmpsrc to machine y in /tmpdst
i think i shall write something like this

rcp -r y:/tmpdst /tmpsrc
can someone tell me how to do it, or what i wrote is right or not ?

thanks
6 REPLIES 6
Pete Randall
Outstanding Contributor
Solution

Re: RCP

If you're coming from x and going to y, on machine y, you would run "rcp -r x:/tmpsrc /tmpdst". If you are on machine x it would be "rcp -r /tmpsrc y:/tmpdst.


Pete

Pete
Steven E. Protter
Exalted Contributor

Re: RCP

If you want subdirectories try the -p paramater as well.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Doug O'Leary
Honored Contributor

Re: RCP

Hey;

The -r option as the OP specified gets the subdirs. The -p option preserves ownership and file modes....

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
RAC_1
Honored Contributor

Re: RCP

Start by reading man page of rcp.

You need the syntax as follows.

rcp -pr /source_dir/ remote_system:/destination/

Anil
There is no substitute to HARDWORK
Cem Tugrul
Esteemed Contributor

Re: RCP


rcp(1) rcp(1)

-p This option can be used to preserve (duplicate)
modification times and modes (permissions) of
source files, ignoring the current setting of the
umask file creation mode mask. If this option is
specified, rcp preserves the sticky bit only if
the target user is superuser.

If the -p option is not specified, rcp preserves
the mode and owner of dest_file if it already
exists; otherwise rcp uses the mode of the source
file modified by the umask on the destination
host. Modification and access times of the
destination file are set to the time when the copy
was made.
***********************************
-r This option can be used to recursively copy
directory subtrees rooted at the source directory
name. If any directory subtrees are to be copied,
rcp recursively copies each subtree rooted at the
specified source directory name to directory
dest_dir. If source_dir is being copied to an
existing directory of the same name, rcp creates a
new directory source_dir within dest_dir and
copies the subtree rooted at source_dir to
dest_dir/source_dir. If dest_dir does not exist,
rcp first creates it and copies the subtree rooted
at source_dir to dest_dir and the output will be
similar irrespective of whether a wildcard
character (source_dir/*) is used for copying or
otherwise.
*************************************
And Finally,i am agree with Pete...

Good luck,
Our greatest duty in this life is to help others. And please, if you can't
Geoff Wild
Honored Contributor

Re: RCP

Do you need to do this all the time? IE - keep the file in sync on both servers?

If yes, then have a look at rdist

I run it like so from cron:

# Copy bwpadm across to the DR site.
15 01 * * * /app/admin/drp/update-binaries.sh >/tmp/update-binaries.cron 2>&1

# cat update-binaries.sh
#! /bin/sh

# Keep the DRP copy of the bwpadm up-to-date.
# Currently the files are in:
#
# /home/bwpadm/DR
#
# See the rdist(1M) distfile for a list of exclusions.

DRPDIR=/app/admin/drp
DRPHOST=svr102

HOST=`/usr/bin/uname -n`
mount | grep /home > /dev/null 2>&1
if [ $? -eq 0 ]
then
/usr/sbin/vgexport -p -s -v -m /home/bwpadm/DR/vg10.map /dev/vg10
( su - bwpadm -c "rdist -f $DRPDIR/distfile bwpadm"; ) 2>&1 |\
tee $DRPDIR/drp.log 2>&1 |\
mailx -s "bwpadm DRP rdist output" `cat /usr/local/mailadmin.list`
fi


# cat distfile
BWPDR = ( svr102 )

#
# File systems to be copied over to the DR host.
# Don't use -R in install - so as not to remove files on destination host
BWPADM = /home/bwpadm

bwpadm: ( ${BWPADM} ) -> ( ${BWPDR} )
install -w ;


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.