Syncronizing files over FTP

11

3

I need to syncronize files in my computer with server to which I have only FTP access. So I can't use rsync (that would need at least SFTP, but the only channel available for me is plain vanilla FTP).

I only need one-way syncronization: from my machine to server. I have heard of a program called unison, but it seems to be meant for two-way syncronisation and I'm unsure whether it could be tweaked to do what I want. I should also add that the program should work non-interactively, so that it could be used inside a script.

Final option would be to write my own script that compares files by modification time (or something like that) and copies over the ones that have changed. I have already managed to mount the FTP directory to a local directory, so the problem boils down to just syncing two directories. But my gut feeling tells me, that there must be something like that already existing in the wild.

Rene Saarsoo

Posted 2009-09-01T19:46:42.097

Reputation: 365

Answers

14

Because I couldn't get wput to work, I looked for an alternative and found: ncftp.

More specifically ncftpput seemed to do almost what wput was designed to do. Most importantly for me, it didn't crash like wput. And indeed it manages to upload only those files that haven't changed using the -z option:

ncftpput -z -u user -p pass ftp.mydomain.com dir/name files-to-upload...

Rene Saarsoo

Posted 2009-09-01T19:46:42.097

Reputation: 365

On OSX, install via: brew install ncftp. – kenorb – 2015-04-15T19:05:40.447

1To copy whole directory trees, use -R. – kenorb – 2015-04-15T19:12:22.310

+1 for the off-label use of -z to mean "noclobber"/"don't overwrite" – barrycarter – 2015-12-08T01:19:24.757

I wish I found this 2 days ago. I gave up on ncftpget since the man page did not show any "only newer" "skip existing" options. I beat my head on lftp -- from BASH to Python. Then I gave another try to ncftp on Google and found your solution. I looked it up for ncftpget (man page) -- "-z/-Z Do (do not) try to resume transfers. The default is to try to resume". Did not sound convincing. But, hell ya.. that's that option I was looking for: download only new files using ncftpget. I hope this comment helps some one. – Anup Nair – 2018-03-17T06:30:49.707

worked perfectly for me – roman m – 2009-11-13T21:01:24.183

4

lftp seems also appropriate here: https://stackoverflow.com/a/693280/480534

Summary:

lftp <username>@<server>
  mirror -c <source> <dest>
  exit

Robert Muil

Posted 2009-09-01T19:46:42.097

Reputation: 141

3

Sure, and it is called wput

user7963

Posted 2009-09-01T19:46:42.097

Reputation: 1 397

Of course! How did I not think about that. Totally forgot that program. I think it will work, but I'll report back when I get back home to try it out... – Rene Saarsoo – 2009-09-02T07:48:10.087

For some reasin wput gives me "Segmentation fault" when ever I try to upload something. – Rene Saarsoo – 2009-09-02T16:03:43.480