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.
Hours:
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
cancel
Showing results for 
Search instead for 
Did you mean: 

copy files

 
heaman1
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 ?
8 REPLIES
Victor Fridyev
Honored Contributor

Re: copy files

Hi

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

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

Re: copy files

Shalom,

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.

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
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:

http://h20392.www2.hp.com/portal/swdepot/searchProducts.do

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

http://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=T1471AA


Bill Hassell, sysadmin
heaman1
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

heaman1
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
heaman1
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@192.168.0.3 :/tmp/ora_file