尝试让 rsync 将文件复制回 svn
我正在尝试设置一个特定的工作流程,但无法弄清楚 rsync 如何(或是否)为此工作。
我的设置是在 Mac OS X 上。
我有我的 SVN 目录。当我运行部署脚本时,文件将移至我的集成 Apache 服务器。我对文件进行修改,然后手动将它们复制回 SVN。
我这样做的原因是,当我编辑 html、css 和 javascript 时,我需要立即看到浏览器中的更改。但尝试手动复制和跟踪这一点非常耗时,我想将其自动化。
我想要做的是使用 rsync 来确定我在 Apache Web 目录中修改的文件,然后将这些文件仅复制回 SVN。
我有一个我一直在测试的 rsync 命令,但我似乎遇到的问题是,由于已部署文件的时间戳都比 SVN 中的时间戳新,所以 rsync 想要将所有文件复制回来,因为它看到它们作为较新的文件。
我还尝试了 diff,它检测到文件差异。我想我可以编写一个 shell 脚本,它可以使用 diff、grep 和 cp 的组合来完成这项工作,但我想看看 rsync 是否可以成为一个一体化的解决方案。
rsync -avuzn --exclude=web-inf/classes/ --exclude=web-inf/lib/ /var/www/web-inf /usr/local/src/svn/WEB-INF
I'm trying to setup a particular workflow but having trouble figuring out how(or if) rsync will work for this.
My setup is on Mac OS X.
I have my SVN directory. When I run my deploy script, the files are moved over to my integration Apache server. I perform my modifications to the files, then manually have been copying them back to SVN.
The reason that I have done this is that I need to immediately see changes in the browser as I'm editing html, css, and javascript. But its getting time consuming trying to manually copy and keep track of this and I want to automate it.
What I want to do is use rsync to determine the files I have modified in the Apache web directory, then copy those files only back to SVN.
I have an rsync command I've been testing, but the problem I seem to be running into is that since the timestamps of the deployed files are all newer than what's in SVN, rsync wants to copy all of the files back because it sees them as newer files.
I also experimented with diff, and it detects the file differences. I imagine I can put together a shell script that can use a combination of diff, grep, and cp to make this work but I wanted to see if rsync could be an all-in-one solution.
rsync -avuzn --exclude=web-inf/classes/ --exclude=web-inf/lib/ /var/www/web-inf /usr/local/src/svn/WEB-INF
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我建议直接在网络服务器上进行颠覆检查。您应该为所有 文件名为
.svn
,以便远程用户不认为这是颠覆检查。I recommend to have a subversion checkout right into the web server. You should add a Deny directive for all Files named
.svn
, so that remote users don't recognize this as a subversion checkout.您没有说明部署脚本如何将文件移动到集成服务器,并且不完全清楚是否涉及不止一台计算机或集成服务器文件位于哪种类型的文件系统上。如果脚本执行正确的操作,您也许能够在文件最初发送时保留文件的修改时间。既然你可以使用 rsync 将它们带回来,那么你不能首先使用 rsync 来发送它们吗?除此之外, scp -p 是另一种在保留许多属性的同时进行传输的方法。
不过,这种工作流程听起来是为分布式版本控制系统量身定制的,例如 mercurial 或git。
You don't say how your deployment script moves the files to the integration server and it isn't totally clear whether more than one machine is involved or what sort of file system the integration server files are on. If the script is doing the right thing, you may be able to preserve the modification times on the files when the files are originally sent over. Since you can use rsync to bring them back, can't you also use rsync to send them in the first place? Barring that, scp -p is another way to transfer while preserving many attributes.
This kind of workflow, though, sounds tailor-made for a distributed version control system, like mercurial or git.
我在这里不明白的是你到底在做什么?一般来说,您应该在自己的计算机上进行开发。您的 svn 存储库应位于您的 Sites 目录中,以便您可以通过 localhost 在浏览器中实时查看该站点。我以同样的方式将 Rails 与 git 结合使用。我的本地 ruby 服务器访问 localhost:3000,我可以开发并不断查看我在做什么。然后,当我的编码达到不错的水平时,我会提交到 git 并部署到我的测试服务器。网站完成后,将进入生产环境。当我在 php/mysql 中编码时,我在自己的本地 apache 服务器上进行测试,然后在完成后直接 ftp 到测试或生产服务器。
这就是你应该如何工作。没有理由从测试或生产服务器复制数据。并且您的版本控制系统应该完成所有同步。
本地开发,远程测试,然后部署到生产。这是最好的方法。
What I don't understand here is what exactly you are doing? Generally speaking, you should be developing on your own computer. Your svn repository should be located in your Sites directory so you can view the site live in your browser through localhost. I use Rails with git in this same manner. My local ruby server go to to localhost:3000 and I can develop and constantly see what I am doing. Then when my coding hits a decent point, I commit to git and deploy to my testing server. Once the site is done, it goes to a production environment. When I code in php/mysql, I test on my own local apache server and then directly ftp to either a testing or production server when I am done.
This is how you should be working. No reason to copy stuff back from your testing or production servers. And your versioning control system should do all the syncing.
Develop locally, Test remotely then deploy to Production. Thats the best way to do it.
我还尝试了自动部署,在编写了自己的 rsync 脚本之后...(易于使用但对安装要求很高,我遇到了 DeployIt... 尝试一下...
http://deployit.monavari.de/
I also experimented with automatic deployments and after I wrote my own rsync-script... (easy to use but demanding on installation, I came across DeployIt... Give it a try...
http://deployit.monavari.de/