4 This CGI script mirrors a source directory to a target directory using
5 a Subversion repository as an intermediary. It's written as a CGI
6 script so that remote users making changes to a WebDAV folder can tell
7 the server to mirror the WebDAV folder contents to another directory
8 on the system. See the example usage story below.
10 This script could be easily changed to run as a normal script.
15 1) You get versioning, diff emails, etc for the modifications to the
17 2) All changes to the source directory are backed by Subversion's
19 3) You have a directory remotely accessible by WebDAV and you want to
20 see what changes are made to the directory, plus the ability to get
21 older versions of the directory.
26 This script is used in this little story.
28 A client has a staging and production web server. The client wants to
29 remotely update the content on the staging server and then push that
30 content to the production server when the updated content is checked
31 out and ready. I didn't want to use FTP for security reasons.
32 Additionally, I wanted to add the ability to track changes to the
33 content and send out commit emails. Also, I wanted to use WebDAV over
34 HTTPS to allow the client's Microsoft Windows OS and FrontPage to
37 Since Subversion isn't a full WebDAV server that operates with
38 Microsoft, I hacked together this solution.
40 I set up a DAV directory using Apache 2's mod_dav that the clients
41 connect to over HTTPS. This directory is the DocumentRoot for an
42 Apache 1 server (under a different username). Any changes to this
43 WebDAV directory are shown immediately in the staging server. When
44 everything looks fine, they use the attached CGI script which calls
45 svn_load_dirs.pl to mirror the staging directory exactly into the
46 Subversion repository. The CGI script uses the REMOTE_USER as the
47 name to perform the 'svn commit' as for tracking purposes. The
48 post-commit hooks then send out the diff email. After the commit
49 succeeds, the CGI script then checks out the repository into the
50 production web server directory.
55 1) Get a copy of svn_load_dirs.pl, revision 3787 or later. You can
58 http://svn.collab.net/repos/svn/trunk/tools/client-side/
60 2) Edit the configuration variables in mirror_dirs_through_svn.cgi so
61 it knows the location of svn, the location of svn_load_dirs.pl, the
62 source directory, the target directory, and the URL to the
63 directory in the Subversion repository where the source directory
66 I don't recommend using the top URL of the Subversion repository,
67 because you can't create tags of the source directory. For
68 example, you may want to use a URL like
70 http://svn.myserver.com/repos/trunk/mirror_this_dir
72 This way you can create a tag of the source directory at special
75 http://svn.myserver.com/repos/tags/mirror_this_dir/something_special
77 3) Set up CGI on your server and install this script.