Duplicate MySQL databases for Kodi

Just a quick post about cloning the Kodi database. Fiddling with MySQL is not my strong point, in fact this was the second time I did something with MySQL… Cant wait till Microsoft finishes the Public Preview of MSSQL for Linux.

My case

I have a VM with MySQL for Kodi (Jarvis) 16.1 . Two Raspberry Pi’s connect to this database. When you connect a Krypton (17.0) device to the database the database will be upgraded and officially you will not be able to connect with 16.1 clients anymore.

17.0 seems stable, but my Kodi distribution OSMC also changed a few thins along with the core Kodi update and not everyone is happy according the user forums. So I would like to test the OSMC 17.0 version before upgrading with no downgrade possibility.

What you need

I like to keep things simple when working on new stuff and not mess with a “production” server/database, so I created a new VM with an empty MySQL server. The server is using the same settings as my primary server.

I’ve read some documentation from MySQL en tips from other people and they all sort of begin with creating a new database to restore data in.

Using MySQL Query Browser:
CREATE DATABASE `MyMusic14` /*!40100 DEFAULT CHARACTER SET utf8 */;
CREATE DATABASE `MyVideos15` /*!40100 DEFAULT CHARACTER SET utf8 */;

After this we have the same databases on both machines, one filled to precious data and the other one empty. Now we need to transfer the data from point a to b.

According the Reference Manual mysqldump is a tool for this. The basic syntax is:

mysqldump db_name | mysql -h ‘other_hostname’ db_name

From a putty session on my primary database I used the following to copy the data to the other database server:

mysqldump -h 1.1.1.1 -u kodi -pkodi MyVideos15 | mysql -h 2.2.2.2 -u kodi -pkodi MyVideos15

mysqldump can also use compression when transferring the data by using the –compress option. You just need to add this in the first part of command like this:

mysqldump -h 1.1.1.1 -u kodi -pkodi --compress MyVideos15 | ...same as above

After this you have two working databases for Kodi. Change the name or ip in the advancedsettings.xml to connect to the new database.

 

I noticed the following performance on the new empty virtual machine, funny isn’t it. Looks like the –compress option adds a lot overhead to this copy.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s