ok here the method:
step 1. convert trac db to csv files
- install sqlite3 (apt-get install sqlite3)
- create and cd into an empty working directory
- create a trac2cvs.sql file and put this in it:
Code: Select all
-- All Trac tickets to convert.
.mode csv
.output tickets.csv
select id, type, owner, reporter, milestone, status, resolution, summary,
description, time / 1000000 as time, changetime / 1000000 as changetime, component, priority, keywords, cc
from ticket order by id;
.output comments.csv
select ticket, time / 1000000 as time, author, newvalue
from ticket_change where field = 'comment' and newvalue <> '' order by ticket, time;
.output attachments.csv
select id, filename, time / 1000000 as time, author from attachment order by id asc;
- execute the script:
Code: Select all
sqlite3 /path/to/trac.db <trac2cvs.sql
this will generate 3 files in the current directory: tickets.csv comments.csv attachments.csv
step 2. install tratihubis and prepare the github project
(assume you're still in the working directory from step 1).
- install python (2.7.x) if not already installed
- install PyGithub with "sudo pip install PyGithub"
- create a test project on github (imported issues & milestones cannot be deleted so better test 1st)
- get a token on github (doc:
https://help.github.com/articles/creati ... -line-use/ , full control repo rights are enough)
- create a tratihubis.cfg file and put this in it:
Code: Select all
[tratihubis]
token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
user = kgersen
repo = AllegianceTest
tickets = ../tickets.csv
comments =../comments.csv
labels = type=defect: bug, type=enhancement: enhancement, resolution=wontfix: wontfix, type=task: question, resolution=duplicate: duplicate, resolution=invalid: invalid
convert_text = true
trac_url = https://trac.alleg.net/
change token, user and repo to yours.
- get my modified tratihubis:
Code: Select all
git clone https://github.com/kgersen/tratihubis.git
step 3. test then export for real
test the import script (this will pretend to do the export ):
Code: Select all
cd tratihubis
python tratihubis.py ../tratihubis.cfg
check for errors , should end with something like this "Finished pretend creating 357 issues from 357 tickets"
if you want to map users and export attachments, read the tratihubis.py file for informations.
to launch the export for real:
Code: Select all
python tratihubis.py --really --skipExisting ../tratihubis.cfg
this might take quite some time and might stop because of github rate limiting. In that case just wait for your reset (see
https://developer.github.com/v3/#rate-limiting ) then restart the command. But the best way is to contact github support and ask them to whitelist you.
Once finished (or while the export is ongoing) you can check the issues on github web site. If all ok. then edit tratihubis.cfg and set repo to the real final repo and do step 3 again.