PDA

View Full Version : FTP Script Help / FTP File Sync ?



frontleft
25th May 2006, 01:46 AM
Hi ,

Im stuck with a problem and im wondering if someone can help me ...

Basically I need to copy from from a server to my linux server , over FTP at a certain time each night , and I need it do to date checking ... ie , Only overwite if the files newer ...

The folders go 1 level deep , and i basically just want the script to FTP in , go through each directory and if a files newer on the server , transfer the file ... ie , Syncing files over FTP ...

Im not having much luck with this and it dosnt appear to be possible with FTP even though its pretty basic ! ...

so far all iv got is:


#!/bin/sh
HOST='wsus'
USER='wsus'
PASSWD='****'


ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
mget *.*
quit
END_SCRIPT
exit 0


But that wont check the date stamps ...

Can anyone help me here ??..

Cheers thanks ...

giulix
25th May 2006, 08:58 AM
As you say, FTP is pretty basic and specialized, buy it does provide a way of listing remote files with ls. So, here you have to choose: either ftp in, list files, close ftp connx, check local files dates, ftp back in and get only the files you need to update. or ftp in, get all files, close connx. A better way of doing this would be to use rsync or use a scripting language with ftp support (Perl and PHP have it, and I am pretty sure Python supports it too).

markkuk
25th May 2006, 09:10 AM
Use the lftp program instead of the basic ftp client. Lftp can synchronize directories over FTP service.