让 ANT 仅对新/更改的文件进行 scp
我想优化我的 scp 部署,该部署当前复制所有文件以仅复制自上次构建以来已更改的文件。我相信当前的设置应该可以以某种方式实现,但我不知道该怎么做。
我有以下内容:
Project/src/blah/blah/ <---- 我正在编辑的文件(在本例中主要是 PHP,还有一些静态资产)
Project/build <-------- 我有一个本地我用来将文件复制到此处的构建步骤
我现在有一个 scp 任务,可以在需要时将所有项目/构建复制到远程服务器。
是否有可能以某种方式利用这个额外的“build”目录来完成我想要的——这意味着我只想上传 src/** 和 build/** 之间的“diff”。是否有可能以某种方式将其检索为 ANT 中的文件集,然后对其进行 scp ?
我确实意识到这意味着如果我以某种方式删除/弄乱服务器上的文件,ANT 脚本不会注意到,但对我来说这没关系。
I would like to optimize my scp deployment which currently copies all files to only copy files that have changed since the last build. I believe it should be possible with the current setup somehow, but I don't know how to do this.
I have the following:
Project/src/blah/blah/ <---- files I am editing (mostly PHP in this case, some static assets)
Project/build <------- I have a local build step that I use to copy the files to here
I have an scp task right now that copies all of Project/build out to a remote server when I need it.
Is it possible to somehow take advantage of this extra "build" directory to accomplish what I want -- meaning I only want to upload the "diff" between src/** and build/**. Is it possible to somehow retrieve this as a fileset in ANT and then scp that?
I do realize that what it means is that if I somehow delete/mess around with files on the server in between, the ANT script would not notice, but for me this is okay.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
modified
标签告诉ant scp
仅复制自上次推送以来已修改的文件,如下所示:第一次使用此功能时,它将发送所有文件并将时间戳缓存在
param
中声明的缓存文件中。之后,它只会发送修改后的内容。在sftp模式下测试和验证。
You can tell
ant scp
to only copy files which have been modified since the last push using themodified
tag like so:The first time you use this, it will send all files and cache the timestamps in the cachefile declared in the
param
. After that, it will only send the modified ones.Tested and verified in sftp mode.
我认为您需要使用 rsync 代替。我发现以下文章可以回答您的问题。
简而言之,rsync 将从中断处恢复,并且应该可以通过 ssh 进行隧道传输。
I think you need to use rsync instead. I found the following article that answers your question.
In a nutshell rsync will resume where it left off and it should be possible to tunnel it over ssh.