Tutorial - How to Transfer SQLite to MariaDB

Requirements: Perl, MariaDB
Tested on: Ubuntu 18.04 and Centos 7

Step by Step Guide

  1. You will need to SSH to the machine to do everything so go login.
  2. Stop your currently running teamspeak server.
tar -cvf ts3.tar /home/ts3/teamspeak3-server_linux_amd64
  1. Before you do anything you should take a backup of your server just in case you mess up with anything.
tar -cvf ts3.tar /home/ts3/teamspeak3-server_linux_amd64

or

zip -r ts3.zip /home/ts3/teamspeak3-server_linux_amd64
  1. Create a new database into MariaDB.
mysql -u root -p
CREATE DATABASE ts3;
exit
  1. Go to teamspeak directory.
cd /home/ts3/teamspeak3-server_linux_amd64
  • put your own path
  1. Create a dump file of the current SQLite file.
sqlite3 ts3server.sqlitedb .dump > ts3dump.sql
  1. Create the Perl converter file and put the following code.
nano sql.pl

https://pastebin.com/raw/BKATXgx5

(Add inside the sql.pl the content of the pastebin. For some security reason the forum didn't allow me to post the code.
  1. Run the Perl file.
perl sql.pl ts3dumb.sql > ts3.sql
  1. Now that you have a compatible MySQL file you need to import it to the database we made before.
mysql -u root -p ts3 < ts3.sql
  1. Convert and Fix to fully work with MariaDB. Under teamspeak’s directory go to " sql/updates_and_fixes " and run the following commands.
mysql -u root -p ts3 < convert_mysql_to_mariadb.sql
mysql -u root -p ts3 < mariadb_fix_latin_utf8.sql
  1. Go back to teamspeak’s root directory and create the " ts3server.ini " file and add the following lines bellow.
nano ts3server.ini

If you already have this file just modify the following lines.

dbplugin=ts3db_mariadb
dbpluginparameter=ts3db_mariadb.ini
dbsqlpath=sql/
dbsqlcreatepath=create_mariadb/
dbconnections=10
  1. You will also need to create the file " ts3db_mariadb.ini " so you can make the database connection from teamspeak to mysql.
nano ts3db_mariadb.ini
[config]
host=127.0.0.1
port=3306
username=root
password=your_password
database=ts3
  1. Copy the MariaDB library from teamspeak’s " redist " folder into teamspeak’s main folder.
cp /home/ts3/teamspeak3-server_linux_amd64/redist/libmariadb.so.2 /home/ts3/teamspeak3-server_linux_amd64/libmariadb.so.2
  1. Modify the teamspeak server start script to read the ts3server.ini file on ts3 server start or restart.
    Find the following lines:
ExecStart=/home/ts3/teamspeak3-server_linux_amd64/ts3server_startscript.sh start
ExecReload=/home/ts3/teamspeak3-server_linux_amd64/ts3server_startscript.sh restart

And replace them with:

ExecStart=/home/ts3/teamspeak3-server_linux_amd64/ts3server_startscript.sh start inifile=ts3server.ini
ExecReload=/home/ts3/teamspeak3-server_linux_amd64/ts3server_startscript.sh restart inifile=ts3server.ini
  1. Reload systemctl to verify the changes on the service start.
systemctl daemon-reload
  1. You are ready to start the server again!
service teamspeak start
  1. After that update your teamspeak’s instance log should return this.
2020-04-13 15:23:31.847227|INFO    |ServerLibPriv |   |TeamSpeak 3 Server 3.12.1 (2020-03-27 10:38:47)
2020-04-13 15:23:31.847477|INFO    |ServerLibPriv |   |SystemInformation: Linux 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 Binary: 64bit
2020-04-13 15:23:31.852988|INFO    |DatabaseQuery |   |dbPlugin name:    MariaDB plugin, Version 3, (c)TeamSpeak Systems GmbH
2019-03-28 16:12:08.746601|INFO    |DatabaseQuery |   |dbPlugin version: 2

You are ready!

You can safely remove these files from the teamspeak directory as they are not needed anymore:

  • ts3dump.sql
  • sql.pl
  • ts3.sql
  • ts3server.sqlitedb (Old database file. You can keep it for backup if you want.)
6 Likes

Is there an update for Teamspeak 6? I tried it this way, but when I try to bash the ts6.sql into MariaDB, I get some errors about column sizes and also some syntax errors.

//Edit → You need to edit the dump file before bashing it and fix each error manually. After that, you have to use the convert_mysql_to_mariadb.sql from /sql/updates_and_fixes. The mariadb_fix_latin_utf8.sql keeps throwing errors because of emojis. I fixed it by removing/sorting out the emojis.
Then you also need to delete the ts3server.sqlitedb file (make a backup first), otherwise it will still load the SQLite database. After changing the tsserver.yaml, everything is working now :slightly_smiling_face:.

//Edit2 → Problems with 2 bots
bot1: Error while getting channel list!
bot2: ERROR TS3 Error: 2052: Error while getting server group list: file input/output error

//Edit3 → Never mind — after restarting, it’s working :slightly_smiling_face:.

//Edit4 → It runs much smoother now. I think the bots were competing while using SQLite, and I always had to wait about 10 seconds when creating a new channel. Performance is much better now.