PDA

View Full Version : ftp update script



jrblevin
12th May 2004, 05:45 PM
I am trying to write a script that will synchronize a remote FTP directory with a local directory (uploading from my box to the ftp site). What I really want to do is "rsync -avz --delete ..." but the remote host doesn't support rsync so I have to use FTP.

I have looked over the ncftp and ncftpput manpages with no luck. I could have it upload _everything_ but that would be overkill since I only want to freshen the files that have changed since the last update. Automatically removing remote files that are no longer used would be a big plus too (like the rsync --delete option). Any ideas?

viper8
12th May 2004, 10:52 PM
Yeah, check out lftp ... Lots of options that will fit what you need

http://lftp.yar.ru/

theurge
12th May 2004, 11:25 PM
Using a combination of grep and sed, you could compare a FTP remote dir listing to a ls -la of the local directory.

I might write this script for fun this weekend. Let me know how it goes.

jrblevin
13th May 2004, 02:19 AM
Thanks for the quick suggestions. I downloaded lftp and it did the trick. I had some trouble with the timestamps though. The remote site wouldn't give the files the same timestamp so I had to turn off timestamp checking. Checking the size should be sufficient though. And there is a --delete option so I will have an exact mirror.

I really like the grep sed idea but I don't have time to play with that right now. I need to learn sed though so that sounds like a good project.

dan1234
7th June 2004, 03:31 AM
I used the command wget to sync the remote ftp site with the local. It seem works for me. wget has a option that compare the dates and only d/l the updated files. Do man wget for more info. Hope this help.

Daniel