HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Showing results for 
Search instead for 
Did you mean: 

copy files

Regular Advisor

copy files

I have two servers ( in different network ) , server A will copy ( scp ) files to server B regularly , as the connection between these two servers is not very stable , so sometimes the files in server B is missing , or the file size is not consistency , the reason may be due to the line disconnection / unstable , can advise if I want to make sure the files are copied to server B ( or lower the file transfer failure rate ) , what is the best way / method ? can suggest the script ? thx

p.s. I may be use the script / method in other unix-like distro. except HP , can advise a method that applicable to other system ?
Victor Fridyev
Honored Contributor

Re: copy files


You can use rsync and run it until you see that all files are copied succesfully. The utility verifies copy result.

Entities are not to be multiplied beyond necessity - RTFM
Steven E. Protter
Exalted Contributor

Re: copy files


rsync's advantages are that it will skip files already copied.

The -e option can be used to run teh data stream through ssh, which encrypts it.

Example code:

rsync -avH --stats --delete -e ssh /var/httpd/ $othernode:/var/httpd/

othernode is the target node. --delete deletes files from the target server that have been deleted on the source server.

Steven E Protter
Owner of ISN Corporation
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Hassell
Honored Contributor

Re: copy files

rsync is ideal for this purpose but both sides must have rsync installed (it is add-on software for HP-UX) and also ssh installed if you want to encrypt the transmission. Get the HP version of rsync from:


If ssh is not installed on your system, get a copy from:


Bill Hassell, sysadmin
Regular Advisor

Re: copy files

the replies ,

What I need to do is simply use rsync to copy file to server B is OK ? or I need to write a script like

rsync from serverA to serverB

if error code = 0 # that mean successful copy to server B
then remove the file
if not equal to 0 ,
then keep the file
Mel Burslan
Honored Contributor

Re: copy files

you do not need to create logic like that for checking file existence or if it is correctly copied or not. All you need is to tell the server and filename where it is going to be copied to/from and the local file name. That is it. The rest of the logic is built into rsync itself. It is the beauty of it.
UNIX because I majored in cryptology...
Suraj K Sankari
Honored Contributor

Re: copy files

Regular Advisor

Re: copy files

thx replies ,

I tested it , it seems very fine , can advise this method is good for the case when there are many many files need to be copy to server B and also all these files are very small in size ( less than 1 K byte ) ? thx
Regular Advisor

Re: copy files

sorry to have one more question

I would like to add such request , if the files are successful copy to server B , then make a file copy to local directory /tmp/backup then remove it or simply move it to /tmp/backup , so that I know what files are successfully copied.

I tried the below method , it can copy file to /tmp/ora_file but do not make backup to /tmp/backup or remove the files , can advise how can I change it ? thx

rsync -avH --delete -b --backup-dir=/tmp/backup -e ssh * root@ :/tmp/ora_file