How To Export Redmine Issues Using SQL
Added by Roger Keays over 10 years ago
Hi guys,
Recently I had to export an old set of redmine issues from the database using SQL and figured I might as well share the query I ended up with. It uses some postgres-specific functions but you might be able to find replacements if you need to. It also puts in code-folding markers so you can browse the exported issues in an editor that supports code folding like VIM.
$ psql -A -F '' -c "
select '{{{ ' || project_id || '/' || id || ' ' || subject || E'\n\n',
replace(regexp_replace(description, '\s+$', ''), '}}}', '} } }') || E'\n',
(select array_to_string(array_agg('Comment posted on ' || created_on || E'\n\n' ||
replace(regexp_replace(notes, '\s+$', ''), '}}}', '} } }')), E'\n\n') from
(select * from journals where notes <> '' and journalized_type='Issue' and
journalized_id=issues.id order by created_on) as ordered_comments), E'\n}}}'
from issues order by project_id desc, created_on desc" -Upostgres -hlocalhost redmine > issues.txt
$ vim issues.txt
:set foldmethod=marker
I posted this to my blog also, which is where you'll find me if you want to give some feedback: http://www.ninthavenue.com.au/how-to-export-redmine-issues-using-sql
Hope this helps someone.