0

I am trying to migrate an oldish installation:

Environment:
  Redmine version                          2.2.3.stable
  Ruby version                             1.9.3 (x86_64-linux)
  Rails version                            3.2.12
  Environment                              production
  Database adapter                         Mysql2
Redmine plugins:
  no plugin installed

to a new machine:

Environment:
  Redmine version                2.6.1.stable
  Ruby version                   1.9.3-p194 (2012-04-20) [x86_64-linux]
  Rails version                  3.2.21
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.6.17
  Mercurial                      2.2.2
  Bazaar                         2.6.0
  Git                            1.7.10.4
  Filesystem                     
Redmine plugins:
  redmine_dmsf                   1.4.9 stable

I did a simple backup on old server:

root@redmine www/redmine# /usr/bin/mysqldump -u root -p"...redmine" redmine_production | gzip > redmine_`date +%y_%m_%d`.gz
root@redmine www/redmine# tar cjf files.tar.bz2 files

and tried to restore it in the new (working, but empty) machine:

root@redmine ~# cd /var/www/redmine/
root@redmine www/redmine# scp mcon@syno0:files.tar.bz2 .
files.tar.bz2                                         100% 4229     4.1KB/s   00:00
root@redmine www/redmine# scp mcon@syno0:redmine_15_02_12.gz .
redmine_15_02_12.gz                                   100%   11KB  11.2KB/s   00:00

*** here Redmine server is STILL working ***

root@redmine www/redmine# service apache2 stop
[ ok ] Stopping web server: apache2 ... waiting .
root@redmine www/redmine# tar xjf files.tar.bz2
root@redmine www/redmine# zcat redmine_15_02_12.gz | mysql --user=root --password=...redmine     redmine_production
root@redmine www/redmine# rake db:migrate
==  Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
   -> 0.0082s
-- create_table("auth_sources", {:force=>true})
   -> 0.0043s
-- create_table("custom_fields", {:force=>true})
   -> 0.0041s
-- create_table("custom_fields_projects", {:id=>false, :force=>true})
   -> 0.0043s
-- create_table("custom_fields_trackers", {:id=>false, :force=>true})
   -> 0.0037s
-- create_table("custom_values", {:force=>true})
   -> 0.0049s
-- create_table("documents", {:force=>true})
   -> 0.0041s
-- add_index("documents", ["project_id"], {:name=>"documents_project_id"})
   -> 0.0127s
-- create_table("enumerations", {:force=>true})
   -> 0.0052s
-- create_table("issue_categories", {:force=>true})
   -> 0.0036s
-- add_index("issue_categories", ["project_id"], {:name=>"issue_categories_project_id"})
   -> 0.0158s
-- create_table("issue_histories", {:force=>true})
   -> 0.0191s
-- add_index("issue_histories", ["issue_id"], {:name=>"issue_histories_issue_id"})
   -> 0.0143s
-- create_table("issue_statuses", {:force=>true})
   -> 0.0046s
-- create_table("issues", {:force=>true})
   -> 0.0045s
-- add_index("issues", ["project_id"], {:name=>"issues_project_id"})
   -> 0.0149s
-- create_table("members", {:force=>true})
   -> 0.0062s
-- create_table("news", {:force=>true})
   -> 0.0052s
-- add_index("news", ["project_id"], {:name=>"news_project_id"})
   -> 0.0139s
-- create_table("permissions", {:force=>true})
   -> 0.0044s
-- create_table("permissions_roles", {:id=>false, :force=>true})
   -> 0.0059s
-- add_index("permissions_roles", ["role_id"], {:name=>"permissions_roles_role_id"})
   -> 0.0168s
-- create_table("projects", {:force=>true})
   -> 0.0582s
-- create_table("roles", {:force=>true})
   -> 0.0045s
-- create_table("tokens", {:force=>true})
   -> 0.0044s
-- create_table("trackers", {:force=>true})
   -> 0.0037s
-- create_table("users", {:force=>true})
   -> 0.0048s
-- create_table("versions", {:force=>true})
   -> 0.0112s
-- add_index("versions", ["project_id"], {:name=>"versions_project_id"})
   -> 0.0428s
-- create_table("workflows", {:force=>true})
   -> 0.0059s
==  Setup: migrated (0.4712s) =================================================

**** MANY LINES, APPARENTLY WITHOUT ERROR ****

==  ChangeChangesetsCommentsLimit: migrating ==================================
-- change_column(:changesets, :comments, :text, {:limit=>16777216})
   -> 0.0081s
==  ChangeChangesetsCommentsLimit: migrated (0.0085s) =========================

==  AddPasswordChangedAtToUser: migrating =====================================
-- add_column(:users, :passwd_changed_on, :datetime)
   -> 0.0104s
==  AddPasswordChangedAtToUser: migrated (0.0108s) ============================

==  InsertBuiltinGroups: migrating ============================================
==  InsertBuiltinGroups: migrated (0.1441s) ===================================

root@redmine www/redmine# service apache2 start
[ ok ] Starting web server: apache2.
root@redmine www/redmine#

After this Redmine is no longer working. Attempts to connect results in:

Internal error

An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

Back

And I get the following log:

...
Connecting to database specified by database.yml
Creating scope :system. Overwriting existing method Enumeration.system.
Creating scope :sorted. Overwriting existing method User.sorted.
Creating scope :sorted. Overwriting existing method Group.sorted.
Started GET "/" for 192.168.7.114 at 2015-02-12 14:41:57 +0000
Processing by WelcomeController#index as HTML
  Current user: admin (id=1)
Completed 500 Internal Server Error in 75.0ms

NoMethodError (undefined method `passwd_changed_on' for #<User:0x00000006696f80>):
  app/controllers/application_controller.rb:150:in `force_logout_if_password_changed'

What am I doing wrong?

ZioByte
  • 246
  • 3
  • 15

1 Answers1

1

SHAME ON ME:

It turns out I wrongly expect rake db:migrate to act on production ENV, which is not the case.

Correct command is: rake db:migrate RAILS_ENV="production".

This is what happens when you blindingly copy&paste.

Sorry for the noise (moderator can just delete this Q&A, if they think it might be useful).

For the record: You also need to drop ALL tables in redmine_production before doing the restore, otherwise rake ... command will fail with error:

Mysql2::Error: Table 'queries_roles' already exists: CREATE TABLE `queries_roles` (`query_id` int(11) NOT NULL, `role_id` int(11) NOT NULL) ENGINE=InnoDB/var/lib/gems/1.9.1/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'
ZioByte
  • 246
  • 3
  • 15