我有一个需要在实时服务器上拉取(git pull)的实时分支,但实时服务器无法访问 bitbucket。
虽然我使用登录/密码在远程服务器上具有 ssh 访问权限(不能使用 ssh-key),但同步远程服务器上指定分支的最佳方法是什么(更新和删除更改的文件)?
用于scp
将文件从可以访问 bitbucket 的机器复制到服务器,而不是使用 git。从位桶中提取 cron 作业。使用 post receive 挂钩启动 scp 命令。
我使用 rsync 解决了这个问题。
使用 rsync 我可以检查女巫文件是否已修改并且在远程服务器上有所不同。
我还创建了一个名为build.exclude.sync女巫的文件,其中包含我想跳过的每个目录,并且在终端我可以使用:
rsync -avz --exclude-from=build.exclude.sync /home/path/to/local/dir/ -e ssh myuser@myremotehost.com:/path/to/remote/dir/
我使用 rsync 和Apache Ant来自动化构建过程。在我的 build.xml 文件中:
<exec executable="rsync" dir="." failonerror="true">
<arg line="-avz --exclude-from=build.exclude.sync ${prod.local.deploydir} -e ssh ${prod.sshusername}@${prod.sshhost}:${prod.homedir}"/>
</exec>