= Importing ticket data

[[PageOutline(2-5,Contents,pullout)]]

To migrate issue tickets from other issue-tracking systems into Trac or perform housekeeping actions on tickets or simply synchronize different databases, there are some tools, plugins and scripts available.

== !TicketImportPlugin

[https://trac-hacks.org/wiki/TicketImportPlugin TicketImportPlugin]: a plugin that allows you to import or update a series of tickets from a '''CSV file''' or (if the [https://pypi.python.org/pypi/xlrd xlrd library] is installed) from an '''Excel spreadsheet''' into Trac.

== !ExportImportXlsPlugin

[https://trac-hacks.org/wiki/ExportImportXlsPlugin ExportImportXlsPlugin]: a plugin that allows you to export and import tickets from a '''XLS file'''. Requires the Python packages xlwt/rxld.

== Bugzilla

[https://trac-hacks.org/wiki/BugzillaIssueTrackingPlugin BugzillaIssueTrackingPlugin]: a plugin that integrates Bugzilla issue data into Trac keeping TracLinks. Ticket data can be imported from Bugzilla using the [trac:browser:branches/1.4-stable/contrib/bugzilla2trac.py bugzilla2trac.py] script, available in the `contrib/` directory of the Trac distribution.

{{{#!python
$ bugzilla2trac.py
bugzilla2trac - Imports a bug database from Bugzilla into Trac.

Usage: bugzilla2trac.py [options]

Available Options:
  --db <MySQL dbname>              - Bugzilla's database
  --tracenv /path/to/trac/env      - full path to Trac db environment
  -h | --host <MySQL hostname>     - Bugzilla's DNS host name
  -u | --user <MySQL username>     - effective Bugzilla's database user
  -p | --passwd <MySQL password>   - Bugzilla's user password
  -c | --clean                     - remove current Trac tickets before importing
  --help | help                    - this help info

Additional configuration options can be defined directly in the script.
}}}

Currently, the following data is imported from Bugzilla:
 * bugs
 * bug activity (field changes)
 * bug attachments
 * user names and passwords (put into an htpasswd file)

The script provides a number of features to ease the conversion, such as:
 * PRODUCT_KEYWORDS: Trac has no concept of products, so the script provides the ability to attach a ticket keyword instead.
 * IGNORE_COMMENTS: Don't import Bugzilla comments that match a certain regexp.
 * STATUS_KEYWORDS: Attach ticket keywords for the Bugzilla statuses not available in Trac. By default, the `VERIFIED` and `RELEASED` Bugzilla statuses are translated into Trac keywords.

For more details on the available options, see the configuration section at the top of the script.

== Jira

[https://trac-hacks.org/wiki/JiraToTracIntegration JiraToTracIntegration]: a plugin that allows you to import Atlassian Jira backup files into Trac. The plugin consists of a Python 3.1 commandline tool that:
 - Parses the Jira backup XML file.
 - Sends the imported Jira data and attachments to Trac using the [https://trac-hacks.org/wiki/XmlRpcPlugin XmlRpcPlugin].
 - Generates a htpasswd file containing the imported Jira users and their SHA-512 base64 encoded passwords.

== Mantis

[https://trac-hacks.org/wiki/MantisImportScript MantisImportScript]: a script to import the following type of data from Mantis into Trac:
 * bugs
 * bug comments
 * bug activity (field changes)
 * attachments (as long as the files live in the mantis database, not on the filesystem).

== !PlanetForge

[https://trac-hacks.org/wiki/PlanetForgeImportExportPlugin PlanetForgeImportExportPlugin]: this plugin exports Trac data (wiki, tickets, components, permissions, repositories, etc.) using the open format designed by the [https://gforge.inria.fr/projects/coclico/ COCLICO] project. It extends the webadmin panel and the 'trac admin ...' command. Has no 'import' feature.

== Scarab

[https://trac-hacks.org/wiki/ScarabToTracScript ScarabToTracScript]: a script that migrates Scarab issues to Trac tickets. Requires [https://trac-hacks.org/wiki/XmlRpcPlugin XmlRpcPlugin].

== Sourceforge

[https://trac-hacks.org/wiki/SfnToTracScript SfnToTracScript]: importer of !SourceForge's new backup file (originated from #Trac3521).
Also, ticket data can be imported from Sourceforge using the [trac:browser:branches/1.4-stable/contrib/sourceforge2trac.py sourceforge2trac.py] script, available in the contrib/ directory of the Trac distribution.

== Other

Since Trac uses a SQL database to store the data, you can also import ticket data from other systems by creating a mapping between the relevant database tables. Just go into [https://www.sqlite.org/sqlite.html sqlite] command line to look at the tables, create the column-to-column mapping as an SQL script and import them from your application.

=== Comma delimited file - CSV

See [trac:attachment:csv2trac.2.py:wiki:TracSynchronize csv2trac.2.py] for details. This approach is particularly useful if you need to enter a large number of tickets by hand. Note that the ticket type field, (task etc.) is also needed for this script to work with more recent Trac releases.

Comments on script: The script has an error on line 168: 'Ticket' needs to be 'ticket'. Also, the listed values for severity and priority are swapped.

----
See also:
 * to import/export wiki pages: TracAdmin,
 * to export tickets: TracTickets, TracQuery
