Topic: Migrating a trac instance

Hi there.

I've been trying to install our project's ("radiocefyl") Trac instance on TuxFamily without success so far.

I tried the lineguides stated here: http://faq.tuxfamily.org/InstallTrac/Fr
I also tried some stuff from here: http://sourceforge.net/p/forge/communit … ed%20Apps/
(I'm migrating Trac from SourceForge to TuxFamily).

I've imported the database backup without any trouble using phpmyadmin.tuxfamily.org. However, Trac is giving me trouble, as can be seen here: http://radiocefyl.tuxfamily.org/cgi-bin/trac.cgi

The status of what i tried is as follows:

1)

I didn't managed to install Trac. It was giving me constant permission errors regarding the python packages directory. So, after lots of different tries, i just downladed Trac (using wget), untared it on my home directory,  and executed "python /home/radiocefyl/Trac-0.12/trac/admin/console.py /home/radiocefyl/trac initenv". That gave me a Trac clean enviroment on "/home/radiocefyl/trac".

2)

Then, i configured the MySQL connection string in "/home/radiocefyl/trac/conf/trac.ini", using the data stated here: http://faq.tuxfamily.org/DbMySQL/En
Tested the MySQL connection before that using mysql from console and everything was fine.

3)

Once configured, i deployed my environment.  "python /home/radiocefyl/Trac-0.12/trac/admin/console.py /home/radiocefyl/trac deploy /home/radiocefyl/radiocefyl.tuxfamily.org-web/htdocs".
With that, i had a cgi-bin directory created. But there where package errors, because Trac was not installed in the Python directory.

4)

So, i tested copying "/home/radiocefyl/Trac-0.12/trac/" to "/home/radiocefyl/radiocefyl.tuxfamily.org-web/htdocs/cgi-bin", in order to Python to find the packages locally. It worked, at least for the package errors.

5)

Then, i had IO errors. "/home/radiocefyl/trac/VERSION dows not exists". It was obviously a permission error, as the file did existed.
So, after trying lots of things, and reading this link, i copied "/home/radiocefyl/trac" to "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include", and in "trac.cgi" changed the TRAC_ENV var value to "../../php-include/trac".
That way, Trac UI began to work.

6)

Now i'm having an error saying that Trac can't find a module for handling wiki, and another one saying that MySQL database is not supported.



So... i'm lost. :(
And tired after hours of trying to hack this thing, honestly.

Can anybody give me a hand with this? Any comment will be fine.
I'm now thinking on installing a virtualenv somewhere, in order to do some proper Trac installation and see if anything changes...


Thanks,
Daniel.

Re: Migrating a trac instance

I can't remember the exact procedure I used to get trac working for me (see trac.stkaddons.net), but here's a few notes:
* I could not get the MySQL plugin working, so I opted for the file-based database (SQLite?) instead.
* I had to install a virtualenv and use this to install packages. I have a virtualenv and trac-env directory under my php-include directory for this webarea.
* easy-install did not ever work, I had to download and extract packages then run the setup.py script manually.
I also had saved some notes for upgrading trac and installing plugins which may be of use:
* Don't forget to run

export PYTHONPATH="<path-to-virtualenv>/lib/python2.6/site-packages/"

(needed every time you want to run a trac/python script from ssh) and use

python setup.py install --prefix=<path-to-virtualenv>

to install things.

I also have the following lines in .htaccess in the root of my webarea (web paths look like /data/web/xx/xx/xx/...):

SetEnv PYTHONPATH "$PYTHONPATH:<web path to virtualenv>/lib/python2.6/site-packages/"
SetEnv TRAC_ENV "<web path to trac-env>"

RewriteEngine on
RewriteBase /

RewriteRule ^chrome/(.*)$ /htdocs/$1 [NC,L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^wiki(/(WikiStart)?)?$ / [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cgi-bin/trac.cgi/$1 [L]
RewriteRule ^$ /cgi-bin/trac.cgi/ [L]

I am not sure if this is the best or most efficient way to install Trac, but it did work for me. I also have the following plugins installed to make life easier: TracSpamFilter, TracAccountManager

Hopefully that helps you to figure it out!
(Don't forget to make sure sensitive files are not web accessible! Anything in php-include can be read by your server but is not available through a URL directly.)

Re: Migrating a trac instance

Thanks stephen.

So far, i been able to install virtualenv and install trac 1.0 on it. But when i try to initialize te trac environment, i get this error:

Creating and Initializing Project
Installing default wiki pages
  TracPermissions imported from /home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/wiki/default-pages/TracPermissions
Initenv for '/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/trac' failed.
disk I/O error
Traceback (most recent call last):
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/admin/console.py", line 466, in do_initenv
    WikiAdmin(self.__env).load_pages(pages_dir)
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/wiki/admin.py", line 165, in load_pages
    if self.import_page(filename, page, create_only, replace):
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/wiki/admin.py", line 152, in import_page
    title))
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/db/util.py", line 121, in execute
    cursor.execute(query, params)
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/db/util.py", line 65, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/db/sqlite_backend.py", line 78, in execute
    result = PyFormatCursor.execute(self, *args)
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/db/sqlite_backend.py", line 56, in execute
    args or [])
  File "/home/radiocefyl/radiocefyl.tuxfamily.org-web/php-include/venv/lib/python2.6/site-packages/Trac-1.0-py2.6.egg/trac/db/sqlite_backend.py", line 48, in _rollback_on_error
    return function(self, *args, **kwargs)
OperationalError: disk I/O error

I couldn't neither install the MySQL bindings for python, as it seems require aditional packages. So, my strategy in that case was trying to convert my MySQL trac database to an SQLite one: but now Trac throws an error regarding its sqlite subsystem itself.

I was told installing Trac should be not this complicated. Maybe i'm doing something wrong?

Any clue, anyone?

I'll try again tomorrow. Maybe that sqlite error it's path related or something.

Re: Migrating a trac instance

Well... i managed to make it work... kind of.

http://radiocefyl.tuxfamily.org/cgi-bin/trac.cgi

I just ignored the installation errors and tried to deploy it. It worked, obviously having trouble with the database.

Next, i tried to convert from MySQL to SQLite. A complete PITA. But i did it after lots of tries.

Now, i'm having collation problems...

Re: Migrating a trac instance

I fixed the collation problems by changing the way mysqldump was supposed to be used as stated here: https://gist.github.com/943776
Just removing the "--compatible" flag did the trick.
Also, it's important to note that "COLLATE UTF8" did not work for sqlite3 and it didn't created the DB tables. Had to replace it by "COLLATE BINARY".

So far, so good. Now... can't login, or edit anything for the matter.
I'm having a strange "database newer than Trac version" error in the Trac logs.

To debug, i did this:

$ python
>>> import trac.env
>>> a = trac.env.Environment("path/to/my/environment")
>>> a.get_version()
[]
>>> trac.db_default.db_version
29
>>> exit()
$

get_version() should return a value stated in the "system" table in the trac.db sqlite database. Checked it, and its value is "21": but Trac is returning an empty list when trying to read that.

Enough for today, will debug this tomorrow.

Re: Migrating a trac instance

Phew! It's finally working :)


Had to manually fix some things in order to make it work:

1)

There were database migration errors (from MySQL, given that TuxFamily have not installed some required packages and i could not install them, to SqLite). The script i used is this one, recommended everywhere for the task: https://gist.github.com/943776

I modified it in order to read a mysqldump FILE instead of having to connect to a database.

Then, having the output, had to manually replace "COLLATE UTF8_CI" to "COLLATE BINARY".
That way, sqlite3 successfuly created the database.


2)

Then, i had error about the trac version. It said that "database newer than Trac version".
trac-admin env upgrade did nothing.
Debugging, found a problem with a record, and manually changed it.
The DB problem was gone.

The fix was:

insert into system (name, value) values ('database_version','29');

3)

Then, i had no login.
Reading about it, finally went to install AccountManager plugin: http://trac-hacks.org/wiki/AccountManagerPlugin

Had to download on my pc, then send it to my remote host space using scp. That's because didn't found any direct link for using with wget from the ssh session.

unzipped, installed, and then did ctrl+f5 (single f5 was not enough) on "/login". The login form was there.

4)

There were no users detected.
After lots of tries, went directly to trac-admin:

$ trac-admin myenv
- trac console 1.0 -
> permission add annonymous TRAC_ADMIN

That way, i had access to the administration panel, even when not logued in.
Once in the admin panel, i saw the different account manager options. It did not detect any user.
So, activated  SessionStore method, with a value of "1", HtDigestHashMethod, and a realm named "TracDbRealm".

With that, at least it let me create a user. I "created" the old user i was using as admin, and everything went successful. It even detected correctly the last time that user was logged in.

5)

However, there was one last error: i could not change permissions, because of a rare cache table error. Apparently, another migration problem. It said "cache table has 2 fields, but 3 values given".
Searching for that, i reached this post: http://www.gossamer-threads.com/lists/t … 8411#48411

So, went again to change the database manually:

$ sqlite3 myenv/db/trac.db
> drop table cache;
> CREATE TABLE cache (
... id integer PRIMARY KEY,
... generation integer,
... key text
... );
> .quit
$

That way, everything worked ok, and i could change the annonymous user permissions (removing TRAC_ADMIN).


Hope it helps someone else.