We were running JIRA as a ticket system for tech support and as a knowledge base. While this works, it’s not ideal, so we’ve decided to switch to osTicket. Of course, we wanted to migrate all issues, comments, attachments and issue links. JIRA has a good REST API, and osTicket has a rather simple database schema, so I’ve created a PHP script to do the migration, which you can obtain at https://gist.github.com/mkuron/3e1c92f9c4e993c65857.
This script is not meant as a black-box solution. It can only get you started in creating your own migration script, as every JIRA setup is different. Before you start, create all staff accounts in osTicket and make sure they have the same user name as in JIRA. Then, set up OAuth for JIRA as explained here: Two-legged OAuth between PHP and JIRA. Add your MySQL password and the mail domain you use to identify staff accounts to the scripts (if you don’t have a common mail domain for staff accounts, you’ll need to edit the logic to identify staff accounts based on group membership). Specify your tech support project key and give the map of knowledge base project keys to osTicket KB category IDs. Run the scripts on the command-line and copy the resulting attachments folder to your osTicket server (note that you’ll need the Attachments on Filesystem plugin and configure it to use the attachments folder).
The scripts are rerun-safe and transactional. If you want, you can remove the jira_id columns from the ost_faq, ost_ticket_thread and ost_file tables after you finish the migration.
To ensure that links continue working as much as possible, add the following redirects to your web server config:
# Redirect JIRA issues RedirectMatch permanent ^/jira/browse/(TECH-[0-9]+) /osticket/jira-redir.php?key=$1 # Redirect all other JIRA pages RedirectMatch permanent ^/jira/ /osticket # prevent access to attachments folder RedirectMatch ^/osticket/attachments/ /osticket/file.php
Put the following file into your osTicket folder and call it jira-redir.php:
<?php require_once 'bootstrap.php'; require_once INCLUDE_DIR . 'ost-config.php'; if (substr(DBHOST,0,1) == ':') $mysqli = new mysqli("localhost", DBUSER, DBPASS, DBNAME, 3306, substr(DBHOST, 1)); else $mysqli = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME); $stmt = $mysqli->prepare('SELECT ticket_id FROM ' . TABLE_PREFIX . 'ticket WHERE number=?'); $stmt->bind_param("s", $_GET['key']); $stmt->execute(); $stmt->bind_result($ticket_id); $stmt->fetch(); $stmt->close(); $url = 'http://'; if ($_SERVER['HTTPS']) $url = 'https://'; $url .= $_SERVER['HTTP_HOST']; $url .= dirname($_SERVER['SCRIPT_NAME']); $url .= '/scp/tickets.php?id='; $url .= $ticket_id; header("Location: " . $url, true, 301); ?>