LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to vaidate SCP move (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-vaidate-scp-move-854836/)

bearitall 01-07-2011 10:12 AM

Need to vaidate SCP move
 
Hey,
I am new to Linux and I am developing my first script. Yay for me that the copy works, however i need to write some logic into it to "validate the files i moved are on both the source and destination, BEFORE i remove the files from the source" Any help would be appreciated

find /source -mtime +3 -type f | grep file.log |xargs -i scp '{}' DestinationServer:/destination location 2>/dev/null
echo $?

pwc101 01-07-2011 10:20 AM

I'd look into rsync which will do a lot of the heavy lifting for you. It's extremely clever at determining which files need to be transferred from the source to the destination.

TB0ne 01-07-2011 10:37 AM

Quote:

Originally Posted by bearitall (Post 4216538)
Hey,
I am new to Linux and I am developing my first script. Yay for me that the copy works, however i need to write some logic into it to "validate the files i moved are on both the source and destination, BEFORE i remove the files from the source" Any help would be appreciated

find /source -mtime +3 -type f | grep file.log |xargs -i scp '{}' DestinationServer:/destination location 2>/dev/null
echo $?

I'd agree with pwc101's advice, and go with rsync. However, if you want to/have to stick with SSH/SCP, consider doing an md5sum on the file(s) in question. Since you're getting to SCP without a password, I'll assume you have your SSH keys swapped already.

Add a line into your script, to do something like:
Code:

ssh user@remote.host "md5sum <filename>"
into a variable. Then, run the md5sum against the same file locally. They should match..if not, burp out an error/try again/whatever.


All times are GMT -5. The time now is 03:05 AM.