A tool to synchronize tickets, wikis and related data from a Trac instance (via XML-RPC) into a GitLab project.
User documentation lives in docs/: getting started, configuration, CLI reference, migration flow, and limitations.
- Export tickets from Trac as JSON files (including content history and comments)
- Export content of wiki pages from Trac as markdown files (including history)
- Export metadata of wiki pages from Trac as JSON files (including history)
- Export milestones as JSON files
- Concurrent export operations for faster migration (speed might be limited by Trac XML-RPC)
- Download attachments
- Configurable via YAML
- Import milestones into GitLab projects (updates if already exist and content differs)
- Import issues into GitLab projects (updates if already exist and content differs)
- Import ticket comments with original timestamps; note authors are recorded for the author patch pass
- Upload ticket attachments and link them from issue descriptions
- Import wiki pages and attachments (latest version; original author/date recorded in a footer)
- Rewrite ticket IDs and changeset references using explicit mapping files
- Map Trac fields to GitLab labels (
trac:type:defect,trac:priority:major, ...) - Validate the target against the export (counts, timestamps, authors, attachments, wiki)
- Run a read-only preflight (Trac/GitLab reachability, role, target state, identities)
- Summarise the export and propose author mappings (
discover) - Show migration status (
status,--json)
- Preserve ticket history in GitLab issues (not supported by the GitLab API)
- Import Trac description history as notes
- Preserve wiki page history in GitLab wikis (not supported by the GitLab API)
This package is compatible with:
- TracXMLRPC version: 1.1.9
- Trac core version: 1.2.3
Tested against the plugin installed from: https://trac-hacks.org/wiki/XmlRpcPlugin
If you're using another version, some methods may not be available or may behave differently.
- Go 1.24 or later
- Access to a Trac instance with XML-RPC enabled
- GitLab project with API access token
- Clone the repository
- Run
make installto install dependencies - Create a project directory:
trac2gitlab init --project-dir projects/my-project
- Edit
projects/my-project/migration.yamland createprojects/my-project/.env(see.env.example). Credentials are read from the environment or.env, never frommigration.yaml:GITLAB_URL=https://gitlab.example.com GITLAB_TOKEN=... GITLAB_PROJECT=group/project TRAC_URL=https://trac.example.com TRAC_USER=... TRAC_PASSWORD=... - Run commands against the project:
trac2gitlab export --project-dir projects/my-project trac2gitlab migrate --project-dir projects/my-project # dry-run trac2gitlab migrate --project-dir projects/my-project --execute # write
Trac Exporter:
trac2gitlab export --project-dir projects/my-projectGitLab Importer:
trac2gitlab migrate --project-dir projects/my-project --executemigrate defaults to --dry-run; per-phase progress is written to
projects/<name>/state/migration.yaml.
Ticket and changeset references are rewritten during import using explicit maps:
references:
enabled: true
tickets_file: mappings/trac-tickets.json
changesets_file: mappings/hg-changesets.json
wiki_file: mappings/wiki-pages.jsontrac-tickets.json:{"tickets": {"1": 3}}(Trac ID → GitLab IID)hg-changesets.json:{"changesets": {"<hg-node>": "<git-sha>"}}wiki-pages.json:{"pages": {"Trac Page": "gitlab-slug"}}(optional overrides)
Wiki links (wiki:Page, [wiki:Page], [Label](Page.md)) are rewritten using
the exported page names plus optional overrides. Missing pages are left alone.
Missing files are allowed: ticket references stay unchanged, and changeset references are left as-is. Fenced code blocks are not rewritten.
Trac fields become GitLab labels:
labels:
enabled: true
prefix: trac
create_missing: true
fields: [type, priority, resolution, component, version, severity, status]For example type=defect becomes trac:type:defect. Existing labels are not
removed; missing labels are added on rerun.
trac2gitlab validate --project-dir projects/my-projectWrites projects/<name>/reports/validation.md and exits non-zero on FAIL.
Checks issue presence, created/closed timestamps, issue and note authors,
labels, note timestamps, attachment links, and wiki pages.
The importer creates issues/notes with the admin token, because GitLab only lets admins/owners set historical timestamps and IIDs. To restore the original authors, emit the patch block and run it on the GitLab host:
# dry run: prints what would change
trac2gitlab patch
# after reviewing the dry run, emit an applying block
trac2gitlab patch --applyPaste the emitted block into the GitLab host shell. It writes a temporary Ruby
file inside the container, runs gitlab-rails runner, and deletes the file.
Use --container <name> if the container is not called gitlab, or
--omnibus for a host install. The block updates issues.author_id and
notes.author_id only; unmapped authors are reported and skipped.
Check the Makefile for more commands and options.