HOW-TO:Share libraries using MySQL/Upgrading XBMC

When updating to a new version, XBMC will make a copy of the current DB and upgrade the copy. That way if anything goes wrong in the upgrading you still have an original untouched copy of your DB.

Starting in XBMC v12 "Frodo", you no longer need to use path substitution to sync thumbnails and other art between XBMC devices. Using path subs is still supported, which is useful for XBMC devices with small amounts of memory, or even recommended for devices with limited I/O storage and capacity, such as the Raspberry Pi, to improve performance.

Updating your library may take a few minutes, so be sure to give XBMC time to do its thing. Stopping midway will mess up the updated DB.

Backing up the database
BACKUP YOUR DATABASE JUST IN CASE.

Even though XBMC makes a copy of your DB and updates that, it is still highly recommended to export your library from your current version before beginning the upgrade process. You don't want to find yourself starting your library from scratch, and it's better to be safe than sorry.

It's also a good idea to make periodic backups of your library even if you are not updating XBMC. Disks can fail, bugs can happen, and if you've put a lot of time in setting up your library then you should play it safe.

To backup simply export the library to a single file using Settings -> Videos -> Library -> Export library and select "multiple files". "Single file" also works, but "multiple files" is recommended as it is the most fail-safe method, especially for saving/resorting images.

Making sure MySQL can update the library
Note: If you originally set up MySQL using this XBMC Wiki guide then you should not have to worry about this section. It never hurts to double check the settings, though.

For XBMC to update the library from a previous version, you may need to make changes to your MySQL server. The user made for the MySQL DB ("xbmc" in most guides) will need access to create new databases. If the user already has that access then you don't need to do anything. If not, you will have to use the following command on your MySQL server:



If you are worried about security then you can limit XBMC's access in MySQL once it has created the new video DB. However, you will need to re-grant these privileges the next time you update XBMC. If the only thing you use MySQL for is XBMC then you don't really need to worry about security.

If you used Path Substitution
XBMC v12 and later no longer needs path substitution for syncing thumbnails.


 * If you used path subs for the entire Thumbnails folder - Extra safe method
 * 1) Quit all XBMC devices.
 * 2) Update all instances to XBMC v12 "Frodo", but don't open/launch XBMC yet.
 * 3) Choose one XBMC device and open XBMC
 * 4) Say yes when it asks to update art.
 * 5) Copy your path-substituted thumbnails folder onto all XBMC devices, replacing the local thumbnails folder in the userdata folder.
 * 6) On the first XBMC device go into userdata/database/ and copy the "Textures13.db" file to all the other XBMC devices in their userdata/database/ folders.
 * 7) Remove path substitution for thumbnails from the advancedsettings.xml file of each XBMC device.
 * 8) You can now open/launch XBMC on your other devices.
 * 9) From that point on, XBMC will sync art/thumbs directly to each XBMC box, but will keep them in sync (whereas before XBMC would only add art on one box, and boxes could have different artwork if set manually). Having the thumbnails folder locally on each box will also speed up loading the library, and what art to use is stored in the videos DB that MySQL is already sharing.


 * If you used path subs for only userdata/thumbnails/videos/ and userdata/thumbnails/music/ - Extra safe method
 * 1) Quit all XBMC devices.
 * 2) Choose one XBMC device to do the initial thumbnails update.
 * 3) Copy the path-substituted thumbnails folder(s) for userdata/thumbnails/videos/ and/or userdata/thumbnails/music/ to the local userdata/thumbnails/ folder on your first XBMC device.
 * If your thumbnails folders are being shared from another XBMC device's thumbnails folder then you don't need to do this. Just make that XBMC device your "first device" for these instructions.
 * 1) Update all instances to XBMC v12 "Frodo", but don't open/launch XBMC yet.
 * 2) Open XBMC on your first device.
 * 3) Say yes when it asks to update art.
 * 4) Copy your the thumbnails folder from the first XBMC device onto all the other XBMC devices.
 * 5) On the first XBMC device go into userdata/database/ and copy the "Textures13.db" file to all the other XBMC devices in their userdata/database/ folders.
 * 6) Remove path substitution for thumbnails from the advancedsettings.xml file of each XBMC device.
 * 7) You can now open/launch XBMC on your other devices.
 * 8) From that point on, XBMC will sync art/thumbs directly to each XBMC box, but will keep them in sync (whereas before XBMC would only add art on one box, and boxes could have different artwork if set manually). Having the thumbnails folder locally on each box will also speed up loading the library, and what art to use is stored in the videos DB that MySQL is already sharing.

If you copied your thumbnails folder
If you simply copied your thumbnails folder between XBMC devices then you technically don't have to do anything extra. However, you may wish to use this extra safe method:
 * 1) Quit all XBMC devices.
 * 2) Update all instances to XBMC v12 "Frodo", but don't open/launch XBMC yet.
 * 3) Choose one XBMC device and open XBMC
 * 4) Say yes when it asks to update art.
 * 5) Copy your the thumbnails folder from the first XBMC device onto all the other XBMC devices.
 * 6) On the first XBMC device go into userdata/database/ and copy the "Textures13.db" file to all the other XBMC devices in their userdata/database/ folders.
 * 7) You can now open/launch XBMC on your other devices.

If you used some process to keep the individual thumbnail folders in sync (such as a script, Dropbox, symbolic links, or rsync) then you no longer need to use those processes. XBMC will download images for new library entries on each XBMC device, and will synchronize the download URL via MySQL (using the videos and/or music DB).

Upgrade fails

 * 1) Downgrade XBMC on one of your XBMC devices to the previous version of XBMC (you only need to do this to one device). Export the library to multiple files using Settings -> Videos -> Library -> Export library and select "multiple files".
 * Note: If you backed up your XBMC database, you can use that backup in place of this first step.
 * 1) Quit XBMC
 * 2) Place true in your advancedsettings.xml file on the downgraded XBMC device.
 * 3) If you used the tag in your advancedsettings.xml file, remove these lines. XBMC will simply use default database names instead (MyVideos and MyMusic). Sometimes using the tag will cause issues when updating the MySQL libraries, but the tag is not needed as of XBMC v11.
 * 4) Use the MySQL configuration utility to drop/delete the existing MySQL copies of the XBMC database(s).
 * 5) When using phpMyAdmin: select Databases option from the top of the screen, put a checkbox in front of all databases called MyMusic or MyVideos followed by some digits, and select Drop underneath the list. Confirm that you want to drop the databases.
 * 6) When using the command line tools: enter   including the semicolon. Type   for every name in the resulting list starting with MyMusic or MyVideos and followed by some digits, for example:   Note that actual names may vary per XBMC version, and do not forget the trailing semicolon.
 * 7) Upgrade the downgraded XBMC device back up to v12 and open XBMC again.
 * 8) Import the library by simply scanning it in as a new file source. XBMC will pick up the exported data as it scans the files in.
 * 9) XBMC will now rebuild a fresh MySQL library DB, but using all your existing information.
 * 10) You can now open/launch XBMC on the other devices.

Different XBMC versions
Using MySQL to sync the library only works if all XBMC devices are using the same version of XBMC.