Migrating and upgrading Mantis

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
elpakko
Posts: 10
Joined: 10 Jun 2010, 05:42

Migrating and upgrading Mantis

Post by elpakko »

Hello.

I was wondering if anyone would have instructions or tips on how to migrate and upgrade an old Mantis database in the following situation:

- Old machine 6-7 years old with very old MySQL, PHP and Mantis 0.19.2
- I would prefer moving the old database without the need to upgrade Mantis first on the old server
- Target machine linux with the latest MySQL, PHP and Mantis or a Mantis virtual appliance for VMware
- For curiosity I tried a simple mysqldump and restore to a empty Mantis 1.1.6 (TurnKey virtual appliance). Surprise surprise this didn't work.

Should I do a clean installation from scratch or can I use a virtual appliance for Mantis? I guess normal upgrade procedure is out of the question as our Mantis is so old.

I would appreciate any help.

Thank you!
elpakko
Posts: 10
Joined: 10 Jun 2010, 05:42

Re: Migrating and upgrading Mantis

Post by elpakko »

Here is some additional information.

I installed a fresh install CentOS + Apache + MySQL + PHP + Mantis 1.21. With this freshly installed Mantis database everything worked like charm, check.php did not report any problems or errors.

Then I restored our old Mantis database to the fresh install Mantis using command: "mysql --force -u root -p mantis < mantisdump"
The restoration was succesfull, however it produced many errors like this one:

"ERROR 1136 (21S01) at line 56: Column count doesn't match value count at row 1"

Now when I try to log in to Mantis using some of the user accounts from our old Mantis installation, I get the following error:

APPLICATION ERROR #401

Database query failed. Error received from database was #1054: Unknown column 'lost_password_request_count' in 'field list' for the query: UPDATE mantis_user_table
SET lost_password_request_count=0
WHERE id=?.


Does someone now what could cause this problem?

Thanks.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Migrating and upgrading Mantis

Post by atrol »

The database schema between your very old MantisBT and current 1.2.1 changed.
You can't import old data in new schema without problems.
You have to create a new empty database, import the old dump and let MantisBT installation procedure upgrade the old schema to the new one.
Read file doc/INSTALLATION of your 1.2.1 MantisBT download how this is done.
Please use Search before posting and read the Manual
elpakko
Posts: 10
Joined: 10 Jun 2010, 05:42

Re: Migrating and upgrading Mantis

Post by elpakko »

atrol wrote:The database schema between your very old MantisBT and current 1.2.1 changed.
You can't import old data in new schema without problems.
You have to create a new empty database, import the old dump and let MantisBT installation procedure upgrade the old schema to the new one.
Read file doc/INSTALLATION of your 1.2.1 MantisBT download how this is done.
So correct me if I'm wrong but I should first create an empty database 'mantis' and then restore with mysqldump? And after that I should install Mantis from scratch? I will try this, thank you!

Can I try the uninstallation procedure or is it better to start everything from the beginning?
elpakko
Posts: 10
Joined: 10 Jun 2010, 05:42

Re: Migrating and upgrading Mantis

Post by elpakko »

Okay, thanks for the tip. The next thing I tried was that I uninstalled Mantis and dropped the "mantis" database from mysql. Then I created a new empty database "mantis" and restored the old database to that one. Then I launched http://localhost/mantis/admin/install.php and inserted values needed. During the install procedure i get the following error under the "Installing Database":

Schema CreateTableSQL ( mantis_bug_file_table )

BAD
CREATE TABLE mantis_bug_file_table ( id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, bug_id INTEGER UNSIGNED NOT NULL DEFAULT 0, title VARCHAR(250) NOT NULL DEFAULT '', description VARCHAR(250) NOT NULL DEFAULT '', diskfile VARCHAR(250) NOT NULL DEFAULT '', filename VARCHAR(250) NOT NULL DEFAULT '', folder VARCHAR(250) NOT NULL DEFAULT '', filesize INTEGER NOT NULL DEFAULT 0, file_type VARCHAR(250) NOT NULL DEFAULT '', date_added DATETIME NOT NULL DEFAULT '1970-01-01 00:00:01', content LONGBLOB NOT NULL, PRIMARY KEY (id) )ENGINE=MyISAM DEFAULT CHARSET=utf8
Table 'mantis_bug_file_table' already exists


I'm not a MySQL specialist so I'm not able to figure out what might be the problem there. Thanks again for your patience...
elpakko
Posts: 10
Joined: 10 Jun 2010, 05:42

Re: Migrating and upgrading Mantis

Post by elpakko »

As said before I'm not a specialist but for some ridicilous reason I was succesfull in the migration process. I checked the following post and manually changed the corresponding lines in "schema.php"

http://www.mantisbt.org/bugs/view.php?id=6307

So if someone else is having troubles with 0.19.2 --> 1.21 migration, here's what I did:

- create a new database 'mantis' in MySQL
- backup your old database with command 'mysqldump --opt -u<username> -p<password> <database name> > <backup file>'
- restore to the previously created empty 'mantis' database with command 'mysql --force -u<username> -p<password> <database name> < <backup file>' (Ignore the error messages)
- start the Mantis installation process by invoking install.php from the browser
- now you are getting errors similar to what you see in the previous post. Look what is the name of the table the error refers to and start editing the /var/www/html/mantis/admin/schema.php
- In this case I first had to find the line number 50:

$upgrade[] = Array('CreateTableSQL',Array(db_get_table('mantis_bug_file_table'),

and change the "CreateTableSQL" to "ChangeTableSQL":

$upgrade[] = Array('ChangeTableSQL',Array(db_get_table('mantis_bug_file_table'),

- After this start the install.php again
- Now you probably will see another error message referring to a different table in the database. Again you will have to edit the schema.php accordingly and change the corresponding CreateTableSQL to ChangeTableSQL
- I had to edit the schema.php file about 15 times before all the needed "Create" statements were replaced with "Change"
- It might also work so that you would replace all the statements in the file, but I don't know what will happen to tables which do not originally produce this error

It's a lot of work but it worked! Hopefully this also helps someone else.

Thanks for your help!
jon-lybrook
Posts: 1
Joined: 08 May 2012, 22:18

Re: Migrating and upgrading Mantis

Post by jon-lybrook »

Running install.php and modifying schema.php as elpakko discovered definitely works. I just upgraded a 0.18 version to the latest and greatest after about 25 edits to schema.php. In one go-around I deleted a table and let it get recreated. Whew. Thanks for posting your results elpakko. Definitely wouldn't have proceeded down that path without some glimmer of hope from your posting that it was indeed the right approach...even a year later!

Cheers,
Jon Lybrook
JasonTEPOORTEN
Posts: 2
Joined: 05 Jul 2012, 01:35
Contact:

Re: Migrating and upgrading Mantis

Post by JasonTEPOORTEN »

I have a procedure that can be used to migrate your current MantisBT 1.0.8 installation from one server to a virtual machine running MantisBT 1.2.11.

Please let me know if there are errors in this procedure.

Please TEST this procedure before using it for a LIVE, PRODUCTION implementation.

This procedure has the following assumptions:
1. The latest version of the Oracle VirtualBOX is used (although any recent hypervisor will do);
2. The FileZilla SFTP client is the preferred method of uploading files to the virtual host;
3. The Desktop PC is running Microsoft Windows 7 or greater;
4. The Desktop PC current user has permission to install software;
5. The target virtual host will be built using the Turnkey LAMP appliance;
6. The target virtual host will be hosted on a hypervisor that will be accessible;
7. The Apache web server base WWW directory is “/var/www/”; and
8. The MySQL 5.x DBMS is the database environment on the current host.

The password “yourMantisDatabasePassword” needs to be changed to your sites preferred password.

Materials (based on using Oracle VirtualBOX):
1. Turnkey Linux LAMP Virtual Appliance: “turnkey-lamp-11.3-lucid-x86”
2. 10 GB Free Hard Drive Space
3. 384 MB RAM
4. Bridged Network Adapter
5. Disabled USB Controller
6. Disabled absolute pointing device
7. FileZilla SecureFTP Software

Steps:

1. Download and install the tools to complete the implementation.
a. FileZilla: http://downloads.sourceforge.net/projec ... ror=aarnet
b. Turnkey Linux LAMP installation CD: turnkey-lamp-11.3-lucid-x86.iso: http://www.turnkeylinux.org/download?fi ... id-x86.iso

2. Build the virtual host and install the base server environment:
a. Define the virtual host with 384 MB ram and a 8 GB hard drive
b. Set the CD to use the “turnkey-lamp-11.3-lucid-x86.iso” and ensure it will boot from the CD when there is no bootable hard drive partition.
c. At the “Turnkey” boot screen, select “Install to hard disk”.
d. At the “Debian Installer Live” screen, select “Guided – use entire disk”.
e. At the “Debian Installer Live” screen, select “Yes” for the “Write the changes to disks” prompt.
f. At the “Debian Installer Live” screen, select “Yes” for the “Install the GRUB boot loader to the master boot record” prompt.
g. At the “Debian Installer Live” screen, select “Yes” for the “Would you like to restart now” prompt.

3. Configure the OS via the First Boot Configuration:
a. Enter “yourMantisDatabasePassword” as the “root” password at the “Please enter a new password for the root account” prompt.
b. Enter “yourMantisDatabasePassword” as the “root” password at the “Confirm password” prompt.
c. Enter “yourMantisDatabasePassword” as the “root” password at the “Please enter a new password for the MySQL ‘root’ account” prompt.
d. Enter “yourMantisDatabasePassword” as the “root” password at the “Confirm password” prompt.
e. Enter “yourMantisDatabasePassword” as the “root” password at the “Enter new password for the Mantis ‘admin’ account” prompt.
f. Enter “yourMantisDatabasePassword” as the “root” password at the “Confirm password” prompt.
g. Select “Skip” at the “Initialize Hub Services” screen.
h. Select “Skip” at the “Security updates” screen to prevent downloading 150 MB of patches.
i. At the “LAMP appliance services” screen, take note of the following details:
• Web: http://HOST_IP/ and https://HOST_IP/
• Web Shell: https://HOST_IP:12320/
• Webmin: https://HOST_IP:12321/
• PHPMyAdmin: https://HOST_IP:12322/
• SSH/SFTP: root@HOST_IP (port 22)
j. The appliance is ready for use.
k. It is recommended that a static IP address and a hostname is assigned by the your network administrator in the network’s DNS.

4. Prepare MantisBT installation package
a. Upload MantisBT installation package, “mantisbt-1.2.11.zip”, to root@HOST_IP:/root/installs/mantisbt/, using Secure FTP. FileZilla is the preferred program.
b. Login to the Web Shell as “root”.
c. Use the command “(cd /var/www && unzip ~root/installs/mantisbt /mantisbt-1.2.11.zip && mv mantisbt-1.2.11 mantis)”.
d. Create the “/var/www/mantis/config_inc.php” file by copying the “config_inc.php” from the current MantisBT environment.
e. Modify the “/var/www/mantis/config_inc.php” file by updating the following variables to reflect the new host:
$g_hostname = 'localhost';
$g_db_type = 'mysql';
$g_database_name = 'mantis';
$g_db_username = 'root';
$g_db_password = 'yourMantisDatabasePassword';

5. Create empty MantisBT database:
a. Login to the Web Shell as “root”.
b. Use the command “(echo "CREATE DATABASE mantis\\g" | mysql --user="root" --password="yourMantisDatabasePassword")”

6. Backup the MantisBT database on your current host and upload the backup file from the current host to the new host at /root/installs/mantisbt/ as Z_MANTIS_DB_BKP.SQL

7. Restore the “Z_MANTIS_DB_BKP.SQL” into the new host's “mantis” database using the command “(mysql --user="root" --password="yourMantisDatabasePassword" mantis < installs/mantisbt/Z_MANTIS_DB_BKP.SQL)”

8. Run the MantisBT installation package
a. Through your web browser, go to http://HOST_IP/mantis/admin/install.php.
b. At Installation Options, if prompted:
• Set “Type of Database” to “MySQL (default)”
• Set “Hostname (for Database Server)” to “localhost”
• Set “Username (for Database)” to “root”
• Set “Password (for Database)” to “yourMantisDatabasePassword”
• Set “Database name (for Database)” to “mantis”
• Set “Admin Username (to create Database if required)” to “root”
• Set “Admin Password (to create Database if required)” to “yourMantisDatabasePassword”
• Enable “Print SQL Queries instead of Writing to the Database”
• Click “Install/Upgrade Database”.
• Manually create the “/var/www/mantis/config_inc.php” based on the instructions provided to create it.
• Backup the “/var/www/mantis/admin/schema.php” file.
c. Upgrade the database schema
• Again, through your web browser, go to http://HOST_IP/mantis/admin/install.php, and Click “Install/Upgrade Database”.
• The MantisBT forum post, “Migrating and upgrading Mantis”, http://www.mantisbt.org/forums/viewtopi ... =2&t=10830, was referred to determine the database schema upgrade procedure.
• For each “CREATE TABLE” error, update the “/var/www/mantis/admin/schema.php” file by changing “CreateTableSQL” to “ChangeTableSQL” for that table and click “Retry”. The table for this upgrade from 1.08 to 1.2.10 are:
• “mantis_email_table”
• “mantis_tag_table”
• “mantis_bug_tag_table”
• For each “ALTER TABLE ADD INDEX” error, disable that statement.
• For the prompt “Install was successful”, click “Continue”.

9. Your new MantisBT installation should be operational.
atrol
Site Admin
Posts: 8366
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Migrating and upgrading Mantis

Post by atrol »

JasonTEPOORTEN wrote:I have a procedure that can be used to migrate your current MantisBT 1.0.8 installation from one server to a virtual machine running MantisBT 1.2.11.
Thanks for this contribution.

What I am missing:
To preserve your system settings, you should copy the files listed below to the new directory, as well as any other custom files such as logo, favicon, css, etc.
config_inc.php custom_strings_inc.php custom_constants_inc.php custom_functions_inc.php

If your attachments are stored on disk ($g_file_upload_method = DISK;) you have to transfer the attachments and to change the paths in database if you use another path on the new system. Change also $g_absolute_path_default_upload_folder if this setting has been used.
Please use Search before posting and read the Manual
Post Reply