views:

216

answers:

3

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
+2  A: 

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.

Martin v. Löwis
A: 

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.

Ned Deily
A: 

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.

David Duggins