Project

General

Profile

Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine

Added by A Fora over 4 years ago

I have just installed a fresh v4.1.1 on a new system and tried restoring a mysql database backed up from a v.4.0.5 installation. Unfortunately the restored database gets (almost, but not entirely) inaccessible after the restore. Otherwise redmine works fine. I spent 2 days on this, and sadly I cannot find a solution.

Here's the steps to reproduce:

1. Installed a fresh v4.1.1 + restored (successfully) a mysql database created in v4.0.5:

gunzip -c /home/xxx/backup/mysql_2020-05-17.gz | sudo mysql --defaults-file=/usr/as/mysql/.my.cnf redmine_default

2. I can successfully login to redmine with the usual 127.0.0.1/redmine and see the list of projects.

3. However, if I click on any project, I get an Error 500 page

4. Inspecting `/usr/share/redmine-4.1.1/log` shows:

Completed 500 Internal Server Error in 151ms (ActiveRecord: 86.4ms)
ActionView::Template::Error (undefined method `description' for #<Tracker:0x00005613c65be020>):
65: <% @trackers.each do |tracker| >
66: &lt;tr&gt;
67: &lt;td class="name"&gt;
68: <
= link_to tracker.name, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id), :title => tracker.description >
69: &lt;/td&gt;
70: &lt;td&gt;
71: <
= link_to @open_issues_by_tracker[tracker].to_i, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id) %>
app/views/projects/show.html.erb:68:in `block in app_views_projects_show_html_erb_3010486713022863027_70353520498380'
app/views/projects/show.html.erb:65:in `_app_views_projects_show_html_erb__3010486713022863027_70353520498380'
lib/redmine/sudo_mode.rb:65:in `sudo_mode'

I have no problem recovering a database in v4.0.5.

I'm running:
- Linux Mint 19.3
- mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine wrapper
- ruby ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
- Rails 5.2.4.2

Many thanks!


Replies (10)

RE: Restoring a backed up database in v4.1.1 results in Error 500 - Added by Mischa The Evil over 4 years ago

What are you doing? Are you restoring a Redmine instance or are you upgrading one?
If you are restoring, then don't simultaneously upgrade it to a newer version. Complete the restore first and then you could start the upgrade procedure. If you are upgrading, then follow all the given steps in RedmineUpgrade.

Though, given the provided information I'd say you miss the 4.1.x DB-migrations. Following step four in the referenced wiki page should solve the error you are having.

RE: Restoring a backed up database in v4.1.1 results in Error 500 - Added by A Fora over 4 years ago

Thanks Mischa I did that of course. Step 4 is required regardless if you are having a fresh install or an upgrade, otherwise mysql database would not be linked to v4.1.1.

In fact I can successfully login to the redmine instance on the new version and can see the project list and the overall issue list. That strange error blocks it from showing individual projects (or issues). Everything else is available to me.

It does not seem right (intuitively to me at least) that you cannot restore a database from a server running an older redmine version directly to a newer brand-new installation on a different machine. I have a complex virtualisation juggle with it, so it's critical for me to have redmine installed on a fresh system and have the db backup restored to it.

The database itself is not ported on a particular redmine/gem version set, so this should not be an issue. Or is it?

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by kumar abhinav over 4 years ago

Hi A Fora,
Running

 bundle exec rake db:migrate RAILS_ENV=production 

should fix your problem.

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by A Fora over 4 years ago

Thanks Kumar, I'm already running it (line 2 below) as a part of my rake protocol:

bundle exec rake generate_secret_token
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
bundle exec rake redmine:load_default_data RAILS_ENV=production REDMINE_LANG=en
bundle exec rake tmp:cache:clear RAILS_ENV=production

As I pointed out - I can login to the database in v4.1.1 and see some of its sections, I suspect the db:migrate command may not be the issue.

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by Kamil AFACAN over 4 years ago

Really I am a new user for Redmine. I had an experience like this I tried to turn back to an old version. Somehow I don't know but db is being affected ffrom the schemas running background. I am using Bitnami Redmine Plus Agile. May help.

https://community.bitnami.com/t/database-transfer-from-another-computer/78269?source_topic_id=80417

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by A Fora over 4 years ago

I can access the new database, the 500 error appears when browsing individual Issues inside it. So this my not relate to the problem you solved.

Also, I do not have any plugins with a direct redmine install (not a bitnami stack like in your case).

Sadly the issue is still unresolved.

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by Mischa The Evil over 4 years ago

In cases like this I can only recommend to either find someone who is sufficiently skilled to manage your Redmine deployment on-premise or decide to outsource both the hosting and management to a hosted Redmine provider.
That being said, I'll try to help you anyway.

A Fora wrote:

The database itself is not ported on a particular redmine/gem version set, so this should not be an issue. Or is it?

Well. You are clearly having an issue with it, don't you? And that's because the Redmine database schema changed between versions 4.0.x and 4.1.x. And since your DB is not properly migrated you are getting the given error.
You can see this for yourself by looking at the schema file in /db/schema.rb. For the trackers table on Redmine 4.1.x for example, it should look like following:

  create_table "trackers", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
    t.string "name", limit: 30, default: "", null: false
    t.string "description" 
    t.boolean "is_in_chlog", default: false, null: false
    t.integer "position" 
    t.boolean "is_in_roadmap", default: true, null: false
    t.integer "fields_bits", default: 0
    t.integer "default_status_id" 
  end

I'm pretty certain you are missing the description field here. Like also stated by kumar abhinav (and Go MAEDA in the issue you opened), you still need to properly migrate you database to the current 4.1.x state.

A Fora wrote:

Thanks Kumar, I'm already running it (line 2 below) as a part of my rake protocol:

There is no such thing as a rake protocol.

A Fora wrote:

bundle exec rake generate_secret_token
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
bundle exec rake redmine:load_default_data RAILS_ENV=production REDMINE_LANG=en
bundle exec rake tmp:cache:clear RAILS_ENV=production

These are the steps for a fresh install of Redmine mixed together with upgrade steps, not the steps for a restoration or an upgrade. Again, don't mix-up these different processes. E.g. you don't want to load the default data into your database if you are restoring or upgrading.

A Fora wrote:

[...] I suspect the db:migrate command may not be the issue.

I'm convinced your suspicion is not right.


What output do you get from the DB-migration command?

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by Kamil AFACAN over 4 years ago

Hi
I think I couldn't express my case, in my case, first the database name was different cominng from using different versions. I solved this issue by the help of PhpMyAdmin page as I explained in the previous post. For the plugins and the 500 error, I found that the backing up method is very important however it is written in the forums and bitnami pages as same.

https://docs.bitnami.com/installer/apps/redmine/administration/backup-restore-mysql-mariadb/

When I use th following command I have the same problem.

mysqldump -A -u root -p > backup.sql

But when I use the following nothing happened and I could start all plugins

mysqldump -u root -p bitnami_app > backup.sql

Wish you luck

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by A Fora over 4 years ago

Mischa The Evil wrote:

Well. You are clearly having an issue with it, don't you? And that's because the Redmine database schema changed between versions 4.0.x and 4.1.x. And since your DB is not properly migrated you are getting the given error.

Thanks Mischa, it makes sense.

Also out of curiosity, does it mean (if there is a need in the future) that downgrading the version will be impossible? Or it will simply result in a loss of some data if the schema was less descriptive in prior versions?

RE: Restoring a db in v4.1.1 gives Error 500, while in v4.0.5 is fine - Added by Mischa The Evil over 4 years ago

A Fora wrote:

Also out of curiosity, does it mean (if there is a need in the future) that downgrading the version will be impossible? Or it will simply result in a loss of some data if the schema was less descriptive in prior versions?

Downgrading (i.e. reversing a schema migration) is possible (albeit not without dropping data, obviously [think about reversing the creation of a new table]) unless one or more migrations are irreversible.
See the Rails guide on Active Record Migrations for more information.

    (1-10/10)