I'm working on a project where we use SVN for our source code control. When changes are committed to the repository, a process on the svn server takes care to copy the changed files to our development server.

Our production server, however, has no such automatic connection -- and for good reason. We automatically deploy committed code changes to the dev server for the purpose of testing. by the time anything gets committed to the repo, we have typically tested it on our local workstations. We don't want to auto-deploy repo changes to our live server for obvious reasons -- something could easily break.

The question I have is once we are convinced that the repo changes need to be rolled out to the production server, what is the best way?

I have suggested running svn export on the production server when we are ready but my coworker is balking -- says it makes him too nervous. Furthermore, svn export will fetch the entire repo unless I explicitly limit the command to some subdirectory or individual file. Additionally svn export might alter file permissions, preventing apache from writing certain data files and/or source files and/or configuration files. There's also the possibility that one might check one's local configuration file into the repo and this would ultimately end up in dev/test/sandbox credentials finding their way onto a production server.

Can anyone recommend a sound approach to the workstation-dev server-production server setup when using svn? At the moment, we are manually tracking changed files and uploading them to the production server via FTP. This is a chore and prone to human error.

    I'm afraid this is something I struggle with a bit as well. So, just to be my usual trollish self while I wait for a real answer ... home brew diff and patch script? :p

      I'm thinking something involving rsync might be the answer. I'm still worried about copying configuration files from dev server over production config files, though.

        sneakyimp wrote:

        When changes are committed to the repository, a process on the svn server takes care to copy the changed files to our development server.

        It sounds like you can do the same thing for the production server, except that this process would be launched on demand.

          laserlight wrote:

          It sounds like you can do the same thing for the production server, except that this process would be launched on demand.

          Treat the production server's copy as a working copy and as part of the deployment process do an "svn up"?

            laserlight wrote:

            It sounds like you can do the same thing for the production server, except that this process would be launched on demand.

            Sadly, the SVN server is maintained by a third party. They do have features that would make it fairly easy for us to manually deploy svn updates to our production server, but this requires that we enter our production server's FTP credentials into their system. We have no reason to believe they are not trustworthy, but it still seems like a security risk to store our payment gateway credentials on a third party system.

            Weedpacket wrote:

            Treat the production server's copy as a working copy and as part of the deployment process do an "svn up"?

            I recall having done this once and can't recall the reasons why we thought it was a bad idea. Some ideas come to mind:
            1) all the little .svn directories and such -- might these be exploited to view source code?
            2) risk of over-writing important credential files with sandbox credentials if a dev were to commit such a file to the repo
            3) adds a lot of complexity to the file system with all of the additional .svn directories and such
            4) possible changes to permissions might deprive cron/apache/users of ability to write a particular file?

            Thinking a bit more about it, I'm wondering if it might still be worth it. We might solve #1 with some kind of Apache directive? #2 we might solve by making important credential files read-only? #3 I could probably live with. #4...not sure.

              sneakyimp wrote:

              2) risk of over-writing important credential files with sandbox credentials if a dev were to commit such a file to the repo

              A pre-commit hook might be able to prevent that.

              Incidentally, at work, we have git repositories on the production servers that are updated on demand.

                Write a Reply...