Non-destructive migration from Mantis to Redmine
Once in a while i have to have new software. On a recent research about using VCS on NAS devices i came across Redmine (cause they talk about GIT and Mercurial a lot). We have used Mantis for at least two years and were never really satisfied with it – don’t get me wrong, it is a great piece of software, but kind of slow to handle. However, i installed Redmine for a recent project of us and it worked out really well.
Now i had to transfer our whole mantis database of the last years into Redmine. There is an official migration guide/script, but it does work destructive (kills all your Redmine data) and has also problems with the latest Mantis version (1.2.0) – or at least i assume it’s only with the latest. Being a Perl programmer has it advantages (besides being a Perl programmer), so i wrote a migration script myself, based on the rake-file from the Redmine source.
About
So here is what it does in short:
- Migrate existing Mantis database non-destructive (keeps your Redmine data).
- Able to map Mantis data to coresponding Redmine data (eg users, projects and so on).
- Fully user interactive (suggest what to map to what, but gives you the capability to change.. assume you have a highly configured Mantis installation).
Things you should keep in mind before migration:
- Custom fields of the type multi list are not supported in Redmine.
- Custom fields of the type checkbox with multiple values will be translated to simple lists.
- Migrates only attachment files which are stored in the database (default).
- Tested only with Mantis 1.2.0 (current) and Redmine 0.9.3 (debian current).
- Make a backup of your Redmine database BEFORE you run the script (eg mysqldump..)!
And another thing: this is a “work in progress”, no warranties, guaranties, whats-o-ever are given.
Install
Download (below) the script, put it in some directory (it will create multiple small YAML files and save all attachment files from the Mantis database to disk – size depends on your data).
Make it executable:
chmod +x mantis2redmine.pl
You need perl up and running. Also install prerequisite perl modules (YAML, DBIx::Simple). On debian that would be:
apt-get install libyaml-perl libdbix-simple-perl
Maybe create a configuration file. All command line parameters could be written in the file. Example:
mantis_db_host = localhost mantis_db_name = mantis mantis_db_login = mantis_user mantis_db_pass = mantis_password redmine_db_host = localhost redmine_db_name = redmine redmine_db_login = redmine_user redmine_db_pass = redmine_password
You can run the script with ‘–help’ to see all possible parameters.
Usage
I suggest you run the script in dry-run-mode and setup the Mantis->Redmine mappings as you like (script will guide you through):
./mantis2redmine.pl -c config.file --dry_run
Even in dry-run-mode all your mappings will be stored in files in the current folder (store-<name>.map). If you want re-configure any mapping, simply remove the store-file and run the script again. Now make a backup of your Redmine database and run the script again:
./mantis2redmine.pl -c config.file --load_maps
This could take some time, depending on the size of your original Mantis database.
After the script finishes successfully check your Redmine installation. Probably you have to assign the imported (or existing) users to the projects (because Redmine supports groups the script doesn’t do that).
The last step is to copy all exported attachment files (default in ‘./attachments/’ folder) in your Redmine file directory (in a “normal” Redmine installation this would be ‘/files’ in your Redmine base dir; if you installed via debian apt-get it is in ‘/var/lib/redmine/default/files’).
Done.
Download
Here it is: mantis2redmine-0.2.tar,gz
mantis_user
My Name is Ulrich Kautz and this is my private blog about server administration, perl programming and some other stuff that is on my mind. I study part-time computer sience at FU Berlin and work as sys admin and web developer at our hosting company
on ubuntu 10.04 this script gave me errors:
is on spanish and means: file or folder doesn’t exist.
i did install libraries YAML, DBIx::Simple as you apt-get command said.
what can i do to make it work?
thanks!
Seems i’ve got linked /usr/bin/env to /bin/env for some reason and assumed this the correct path. Is fixed now. Download again, or change first line in the file to
i’m beginning to walk, but a few steps after a fall down
this is the command i used
had to do it with attachment_dir option cuz it force me to (didn’t create it by default or automaticly).
running it i began to see errors:
*** Projects *** Use of uninitialized value $first_id in hash element at ./mantis2redmine.pl line 366, line 3. Use of uninitialized value within @_ in list assignment at ./mantis2redmine.pl line 976, line 3. Mantis: Project micontrol - csystems : 1 micontrol - aguasanandres : 2 micontrol - rexhelmez : 3 Redmine: Project Project translation Mantis -> Redmine 1:micontrol - csystems -> -1:new 2:micontrol - aguasanandres -> -1:new 3:micontrol - rexhelmez -> -1:new Use of uninitialized value in concatenation (.) or string at ./mantis2redmine.pl line 1015, line 3. Use of uninitialized value in concatenation (.) or string at ./mantis2redmine.pl line 1015, line 3. Type 'ok' if you confirm or num:num or num:-1 for create as new to change assignment eg 3: to change Project of 'micontrol - rexhelmez' to '' type 'print' to show the Redmine/Mantis tabels again (ok/num:num/print) > ok *** Versions *** Use of uninitialized value $first_id in hash element at ./mantis2redmine.pl line 404, line 4. Use of uninitialized value within @_ in list assignment at ./mantis2redmine.pl line 976, line 4. Mantis: Version Redmine: Version Version translation Mantis -> Redmine Use of uninitialized value $last_mantis in concatenation (.) or string at ./mantis2redmine.pl line 1015, line 4. Use of uninitialized value in concatenation (.) or string at ./mantis2redmine.pl line 1015, line 4. Use of uninitialized value $last_mantis in hash element at ./mantis2redmine.pl line 1015, line 4. Use of uninitialized value in concatenation (.) or string at ./mantis2redmine.pl line 1015, line 4. Use of uninitialized value in concatenation (.) or string at ./mantis2redmine.pl line 1015, line 4. Type 'ok' if you confirm or num:num or num:-1 for create as new to change assignment eg : to change Version of '' to '' type 'print' to show the Redmine/Mantis tabels again (ok/num:num/print) > ok Use of uninitialized value in numeric eq (==) at ./mantis2redmine.pl line 943, line 5. Can't use an undefined value as a HASH reference at ./mantis2redmine.pl line 943, line 5.after that it creates:
with attachment dir empty. obviously there are misssing maps…doesn’t it?
any ideas?
Sorry, got swamped with daily business. Ok, i’ve looked in the code. As it seems, those errors indicate, that your redmine is kind of empty and the script does not handle this very well. Is your redmine db empty (important for further debugging)?
just the default_data from a fresh install
Alright. I’ve writte it to migrate mantis databases into existing redmine databases with already existing content. I think the default importer from mantis works perfectly with fresh databases. However, i’ve made some small adjustments and it should work now also with empty redmine databases. Download above. Thanks for reporting.