Kodi Community Forum

Full Version: XBMC MySql database backup - multiple databases?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

Edit - Ah oops, wrong forum sorry. Can someone please move to general support for me?

I went to back up my local MySQL that runs the XBMC database this evening. I access it from a few clients so it'd be nice to keep my watched shows etc.

I seem to have seven xbmc video databases, and six music databases, despite configuring only one, and not adding any music to XBMC (as far as I recall). I've done a google search and nothing comes up. I really just want to back it up, but backing up thirteen databases seems a bit silly, surely only one is being used?

Code:
Show databases;
'xmbcmoviedatabase60'
'xmbcmoviedatabase67'
'xmbcmoviedatabase68'
'xmbcmoviedatabase69'
'xmbcmoviedatabase73'
'xmbcmoviedatabase75'
'xmbcmusicdatabase18'
'xmbcmusicdatabase27'
'xmbcmusicdatabase28'
'xmbcmusicdatabase30'
'xmbcmusicdatabase32'

Here's the advancedsettings.xml from my R.Pi (the Windows one is identical).

Code:
<advancedsettings>
    <videodatabase>
        <type>mysql</type>
        <name>XMBCMovieDatabase</name>
        <host>192.168.1.10</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
    </videodatabase>

    <musicdatabase>
        <type>mysql</type>
        <name>XMBCMusicDatabase</name>
        <host>192.168.1.10</host>
        <port>3306</port>
        <user>xbmc</user>
        <pass>xbmc</pass>
    </musicdatabase>
    
    <pathsubstitution>
      <substitute>
        <from>special://masterprofile/Thumbnails/Video/</from>
        <to>smb://192.168.1.10/xbmc/userdata/Thumbnails/Video</to>
      </substitute>
      <substitute>
        <from>special://masterprofile/Thumbnails/Music/</from>
        <to>smb://192.168.1.10/xbmc/userdata/Thumbnails/Video</to>
      </substitute>
    </pathsubstitution>
</advancedsettings>

Any thoughts or information is appreciated Smile
As far as I'm aware it's the database with the highest number so videodb75. Each time xbmc is upgraded it increments the database number.

I'm sure someone else can confirm if this correct.
Thanks ThY, that makes sense Smile I guess it means I have to keep changing my database backup script, which is slightly annoying, but I can live with it Smile
Hi timmmay,

Not sure what OS your using but if you're on linux I made this little script to dump the highest numbered database to two files (music and video). You would just need to change the DIR variable to your backup location.

Code:
#!/bin/bash

echo "Beginning XBMC database backup.";

echo "Creating backup directory.";

DIR=/media/backup/xbmc/$(date +%Y%m%d);

mkdir $DIR;

# Get music database number
MUSIC_DB=$(mysql -u xbmc -pxbmc -e "Show databases;" | grep "XMBCMusicDatabase");
MUSIC_DB=${MUSIC_DB:7}

echo "Exporting database 'MyMusic"$MUSIC_DB"'.";

mysqldump -u xbmc -pxbmc MyMusic$MUSIC_DB > $DIR/Music.$MUSIC_DB.sql;

echo "Music database exported.";

# Get video database number
VIDEO_DB=$(mysql -u xbmc -pxbmc -e "Show databases;" | grep "XMBCMovieDatabase")
VIDEO_DB=${VIDEO_DB:8}

echo "Exporting database 'MyVideos"$VIDEO_DB"'";

mysqldump -u xbmc -pxbmc MyVideos$VIDEO_DB > $DIR/Videos.$VIDEO_DB.sql

echo "Videos database exported.";

echo "XBMC backup finished.";

Of course if you have multiple clients and a machine which is on most of the time you may want to look into replication.

http://wiki.xbmc.org/index.php?title=HOW-TO:Sync_multiple_libraries/Update_Paths_In_MySQL (wiki)
Just a quick update, in case anyone else searches for specific terms. I wasn't getting updates on one of my devices, because one of the versions of Kodi (on my main computer) was running an older version and was point at an older database.

Kodi 14.1 used XMBCMovieDatabase90, at least on my computer. Kodi 14.2 uses XMBCMovieDatabase92.

Computer was saying
17:03:53 T:3038146560 NOTICE: Running database version XMBCMovieDatabase90

My media center Raspberry Pi 2 was saying
16:17:25 T:1968410624 NOTICE: Running database version XMBCMovieDatabase92

Because the computer was writing to the shared database v90 and the computer was reading v92 (which it migrated a few days ago) it didn't get the new media.

TLDR: update your version of kodi if you don't see updates.