我试图只镜像目录树的那些分支,这些分支包含分支中某处的特定目录名称。我花了几个小时尝试不同的东西无济于事。
远程 FTP 站点的目录结构如下:
image_db
movies
v2
20131225
xyz
xyz.jpg
20131231
abc
abc.jpg
AllPhotos <-- this is what I want to mirror
xyz
xyz.jpg
abc
abc.jpg
v4
(similar structure to 'v2' above, contains 'AllPhotos')
...
tv_shows
(similar structure to 'movies', contains 'AllPhotos')
other
(different paths, some of which contain 'AllPhotos')
...
我正在尝试创建仅包含“AllPhotos”目录的本地镜像,并且它们的父路径完好无损。
我已经尝试过这种变化:
lftp -e 'mirror --only-newer --use-pget-n=4 --verbose -X /* -I AllPhotos/ /image_db/ /var/www/html/mir_images' -u username,password ftp.example.com
...其中“-X /*”不包括所有目录,“-I AllPhotos/”仅包括 AllPhotos。这不起作用,lftp 只是复制所有内容。
我也尝试了这个的变体:
lftp -e 'glob -d -- mirror --only-newer --use-pget-n=4 --verbose /image_db/*/*/AllPhotos/ /var/www/html/mir_images' -u username,password ftp.example.com
...并且 lftp 在远程目录结构上嘎吱作响,而实际上并没有在我这边创建任何东西。
基本上,我只想镜像那些在完整目录路径中某处具有字符串“AllPhotos”的文件。
更新1:
如果我可以使用 wget、rsync、ftpcopy 或除 lftp 之外的其他一些实用程序来做到这一点,我欢迎提供替代方案的建议。
尝试 wget 对我也不起作用:
wget -m -q -I /image_db/*/*/AllPhotos ftp://username:password@ftp.example.com/image_db
...它只是获取整个目录结构,即使 wget 文档说 -I 路径中允许使用通配符。
更新 2:
经过进一步调查,我得出的结论是,我可能应该编写自己的镜像实用程序,尽管我仍然怀疑我以错误的方式接近 lftp,并且有一种方法可以使其仅镜像具有特定字符串的文件绝对路径。