views:

78

answers:

3

Hello,

I've started using subversion to keep track - and be able to reverse - of our website changes related to its development and maintenance. Loving this feeling of security it provides!

I would like to know if there would be a tool / a way to be able to automate the synchronisation between the "live" website and the subversion repository. It would be great to be able to both commit a bug patch to the repository and to the live version (right now i manually upload via ftp the corrected file, then commit it to the subversion repository).

I'm sure this must exist somewhere, but under which name ? What set up does it need?

Thank you for your feedback, A.

+2  A: 

Basicly you could do it with svn repository hooks, especially the post-commit hook.

splash
Info on hooks from the svn book: http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-5-sect-2.1
Roman A. Taycher
+3  A: 

You can create a post-commit hook that will export your repository at the latest revision to your webserver directory:

#!/bin/sh

# Delete Old site
rm -R /var/www/website

# Export Repository
svn export --force file:///var/svn/website /var/www/website

# Make sure Apache Owns the website
chown -R www-data:www-data /var/www/website 

(credits to this forum thread)

Save this in a file called post-commit, in the hooks directory of your repository, and make it executable.

If the repository and website are not on the same server, you'll want to export in a temporary directory, and then push it via ftp or scp

EDIT: found also this perl module that could do the job: SVN::Notify::Mirror

CharlesB
This sounds really close to my set up: i indeed host the repository and the website on the same server account. Great! But Wow: the "delete old website" part is mandatory? It's 1.5gigs. I'd rather have it update only what has changed.
pixeline
nothing mandatory, it's just an example you can adapt! you can do an svn update from a temp working copy and rync your website to it your with .svn exclusion
CharlesB
Thanks a lot Charles!
pixeline
You're welcome! the yesterday's site problems cancelled your acceptance, could you reaccept? Thanks
CharlesB
+1  A: 
  1. Create a working copy(a local copy) of the repository/website in your webserver by performing a svn checkout.
  2. you can setup a task in cron/scheduler (depending on linux/windows). The task can do a svn update in your working copy. This can be done every few mins/hours, depending on the frequency of your commits.
  3. Direct your webserver not to display .svn dirs. In case of apache, you can include the below lines in to your httpd.conf (there should be a way in IIS too, let me know if you need this for windows)
<DirectoryMatch \.svn>
   Order allow, deny
   Deny from all
</DirectoryMatch>

AliasMatch \.svn /non-existant-page
Version Control Buddy
Interesting approach, using a cronjob to sync regularly. Thanks!
pixeline