X

將 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: 對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
Related Post