將 Trac 資料轉換到 Redmine

要將 Trac 的資料要搬移到 Redmine, 要如何做?

從 Trac 轉換到 Redmine 步驟

環境: Debian、Ubuntu Linux

下述步驟參考自: Redmine - RedmineMigrate - Migrating from other systems

  1. scp /var/lib/trac/trac_project_name redmine.example.com:/tmp/trac_project_name # 把 trac 整個目錄的資料, 全部 scp 到 redmine 的機器上.
  2. cd /usr/share/redmine
  3. sudo rake redmine:migrate_from_trac RAILS_ENV="production" # 執行資料轉換, 不用擔心會影響到現在 redmine 的專案, DB 等等, 在建立時, 是會拆開的, 就算重跑也沒關係.

    WARNING: a new project will be added to Redmine during this process.
    Are you sure you want to continue ? [y/N] y

    Trac directory []: /tmp/trac_project_name
    Trac database adapter (sqlite, sqlite3, mysql, postgresql) [sqlite]: sqlite3 # 0.11 以上都是 sqlite3
    Trac database encoding [UTF-8]:
    Target project identifier []: trac_project_name # trac 專案名稱, 也是 redmine 的專案名稱

    This project already exists in your Redmine database. # 若有重複跑, 會問是否要蓋掉 DB
    Are you sure you want to append data to this project ? [Y/n]

    Migrating components..
    Migrating milestones....
    Migrating custom fields

    Migrating tickets...... # 有多少 ".", 就有多少 Tickets
    Migrating wiki.. # 有多少 ".", 就有多少 Wiki

    Components:      0/2
    Milestones:      0/4
    Tickets:         170/170
    Ticket files:    2/2
    Custom values:   0/0
    Wiki edits:      600/619
    Wiki files:      6/16

  4. 到此就已經由 Trac 搬移到 Redmine 完成, 再進入 Redmine 把權限, 人員的關係設定起來即可.

問題

  • Wiki 有些語法不同, 所以字得大小、List 的排版會有點不同, 不過大致上都正常, 都還在可以接受的範圍
  • Milestone 無法對起來, 進度都是空的.

錯誤排除

若上述轉換時, 有下述錯誤的狀況, 可以依照此步驟來解決.

問題
  1. cd /usr/share/redmine
  2. sudo rake redmine:migrate_from_trac RAILS_ENV="production" --trace

    (in /usr/share/redmine)
    rake aborted!
    undefined method `find_each' for #<Class:0x7fecebccc718>
    /usr/share/redmine/vendor/rails/activerecord/lib/active_record/base.rb:1835:in
    `method_missing'
    /usr/share/redmine/lib/tasks/migrate_from_trac.rake:461:in `migrate'
    /usr/share/redmine/lib/tasks/migrate_from_trac.rake:764
    /usr/lib/ruby/1.8/rake.rb:636:in `call'

  3. 此問題可見 Bug: Redmine - Defect #5087: migrate_from_trac not work on Redmine 0.9.1
解法
  1. sudo vim /usr/share/redmine/lib/tasks/migrate_from_trac.rake

    將 461 行
    TracTicket.find_each(:batch_size => 200) do |ticket|
    改成
    TracTicket.find(:all).each do |ticket|

  2. 再重新跑即可.

相關文章

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

在〈將 Trac 資料轉換到 Redmine〉中有 8 則留言

  1. 您好,我在做trac的数据导入redmine的时候一直报错这个,麻烦您能帮我解答么,谢谢

    E:\Bitnami\redmine-2.6.9-4\apps\redmine\htdocs>bundle exec rake redmine:migrate_from_trac RAILS_ENV="production"
    DL is deprecated, please use Fiddle

    WARNING: a new project will be added to Redmine during this process.
    Are you sure you want to continue ? [y/N] y

    Trac directory []: E:\TRAC\TracSanguo
    Trac database adapter (sqlite3, mysql2, postgresql) [sqlite3]:
    Trac database encoding [UTF-8]:
    Target project identifier []: wslw

    This project already exists in your Redmine database.
    Are you sure you want to append data to this project ? [Y/n] y

    rake aborted!
    LoadError: Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:29:in `spec'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:713:in `block in establish_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:710:in `each'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:710:in `establish_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:375:in `migrate'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:776:in `block (2 levels) in '
    Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile.
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `block in require'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:236:in `load_dependency'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:251:in `require'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:29:in `spec'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/vendor/bundle/ruby/2.1.0/gems/activerecord-3.2.22/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:713:in `block in establish_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:710:in `each'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:710:in `establish_connection'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:375:in `migrate'
    E:/Bitnami/redmine-2.6.9-4/apps/redmine/htdocs/lib/tasks/migrate_from_trac.rake:776:in `block (2 levels) in '
    Tasks: TOP => redmine:migrate_from_trac
    (See full trace by running task with --trace)

    1. 已经处理好了,首先要下载sqlite3-1.3.11-x86-mingw32.gem,拷贝到目录apps\redmine\htdocs\vendor\cache下,然后打开文件apps\redmine\htdocs、Gemfile文件,添加一行gem "sqlite3", "1.3.11",打开Bitnami Redmine Stack Environment控制台,输入bundle install --no-deployment --local即可,或者输入bundle install --no-deployment,需要连接网络下载sqlite3-1.3.11-x86-mingw32.gem文件

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料