简体   繁体   English

FTP仅同步新文件

[英]FTP sync only new files

I have the following problem where I need to download to a local directory only new files from an FTP structure, process them using various PHP scripts, and then move them to an archive so they cannot be processed again. 我遇到以下问题,我需要从FTP结构仅将新文件下载到本地目录,使用各种PHP脚本处理它们,然后将它们移动到归档文件中,以便无法再次处理它们。

The FTP structure is as follows: FTP的结构如下:

  • root
  • root --2011 根--2011
  • root --2011 --12 根--2011 --12
  • root --2011 --12 --01, 02 etc 根--2011 --12 --01、02等

It uses a separate folder for each folder structure. 它为每个文件夹结构使用一个单独的文件夹。 Once at day level, it then lists files that use a time stamp naming convention.g. 每天一次,然后列出使用时间戳命名约定的文件。g。 2011-12-09-09-21-34-753.dat 2011-12-09-09-21-34-753.dat


What I need to be able to do is ignore the folder structure on the FTP, download only new .dat files into a single 'local' folder for processing and ensure that these have not been downloaded before. 我需要做的就是忽略FTP上的文件夹结构,仅将新的.dat文件下载到单个“本地”文件夹中进行处理,并确保之前没有下载这些文件。

The files are text only and vary from 1kb to at worst 1.5mb. 文件仅是文本,范围从1kb到最坏的1.5mb。 The FTP server is hosted on a Windows host. FTP服务器托管在Windows主机上。

Any suggestions? 有什么建议么?

Sounds like a perfect use for rsync: http://en.wikipedia.org/wiki/Rsync 听起来是rsync的完美用法: http//en.wikipedia.org/wiki/Rsync

The other way would be to manually log the files/dates you've processed before, and manually sync the changes. 另一种方法是手动记录以前处理过的文件/日期,并手动同步更改。 I would use rsync personally. 我会亲自使用rsync。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM