I recently had to migrate an OTRS installation to another server. It's basically not that difficult as the files don't change and all data is stored in the database. However some migration steps should not be forgotten. This guide should serve as a reminder, in case I'll have to do another migration in the future.
The previous server will be called OLDSERVER, the destination server NEWSERVER in the following guide.
OTRS has its database on a MySQL server running on localhost.
1. Stopping OTRS on OLDSERVER
To not risk that during the transfer new tickets arrive or that an agent works on a ticket, OTRS should be stopped on OLDSERVER.
You can do this by stopping the cron service and Apache (or by simply disable the virtual host used for OTRS):
/etc/init.d/cron stop; /etc/init.d/apache2 stop
2. Create backup + transfer data on OLDSERVER
You should now have a consistent state of your OTRS installation on OLDSERVER so you can do a proper backup.
First the OTRS database needs to be dumped, then transferred to NEWSERVER:
mysqldump otrs > /tmp/otrs.sql; scp /tmp/otrs.sql root@NEWSERVER:/tmp/
Note that some OTRS databases can be huge, so it might make sense to zip/gzip/bzip the dump before the transfer.
Then the complete folder /opt/otrs (or wherever you have your OTRS installation installed) can be transferred to the new server.
I chose to pack the whole /opt/otrs into a tar.gz file to keep the file permissions and ownerships and then copy this file with scp:
tar -czf /tmp/otrs.tar.gz /opt/otrs; scp /tmp/otrs.tar.gz root@NEWSERVER:/tmp/
3. Prepare stuff on NEWSERVER
OTRS needs to run under its own system user, so this one needs to be created on NEWSERVER:
useradd -r -d /opt/otrs -c 'OTRS user' -u 1001 otrs
Make sure you use the same UID as used on OLDSERVER, if possible.
The new database (and database user) also needs to be created on NEWSERVER:
mysql> create database otrs;
mysql> grant all on otrs.* to 'otrs'@'localhost' identified by 'somePass';
In case you don't remember the password, you can look it up on OLDSERVER in /opt/otrs/Kernel/Config.pm.
Furthermore I'd stop the cron service on NEWSERVER as well:
4. Import data on NEWSERVER
Let's start with the files. We can now unpack the tar.gz file into /opt:
tar -xzf /tmp/otrs.tar.gz -C /opt/
Verify the file ownerships. If they don't seem OK (e.g. a "ls -l /opt/otrs" doesn't show the user otrs), you should run /opt/otrs/bin/otrs.SetPermissions.pl.
Then import the database:
mysql otrs < /tmp/otrs.sql
5. Don't forget the cronjobs!
This is most likely the step which could be forgotten the easiest. There are of course still the cron jobs on OLDSERVER, which need to run on NEWSERVER.
On OLDSERVER show the crontab of user otrs:
crontab -l -u otrs
Copy the whole output and on NEWSERVER insert it into the crontab:
crontab -e -u otrs
6. Complete the migration
Change DNS records to point to the new IP address, or inform your colleagues about the new domain/URL for OTRS.
It is recommended to do a quick testing on a secondary domain if OTRS works as it should. Only if the tests were successful, the "real" domain should then be changed or pointed to the migrated OTRS installation.
Once the tests were completed, you can start the cron service on NEWSERVER. This will start fetching the mails and create tickets again:
Florian from Switzerland wrote on Jan 4th, 2016:
Thanks for the tutorial
Do not forget to copy the apache 'script' to enable the new OTRS to be reachable. In my case I copied:
and I add to add the corresponding symbolic link into
sudo ln -s ../sites-available/otrs.conf otrs.conf
sudo apache2ctl -k restart
Umbymagik from italy wrote on Apr 23rd, 2015:
ck from Switzerland wrote on Mar 2nd, 2015:
Hi Rohanil, Maybe you forgot to make the server alias to /otrs in the Apache config? Or you could use a real VirtualHost entry without having to use the /otrs alias path.
Rohanil Raje from Japan wrote on Mar 2nd, 2015:
I could not able to access the otrs on new server.
It says 404 error: "The requested URL /otrs/index.pl was not found on this server."
There is no problem with apache. I followed all your steps.
Both servers are running CentOS.
Davide from Italy wrote on Aug 8th, 2014:
Very useful article.
Applied and worked perfectly.
AWS Android Ansible Apple Atlassian Automation BSD Backup Bash Bluecoat CMS Chef Cloud Consul Container Containers CouchDB DB DNS Database Databases Docker ELK ElasticSearch Elasticsearch Filebeat FreeBSD GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Icingaweb2 InfluxDB Internet Java Kibana Kubernetes LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Rancher SSL Security Shell SmartOS Solaris Surveillance SystemD TLS Tomcat Ubuntu Unix VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder