Operating System - HP-UX
1830163 Members
1862 Online
109999 Solutions
New Discussion

How can I overwrite directory using rcp

 
Henry Chua
Super Advisor

How can I overwrite directory using rcp

Hi Guys,

By using RCP to remote copy files, I can only overwrite existing files, but not existing folders, how can I do the latter?

Is there any other option I can use?

Please advise!

Merry Xmas

Henry
5 REPLIES 5
harry d brown jr
Honored Contributor

Re: How can I overwrite directory using rcp


you are confused. rcp COPIES files from one location to another, and if the -r option is used, then it recursively walks sub directories and copies those files. It WILL NOT copy directory headers thus it will not automatically remove files that aren't being copied.

What you are asking is to have rcp delete the destination first then copy the files.

To do this:

remsh DESThost rm -rf DESTdirectory
rcp -rp LOCALdirectory DESThost:DESTdirectory

live free or die
harry d brown jr
Live Free or Die
Henry Chua
Super Advisor

Re: How can I overwrite directory using rcp

Hi there,

Thanks for the tips. In this case is there any other way to achieve this? You see, I need to copy a whole bunch of directories to a remote box for backup and I will have to overwrite those directories that has been modified, so am trying to look for an easy way to go around this..

regards
Henry
harry d brown jr
Honored Contributor

Re: How can I overwrite directory using rcp

Use tar or cpio with (both) with gzip, thus achieving a true archive. You can also get GNU's tar that can use gzip as it archives: http://hpux.cs.utah.edu/hppd/hpux/Gnu/tar-1.14/

live free or die
harry d brown jr
Live Free or Die
bhavin asokan
Honored Contributor

Re: How can I overwrite directory using rcp

hi,

take a tar . copy it to another server. untar it.

regds,
harry d brown jr
Honored Contributor

Re: How can I overwrite directory using rcp

bhavin asokan,

He wants to keep the directories in sync, thus if the destination directory has a file in it that is not on the source, then he wants that file deleted from the destination. Therefore tar'ing and untar'ing aren't going to achieve that, thus he has to either just keep the tar archive at the destination or perform a delete.

live free or die
harry d brown jr
Live Free or Die