Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Quick overview of the problem. I have a website that is in SVN and checked out on 2 different servers for load balancing. It's a drupal site and everything besides the assets and files directory is checked out locally on the servers.

Now on an update i have to update the two local checkouts manually.(svn up) This is prone to errors and will provide even more overhead if we decide to add another webserver to the rotation.

So in short: I have to find a way to automate keeping the 2 local checkouts in sync so i only have to update on 1 server and everything gets synced.

Things i have tried:

  • md5 sum of the directory on server 1 and through SSH on server 2 (excluding the .svn directories) using a find command, then executing svn ups on server 2 using the outcome of diff as arguments. It always gives me the same files that are different.

    ssh $TARGET "cd "$SVN_TARGET" && find . -name .svn -prune -o -type f -print0 | xargs -0 md5sum" >> /tmp/server2.sums

    cd $SVN_SOURCE && find . -name .svn -prune -o -type f -print0 | xargs -0 md5sum >> /tmp/server1.sums

    diff /tmp/server1.sums /tmp/server2.sums | cut -d"." -f2 | xargs -i ssh $TARGET "su www-data -c 'svn up /dir/to/svn/repo/{} --username \"*\" --password \"**\"'"

  • using svn info and then svn diff with the head revision to give me all the files changed. The problem there is that the local revision id doesn't equal the one of the head revision on the SVN server even when it's up to date.

Any help is much appreciated and excuses for the wall of text :)

share|improve this question
I used a custom post-commit hook script for the svn repo that parses on several words in the path using "/usr/bin/svnlook changed $REPOS -r $REV | sed "s/^....//" " to get the files changed and based on that issueing svn update commands through SSH on the correct servers Thanks for the help and all the answers, learned some new stuff along the way :) – plaix May 26 '11 at 8:05
up vote 0 down vote accepted

What about a crontab entry on each host which runs a script each five minutes? The script could update the svn repository and do whatever post-processing is deemed necessary... .

Or you could have a post-commit hook in subversion trigger the deployment to the two clients... .

share|improve this answer

How about a control job running in crontab on one of the hosts which does an svn info to determine the revision, that then does a svn update to that revision and at the same time runs an ssh svn update to the same revision on the other host?

share|improve this answer
I tried that, the problem there was that the revision id you get from svn info isn't the current revision from the svn repository. – plaix May 25 '11 at 9:24
If you grep for Revsion in the output it will be. Just don't use Last Changed Rev. – Decado May 25 '11 at 13:29

In case you're running on linux OSes you may use DRBD to sync the datas between the two SVN servers at the block level without worrying about Subversion.

share|improve this answer

I strongly recommend using capistrano for code deployment. See following tutorials for integration with Drupal: first and second.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.