Home > Allgemein > Migrating from Mantis to Redmine

Migrating from Mantis to Redmine

Today we migrated from our old Mantis 1.1.x Installation to Redmine 0.9 (Debian package). Using the migration-script redmine:migrate_from_mantis made great work after some minor traps.

First there was a bug in /usr/share/redmine/lib/tasks/migrate_from_mantis.rake:287. Replaced :role by :roles and added proper [] this was fixed fast. Thereby we’ve changed the default password ‘mantis’ for all users to a generated one (/usr/share/redmine/lib/tasks/migrate_from_mantis.rake:257). After that the import stoped with

rake aborted!
Validation failed: Login has already been taken

Easy reason, 1 hour of debug: User admin was already in the "clean" database of Redmine, so the Mantis user admin has to be renamed.

The most time consuming issue was the encoding. The Mantis database has had the character set latin1 and redmine utf8. This made the import stop when having categories with german umlauts in them (SQL-errors) or cut the complete text before the first umlaut. Having that mastered here is the final mini-script we use to migrate:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# prepare mantis database (copy from another host, encoding)
ssh mantishost "mysqldump --add-drop-table mantisdb | gzip - -c" | gunzip - -c \
        > ~/bugtracker.mysql
# we don't need to recode
# recode ISO-8859-1..UTF-8 < db-latin1.mysql > db-utf8.mysql
# replace charset table definition
sed -i 's/CHARSET=latin1/CHARSET=utf8/g' ~/bugtracker.mysql
echo "drop database bugtracker"|mysql
echo "CREATE DATABASE bugtracker DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"|mysql
mysql bugtracker < ~/bugtracker.mysql
echo "UPDATE mantis_user_table SET username='adminMantis' WHERE id=1"|mysql bugtracker

# cleanup redmine
echo "drop database mit_redmine" | mysql
echo "CREATE DATABASE mit_redmine DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"|mysql
# remove attachements
sudo sh -c "rm /var/lib/redmine/default/files/*"
cd /usr/share/redmine
# prepare redmine
sudo RAILS_ENV=production rake db:migrate
sudo RAILS_ENV=production rake redmine:load_default_data

# finally run the migrate script
sudo rake redmine:migrate_from_mantis RAILS_ENV="production"

Running it (notice the latin1 instead of UTF-8 encoding):

> sudo rake redmine:migrate_from_mantis RAILS_ENV="production"
(in /usr/share/redmine)

WARNING: Your Redmine data will be deleted during this process.
Are you sure you want to continue ? [y/N] y

Please enter settings for your Mantis database
adapter [mysql]:
host [localhost]:
database [bugtracker]:
username [root]:
password []: xxx
encoding [UTF-8]: latin1

Migrating users..............................
Migrating projects.....................
Migrating bugs...[cut many dots and some warnings]
Migrating news.
Migrating custom fields.....

Users:           30/30
Projects:        21/21
Memberships:     69/69
Versions:        15/15
Categories:      213/213
Bugs:            2726/2726
Bug notes:       3774/3795
Bug files:       349/349
Bug relations:   1054/1064
Bug monitors:    47/53
News:            1/1
Custom fields:   5/5
  1. 18. Januar 2010, 21:25 | #1

    Hello,

    For those who (like me) would be interested in importing a Mantis 1.2.0rc1 database into Redmine without tearing their hair out, here is a very simple howto:

    http://www.webismymind.be/page/fr/17/migrate-mantis-120rc1-to-redmine.html

  1. Bisher keine Trackbacks