我正在尝试迁移旧的安装:
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
到新机器:
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
我在旧服务器上做了一个简单的备份:
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
并试图在新的(工作的,但空的)机器中恢复它:
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#
在此之后 Redmine 不再工作。尝试连接会导致:
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
我得到以下日志:
...
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'
我究竟做错了什么?
对我感到羞耻:
事实证明,我错误地期望
rake db:migrate
对 采取行动production
ENV
,但事实并非如此。正确的命令是:
rake db:migrate RAILS_ENV="production"
.当您盲目地复制和粘贴时,就会发生这种情况。
抱歉打扰了(版主可以删除此问答,如果他们认为它可能有用)。
作为记录:您还需要在进行还原之前删除 redmine_production 中的所有表,否则
rake ...
命令将失败并出现错误: