Update Migration trac redmine

Anthony Callegaro 2024-06-18 12:47:34 +00:00
parent 149bc3962e
commit 9781e81c44

@ -1,255 +1,254 @@
How to migrate from trac to redmine How to migrate from trac to redmine
=================================== ===================================
This tutorial describes how to migrate from trac to redmine. Originally This tutorial describes how to migrate from trac to redmine. Originally
written to perform an upgrade from trac 0.10.3 (old etch server) to written to perform an upgrade from trac 0.10.3 (old etch server) to
Redmine 1.0.1 (squeeze) but was successfully tested with trac 0.11 and Redmine 1.0.1 (squeeze) but was successfully tested with trac 0.11 and
0.12, as well as Redmine 1.0.5 and 1.1.2 (1.2 is also working. This 0.12, as well as Redmine 1.0.5 and 1.1.2 (1.2 is also working. This
version was also tested to produce the upstream patch but not version was also tested to produce the upstream patch but not
intensively). intensively).
**Do not forget to disable trac to prevent users from using it during **Do not forget to disable trac to prevent users from using it during
the migration.** the migration.**
1. Backup Trac data 1. Backup Trac data
------------------- -------------------
ssh oldtracserver ssh oldtracserver
cd /var/lib/ cd /var/lib/
tar -czf trac.tar.gz trac tar -czf trac.tar.gz trac
scp /var/lib/trac.tar.gz newredmineserver:/tmp/ scp /var/lib/trac.tar.gz newredmineserver:/tmp/
2. Install redmine on the new server 2. Install redmine on the new server
------------------------------------ ------------------------------------
Pretty straightforward even if running the standalone server requires Pretty straightforward even if running the standalone server requires
some tricks : some tricks :
aptitude install redmine aptitude install redmine
cd /usr/share/redmine/ cd /usr/share/redmine/
mkdir tmp mkdir tmp
chown -R www-data:www-data tmp/ chown -R www-data:www-data tmp/
mkdir log mkdir log
touch log/production.log touch log/production.log
chown -R www-data:www-data log/ chown -R www-data:www-data log/
# Running the standalone server # Running the standalone server
sudo -u www-data X_DEBIAN_SITEID="default" ruby script/server webrick -e production -b newredmineserverip sudo -u www-data X_DEBIAN_SITEID="default" ruby script/server webrick -e production -b newredmineserverip
Now you now can go to http://newredmineserver:3000 to be greeted by the Now you now can go to http://newredmineserver:3000 to be greeted by the
default redmine page. default redmine page.
3. Install a development environment 3. Install a development environment
------------------------------------ ------------------------------------
People might argue that this is optional but it is a very important ste People might argue that this is optional but it is a very important ste
You are likely to do a lot of mistakes with a new unfamiliar tool so you You are likely to do a lot of mistakes with a new unfamiliar tool so you
will be glad that you tried it on dev beforehand. The production will be glad that you tried it on dev beforehand. The production
database will be kept clean of all trial and errors which might save you database will be kept clean of all trial and errors which might save you
from redoing a lengthy migration. from redoing a lengthy migration.
vi /etc/redmine/default/database.yml vi /etc/redmine/default/database.yml
-> development: -> development:
adapter: sqlite3 adapter: sqlite3
database: /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default-dev database: /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default-dev
encoding: utf8 encoding: utf8
cd /usr/share/redmine cd /usr/share/redmine
rake db:migrate RAILS_ENV="development" rake db:migrate RAILS_ENV="development"
rake redmine:load_default_data RAILS_ENV="development" rake redmine:load_default_data RAILS_ENV="development"
touch log/development.log touch log/development.log
chown -R www-data:www-data log/ chown -R www-data:www-data log/
chown www-data:www-data /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default-dev chown www-data:www-data /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default-dev
sudo -u www-data X_DEBIAN_SITEID="default" ruby script/server webrick -e development -b newredmineserverip -p 3001 sudo -u www-data X_DEBIAN_SITEID="default" ruby script/server webrick -e development -b newredmineserverip -p 3001
4. Cleanup Redmine test environment 4. Cleanup Redmine test environment
----------------------------------- -----------------------------------
If you still managed to mess up your database during your migration, If you still managed to mess up your database during your migration,
here is how to recover a clean redmine environment : here is how to recover a clean redmine environment :
rm /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default* rm /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default*
rm /var/lib/redmine/default/files/* rm /var/lib/redmine/default/files/*
cd /usr/share/redmine cd /usr/share/redmine
rake db:migrate RAILS_ENV="production" rake db:migrate RAILS_ENV="production"
rake db:migrate RAILS_ENV="development" rake db:migrate RAILS_ENV="development"
rake redmine:load_default_data RAILS_ENV="development" rake redmine:load_default_data RAILS_ENV="development"
rake redmine:load_default_data RAILS_ENV="production" rake redmine:load_default_data RAILS_ENV="production"
chown www-data:www-data /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default* chown www-data:www-data /var/lib/dbconfig-common/sqlite3/redmine/instances/default/redmine_default*
5. Migrate trac DB to Redmines 5. Migrate trac DB to Redmines
------------------------------- -------------------------------
The script used for the migration has been heavily customised to import The script used for the migration has been heavily customised to import
more data from trac than the default script shipped with redmine. I more data from trac than the default script shipped with redmine. I
based my work on the [Trac Importer Patch based my work on the [Trac Importer Patch
Coordination](http://www.redmine.org/boards/1/topics/12273) effort from Coordination](http://www.redmine.org/boards/1/topics/12273) effort from
Redmines forum. More specifically on the most advanced version of the Redmines forum. More specifically on the most advanced version of the
script that can be found script that can be found
[here](https://github.com/landy2005/Redmine-migrate-from-Trac/raw/master/migrate_from_trac.rake). [here](https://github.com/landy2005/Redmine-migrate-from-Trac/raw/master/migrate_from_trac.rake).
My modifications add the following enhancements : My modifications add the following enhancements :
- Handle many more ticket property changes : - Handle many more ticket property changes :
- change of ownership (re-assignement) - change of ownership (re-assignement)
- change of components (category) - change of components (category)
- change of priority - change of priority
- change in the summary (one line description) - change in the summary (one line description)
- change of issue type (bug, feature…) - change of issue type (bug, feature…)
- change of completion ratio - change of completion ratio
- Populate the completion ratio. This is done through a mapping hash - Populate the completion ratio. This is done through a mapping hash
that maps it to tracs resolution. By default : that maps it to tracs resolution. By default :
RATIO_MAPPING = {'' => 0, RATIO_MAPPING = {'' => 0,
'fixed' => 100, 'fixed' => 100,
'invalid' => 0, 'invalid' => 0,
'wontfix' => 0, 'wontfix' => 0,
'duplicate' => 100, 'duplicate' => 100,
'worksforme' => 0} 'worksforme' => 0}
- Handle CCs field by adding watchers accordingly - Handle CCs field by adding watchers accordingly
- Add start date (firsts comment date) and the due date (when - Add start date (firsts comment date) and the due date (when
done\_ratio is 100%) to populate the calendar and gantts charts done\_ratio is 100%) to populate the calendar and gantts charts
- Add timelog entries to handle migration from timeandestimation - Add timelog entries to handle migration from timeandestimation
plugin (hours spent, total hours), estimated hours already exists in plugin (hours spent, total hours), estimated hours already exists in
redmine. Timelog comments links to the correct note in the ticket. redmine. Timelog comments links to the correct note in the ticket.
- Add a new task tracker with a correct workflow and map it to tracs - Add a new task tracker with a correct workflow and map it to tracs
tasks. tasks.
- Enable all redmine modules by default (yes it is pure lazyness :o) ) - Enable all redmine modules by default (yes it is pure lazyness :o) )
It also fixes some bugs in the current script : It also fixes some bugs in the current script :
- Add a tickets author to the list of project reporter - Add a tickets author to the list of project reporter
- Put correct updated time on ticket - Put correct updated time on ticket
- Plenty of small issues - Plenty of small issues
And some ugly hack that might be removed : And some ugly hack that might be removed :
- Add an ugly hack to set the billable custom field type to a - Add an ugly hack to set the billable custom field type to a
checkbox. A proper fix would require to parse the trac.ini which checkbox. A proper fix would require to parse the trac.ini which
would be a bigger implementation. would be a bigger implementation.
I [sent it I [sent it
upstream](http://www.redmine.org/boards/1/topics/12273?r=24039#message-24039) upstream](http://www.redmine.org/boards/1/topics/12273?r=24039#message-24039)
hoping they will put it in a future version of redmine. Else you can hoping they will put it in a future version of redmine. Else you can
download it from here : attachment:migrate\_from\_trac.rake. The download it from here : ![migrate_from_trac.rake](../raw/migrate_from_trac.rake). The
corresponding patch for Redmines trunk revision 5857 is here : corresponding patch for Redmines trunk revision 5857 is here : ![migrate_from_trac.rake_r5857.patch](../raw/migrate_from_trac.rake_r5857.patch).
attachment:/migrate\_from\_trac.rake\_r5857.patch.
Once you have the new script, run :
Once you have the new script, run :
rake redmine:migrate_from_trac RAILS_ENV="production"
rake redmine:migrate_from_trac RAILS_ENV="production" -> WARNING: a new project will be added to Redmine during this process.
-> WARNING: a new project will be added to Redmine during this process. Are you sure you want to continue ? [y/N] y
Are you sure you want to continue ? [y/N] y
Trac directory []: /tmp/trac/mytracproject
Trac directory []: /tmp/trac/mytracproject Trac database adapter (sqlite, sqlite3, mysql, postgresql) [sqlite3]:
Trac database adapter (sqlite, sqlite3, mysql, postgresql) [sqlite3]: Trac database encoding [UTF-8]:
Trac database encoding [UTF-8]: Target project identifier []: myredmineproject
Target project identifier []: myredmineproject # Repeat for all projects
# Repeat for all projects rake redmine:migrate_from_trac RAILS_ENV="development"
rake redmine:migrate_from_trac RAILS_ENV="development" # Repeat for dev environment
# Repeat for dev environment
As said above each my script will add a link in each timelog comments
As said above each my script will add a link in each timelog comments pointing to the correct note in the issue. Unfortunately timelog entries
pointing to the correct note in the issue. Unfortunately timelog entries are not textiled and so are displayed as raw text. If you want to change
are not textiled and so are displayed as raw text. If you want to change this behaviour you will have to apply the patch from [this
this behaviour you will have to apply the patch from [this issue](http://www.redmine.org/issues/202) to your Redmine :
issue](http://www.redmine.org/issues/202) to your Redmine :
cd /usr/share/redmine
cd /usr/share/redmine wget "http://www.redmine.org/attachments/download/2807/textilize-timelog-entry-comment_r3084.patch"
wget "http://www.redmine.org/attachments/download/2807/textilize-timelog-entry-comment_r3084.patch" patch -p0 < textilize-timelog-entry-comment_r3084.patch
patch -p0 < textilize-timelog-entry-comment_r3084.patch
6. SVN migration
6. SVN migration ----------------
----------------
If you are migrating SVN to a new server as well, here is a small
If you are migrating SVN to a new server as well, here is a small procedure. Nothing exciting you will find the same all over the web,
procedure. Nothing exciting you will find the same all over the web, this is just for reference :
this is just for reference :
### 6.1. Backup SVN on the old host
### 6.1. Backup SVN on the old host
ssh oldsvnserver
ssh oldsvnserver cd /var/lib/svn/repository
cd /var/lib/svn/repository for project in *; do svnadmin dump ${project} | gzip > ${project}.gz ; done
for project in *; do svnadmin dump ${project} | gzip > ${project}.gz ; done scp *.gz newsvnserver:/tmp/
scp *.gz newsvnserver:/tmp/
### 6.2. Import on the new host
### 6.2. Import on the new host
svnadmin create project1
svnadmin create project1 zcat project1.gz | svnadmin load project1
zcat project1.gz | svnadmin load project1
7. Link Redmine to SVN
7. Link Redmine to SVN ----------------------
----------------------
If you used trac tickets links in your commit message with “See \#” and
If you used trac tickets links in your commit message with “See \#” and “Fix \#” heavily like us then dont forget to add the following :
“Fix \#” heavily like us then dont forget to add the following : In redmine, go to Administration ->Settings ->Repository (i.e.
In redmine, go to Administration ->Settings ->Repository (i.e. http://newredmineserver:3000/settings?tab=repositories) to include
http://newredmineserver:3000/settings?tab=repositories) to include see/fix :
see/fix :
![](../raw/AdminSettingsRepository.png)
![](AdminSettingsRepository.png)
### 7.1. Add pre-revprop-change hooks to allow revision modifications
### 7.1. Add pre-revprop-change hooks to allow revision modifications
cd /var/lib/svn/
cd /var/lib/svn/ vi pre-revprop-change
vi pre-revprop-change -> #!/bin/sh
-> #!/bin/sh exit 0
exit 0 ln -s /var/lib/svn/pre-revprop-change project1/hooks/
ln -s /var/lib/svn/pre-revprop-change project1/hooks/ ln -s /var/lib/svn/pre-revprop-change project2/hooks/
ln -s /var/lib/svn/pre-revprop-change project2/hooks/ ...
... ln -s /var/lib/svn/pre-revprop-change projectn/hooks/
ln -s /var/lib/svn/pre-revprop-change projectn/hooks/
### 7.2. Modify SVN commits logs
### 7.2. Modify SVN commits logs
rake redmine:migrate_from_trac_svn RAILS_ENV="production"
rake redmine:migrate_from_trac_svn RAILS_ENV="production" -> WARNING: all commit messages with references to trac pages will be modified
-> WARNING: all commit messages with references to trac pages will be modified Are you sure you want to continue ? [y/N] y
Are you sure you want to continue ? [y/N] y
Subversion repository url []: file:///var/lib/svn/project1
Subversion repository url []: file:///var/lib/svn/project1 Subversion repository username []:
Subversion repository username []: Subversion repository password []:
Subversion repository password []: Redmine project identifier []: myredmineproject
Redmine project identifier []: myredmineproject # Repeat for all projects
# Repeat for all projects rm */hooks/pre-revprop-change
rm */hooks/pre-revprop-change
### 7.3. Setup all repositories in redmine
### 7.3. Setup all repositories in redmine
In redmine, go to : your project ->Settings ->Repository (i.e.
In redmine, go to : your project ->Settings ->Repository (i.e. http://newredmineserver:3000/project1/settings/repository) :
http://newredmineserver:3000/project1/settings/repository) :
![](../raw/RepositorySettings.png)
![](RepositorySettings.png)
### 7.4. Sync redmine DB from SVN
### 7.4. Sync redmine DB from SVN
You have to generate a key first by going back in Administration -&gt;
You have to generate a key first by going back in Administration -&gt; Settings ->Repository (i.e.
Settings ->Repository (i.e. http://newredmineserver:3000/settings?tab=repositories) :
http://newredmineserver:3000/settings?tab=repositories) :
![](../raw/GenerateKey.png)
![](GenerateKey.png)
Then to import all projects repository at once run :
Then to import all projects repository at once run :
wget "http://newredmineserver:3000/sys/fetch_changesets?key=8qKxftrhICYt8bPEShVa"
wget "http://newredmineserver:3000/sys/fetch_changesets?key=8qKxftrhICYt8bPEShVa"
8. Upgrade to Redmine 1.0.5
8. Upgrade to Redmine 1.0.5 ---------------------------
---------------------------
Squeeze version of redmine is vulnerable to
Squeeze version of redmine is vulnerable to [this](http://security-tracker.debian.org/tracker/TEMP-0608397-D41D8C)
[this](http://security-tracker.debian.org/tracker/TEMP-0608397-D41D8C) security advisory (at the time of writing 21/04/2011) which is corrected
security advisory (at the time of writing 21/04/2011) which is corrected in 1.0.5.
in 1.0.5.
aptitude -t squeeze-backports install redmine redmine-sqlite
aptitude -t squeeze-backports install redmine redmine-sqlite
Thats it ! Your trac projects should now be migrated completely to
Thats it ! Your trac projects should now be migrated completely to redmine. The only remaining issues we encountered where from bogus data
redmine. The only remaining issues we encountered where from bogus data in Trac, or badly formatted HTML in wiki pages that needed to be
in Trac, or badly formatted HTML in wiki pages that needed to be modified manually. Despite these few exceptions the script will do
modified manually. Despite these few exceptions the script will do pretty much all the work for you.
pretty much all the work for you.
See also
See also --------
--------
- [Redmine configuration tips](Redmine-configuration)
- [Redmine configuration tips](Redmine-configuration) - [A secure SVN+SSH setup with
- [A secure SVN+SSH setup with path-based authorisation](SVN+SSH-path-based-authorisation)
path-based authorisation](SVN+SSH-path-based-authorisation)