我有一个包含PHP文件和其他内容的网站。我希望能够实现本地网站副本和服务器网站之间的一键同步。最好能够提供命令行工具或Eclipse PDT插件来实现这个功能。
我有一个包含PHP文件和其他内容的网站。我希望能够实现本地网站副本和服务器网站之间的一键同步。最好能够提供命令行工具或Eclipse PDT插件来实现这个功能。
我建议使用lftp。这是一个复杂、可编写脚本的命令行FTP客户端。
lftp has builtin mirror which can download or update a whole
directory tree. There is also reverse mirror (mirror -R)
which uploads or updates a directory tree on server. Mirror
can also synchronize directories between two remote servers,
using FXP if available.
使用 lftp 命令执行 mirror.sh 脚本。
mirror.sh
open sftp://<username>:<password>@<ip address>
mirror -c /<source> /<destination>
exit
有一个名为FTP Synchronizer的工具(适用于Windows),可以从命令行运行。如果不使用任何FTP库,您无法通过FTP同步文件。该库越成熟,同步文件的速度就越快(例如,它可以在其内部数据库中缓存已同步的文件信息)。
不喜欢FTP同步器?Google搜索替代方案。
PhpStorm 刚刚添加了双向同步功能(通过FTP和其他方式) 到他们最优秀的PHP IDE中。这个功能在当前的3.0 EAP (beta)版本中,而不是2.1版本中。
我写了一个简单的脚本
#!/bin/bash
FTPLOCALFOLDER=$1
FTPLINK=$2
ls "$FTPLOCALFOLDER" > "./filesdownloaded.txt"
curl -sS "$FTPLINK" | grep -oE "(?href=\").*?(?\")" | awk -F '"' '{print $2}' > "./filesinlink.txt"
grep -v -f "./filesdownloaded.txt" "./filesinlink.txt" > "./filestodownload.txt"
echo "Start downloading"
while read p; do
echo "downloading..... $p from $FTPLINK$p"
wget "$FTPLINK""$p" -O "$FTPLOCALFOLDER""$p"
done < "./filestodownload.txt"