Copying files from one server to another server?

Hi all,

In Server1, one directory contains files now. In this directory, based on some operations, daily some files will generate and store regularly.
Now i want to copy the files to Server2 through SFTP/FTP command on daily based on the previous day present data(i.e based on the latest file date) in Server2 directory.


In Server1: Files from 01/08/2014 to 29/08/2014.

In Server2: But in this server,

i want to copy the files from Server1 based on the latest copied file date in server2 ( i.e when i run on 20/08/2014 i want to know which files with latest date copied. If i have the latest one 19/08/2014 in Server2), whenever i run the script that day files will copy to server2.

Requirement-2: (based on requirement-1)
If i wont run on any day (ex 22/08/2014) or in weekends that day(s) files i missing. So, i want to copy from these days too, on the next run.

Can you please provide the Shell script for this.

Thanking you.


Shell script?

I’d use a PHP script (via CRON to make it easy on myself) and use it’s FTP to compare the date of the file on two servers and copy the file from one server to the other if it exceeds one day (or is simply not the same - but run the CRON only once per day).

I do something similar to this for a client with a LARGE file which needs to be duplicated to facilitate downloads from multiple sites in a short period. That script, however, is triggered by an update to the database (which is on a weekly basis).

If you have the proper tool (CRON), use it to make your life simpler.