Project

General

Profile

Mirroring Trac

The motivation for this article is to describe setting up two identical Trac installations accessing the same database. One is to a Shibboleth protected setup":http://dev.e-taxonomy.eu/trac. The other refers to the "Trac installation for EDIT developers

The following sections describe the crucial points setting up a Trac mirror.

Installing Trac

Trac is programmed in python, runs on Apache2, relies on a subversion repository and our mirror site is running against a postgres database. So, the following packages needs to be in place before installing Trac.

apt-get install python
apt-get install libapache2-mod-python
apt-get install python-psycopg2
apt-get install python-subversion

Furthermore, we need to enable the python module on the Apache server.

a2enmod mod_python

Next, the python setuptools are required to setup python.

apt-get install python-setuptools

Now, we are prepared to download the same Trac version as installed on the master site (0.10.4). Then, the software has to be extracted to somewhere and has to be installed running the setup.py script.

wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
tar xvfz trac-0.10.4.tar.gz
cd trac-0.10.4
python setup.py install

This should install the Trac system to /usr/share/trac.

Installing plugins

Next, the same trac plugins as on the master must be installed on the slave too.

This can be done by simply copying any .egg files from the master site to the directory /usr/share/trac/plugins/

Otherwise, the plugins can be downloaded from e.g. the trac-hacks plugin page":http://trac-hacks.org/wiki/plugin and installed along the instructions on the "Trac wiki

Further on, the installed plugins must be enabled within the [[components]|section of the trac configuration file. (see [#ConfiguringtheTracMirror Configuring the Trac Mirror]]

Currently, the following plugins have to be installed

  • graphviz-0.6.9-py2.4.egg

  • TracExtendedXmlRpc-0.1-py2.4.egg

  • TracWebAdmin-0.1.2dev_r5753-py2.4.egg

  • TracNavigationMenu-1.0m-py2.4.egg

  • TracXMLRPC-0.1-py2.4.egg

Installing Macros

Also, the same wiki macros have to be installed on the slave site as on the master.

So, the easiest way is to simply copy these macros from the master site to the directory /usr/share/trac/wiki-macros/

Alternatively, macros can be downloaded from trac-hacks macros page

Currently, the following wiki macros have to be installed

  • CSV

Installing others

Further on, the current master site relies on several other packages, which should be installed as well

apt-get install python-docutils
apt-get install python-clearsilver
apt-get install graphviz
apt-get install python-pydot
apt-get install librsvg2-bin

Configuring the Trac Mirror

Since, we like to setup a mirror for the EDIT Developers Wiki, we should get the master's configuration file and copy it into the subdirectory conf of the EDIT project environment within trac (i.e. /var/www/trac/edit/conf/trac.ini)

Next, the Trac configuration file needs to be adapted to the mirror's environment. Here are some crucial points to take care off.

components section::

Take care to enable any installed plugins or macros here

graphviz section::

Create or change the directory given in the variable cachedur_

project section::

Adapt the url variable and the location of the icon.

trac section::

Adapt the database url (database=postgres://:@/trac_edit) and the path to the subversion repository (repository_dir). Attention: The repository must be located at the same path as the master repository. Otherwise, it will not work due to the shared database configuration. Also, it is not possible to use remote repositories. Thus, a local Subversion repository mirror has to be installed on the mirror site as well.

Subversion mirror

A local mirror of the master's subversion repository will be needed to run the Trac mirror. Please, refer to the Subversion repository mirror article.

Templates

Additional templates from the EDIT project environment should be copied to /var/www/trac/edit/templates.

htdocs

Additional htdocs from the EDIT project environment should be copied to /var/www/trac/edit/htdocs.

Attachments

Unfortunately, Trac stores any attachment files locally in the attachment subdirectory of the relating project environment (e.g. /var/www/trac/edit/attachments). So, they have to be transferred manually to the mirror site.

TODO: Implement a method to synchronise the attachment file regularly. May rsync would be a solution to do this. Another idea is to use the subversion repository to store and access the attachments. Perhaps, there will be already an existing plugin doing this job ?

Enabling Apache

Enabling Trac as an Apache site can be done by providing a site description e.g. like /etc/apache2/sites-available/trac and to enable the site by

a2ensite trac

Here is a valid site description for trac with Shibboleth single sign-on. Make sure to adopt the PythonOption !TracEnv and !TracUriRoot to your needs.

<Location /trac>
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /var/www/trac/edit
    PythonOption TracUriRoot /trac

    AuthType           shibboleth
    ShibRequireSession On
    require            valid-user
</Location>

Alias /_sharedtrac "/usr/share/trac/htdocs"
Alias /trac_htdocs "/var/www/trac/edit/htdocs"
<Directory "/usr/share/trac/htdocs">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Finally, restart apache and hopefully enjoy your trac mirror!

Troubleshooting

Different Subversion Repository UUIDs

Whenever Trac comes up with an error message enforcing you to run trac-admin resync, then take a look at the log file in /var/www/trac/edit/logs/trac.log. If there is a line stating that the repository uuid does not match, then this problem could be solved by setting the same repository uuid as on the master repository.

Add picture from clipboard (Maximum size: 40 MB)