Migration einer existierenden Trac Installation nach Debian mit MySQL

Trac_logo.pngTrac ist eigentlich ein webbasiertes Projektmanagement Werkzeug für die Software Entwicklung. Es hat Wiki und Fehlermanagementfunktionen. Was mich aber am meisten interessiert ist die Oberfläche auf Subversion. Zusammenn mit dem Wiki kann damit schön Änderungen, die man in Subversion festhält, dokumentieren. Ich habe Trac zum ersten mal bei xtcmodified kennengelernt und auch Piwik nutzt es unter anderem

Im Rahmen meiner Servermigration von Gentoo nach Debian war es jetzt an der Zeit meine vorhandene Installation von Trac zu migrieren.

Zuerst installieren wir Trac und python-mysqldb da ich mit MySQL arbeiten möchte. Im den nächsten Schritten wird zuerst das Verzeichniss erstellt in das die Projekte kommen und wir erstellen die MySQL Datenbank

apt-get install trac python-mysqldb
mkdir /your-root-to-trac/trac
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
mysql> create database trac;
Query OK, 1 row affected (0.04 sec)
mysql> create user 'trac'@'localhost' identified by 'geheim';
Query OK, 0 rows affected (0.11 sec)
mysql> grant all on trac.* to 'trac'@'localhost';
Query OK, 0 rows affected (0.00 sec)

Jetzt haben wir die Voraussetzungen geschaffen und nun initialisieren wir die Trac Umgebung

trac-admin /your-root-to-trac/trac initenv
Creating a new Trac environment at /your-root-to-trac/trac/projekt
Project Name [My Project]>
  Please specify the connection string for the database to use.
  Database connection string [sqlite:db/trac.db]> mysql://trac:geheim@localhost/trac  
 
 Please specify the type of version control system,
 By default, it will be svn.

Repository type [svn]>

 Please specify the absolute path to the version control
 repository, or leave it blank to use Trac without a repository.

Path to repository [/path/to/repos]> /var/svn/project
Creating and Initializing Project
 Installing default wiki pages
[.......]
[.......]
[.......]
[.......]
[.......]

The latest documentation can also always be found on the project
website:

  http://trac.edgewall.org/

Congratulations!

Jetzt die alten Daten sichern. Auf dem alten Server in das Verzeichnis mit den Trac Daten gehen und ein Archiv der Anhänge erstellen sowie die Datenbank sichern.

cd /var/trac/old-trac
tar cvzf trac-attachments.bak attachments
mysqldump --user=trac --password=geheim trac | gzip > trac-datenbanken.sql.gz

Beide Sicherungen müssen auf den neuen Server kopiert werden. Dort auspacken und den Datenbankbackup einspielen

cd /your-root-to-trac/trac/projekt
tar xzvf /path/to/old-backup/trac-attachments.bak
gunzip /path/to/old-backup/trac-datenbanken.sql.gz
mysql --user=trac --password='geheim' trac < /path/to/old-backup/trac-datenbanken.sql

Dann kann man das ganze wie gewohnt aufrufen

tracd --port 8000 /your-root-to-trac/trac/projekt/

Wenn man jetzt noch die Anmeldung einrichten will

cd /your-root-to-trac/trac/projekt
htpasswd -c .htpasswd adminuser
tracd --port 8000 --basic-auth=projekt,/your-root-to-trac/trac/projekt/.htpasswd,/your-root-to-trac/trac --env-parent-dir /your-root-to-trac/trac

Nun brauchen wir noch ein Startup Script damit Trac auch beim Booten gestartet wird.

cd /etc/init.d
cp skeleton tracd
vi tracd

# Provides:          track
DESC="trac"
NAME=tracd
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="-d --port 8000 --basic-auth=projekt,/your-root-to-trac/trac/projekt/.htpasswd,/your-root-to-trac/trac --env-parent-dir /your-root-to-trac/trac"

chmod +x tracd

update-rc.d tracd defaults