Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

  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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top