Is there a way (command line is fine, if necessary) to see a listing of all of the folders assigned to all of the libraries on my Plex Server? As my server has grown, many libraries have several different folders usually on different drives. Right now, the only way I can find out which folders are assigned to libraries is one at a time using the ‘Add Libraries’ panel in the ‘Edit Library’ tool through the web interface.
I am looking for a way to see that information for all libraries at the same time, preferably in a way I can copy to a text file to use for reference while I am cleaning up the drives.
I am also curious if there is any way to discover this same information from the files in %LocalAppData%‘Plex Media Server’ after the computer running the server has died and the drive is moved to a new machine. This would GREATLY help in preparing the media drives on the replacement system.
Using a SQLite editor I found it relatively easy.
(free for Windows: https://sqlitebrowser.org/)
Open the file com.plexapp.plugins.library.db
(which of course can be opened also when the server is not running. If this file is invalid, try opening one of the backup copies instead, which are by default in the same folder.)
The information you seek is listed in the table section_locations.
You’ll have to cross-reference which library_section_id is which library name, using the table library_sections.
This SQL query will give you the most important library properties, neatly listed together:
SELECT S.id, name, root_path, agent, scanner FROM section_locations L INNER JOIN library_sections S ON L.library_section_id=S.id ORDER BY name
If the drive is not damaged and you are going to move it into the new machine, you might even be able to work with all the old plex data.
Which will transfer all metadata, all “watched” states, playback history, manually edited metadata etc to the new machine.
In order for this to work, you need to:
make the old plex data folder read+write -able by the new Windows user account.
access the “user” part of the old Windows registry, and extract the Plex-specific data, and import them into your new Windows user account. This step will enable you to also carry over your old server ID and all the shares you may have created for other plex users.
1)
After inserting the old hard drive into the new machine, Windows will ask you if you want to make it accessible. If you tell Yes, Windows will take care of it.
If you abort Windows while it’s doing this, you’ll have to repair the access permissions to the folder and make sure that these permissions are properly propagated downwards, to all folders and subfolders and files therein, yourself.
2)
Read up on how to open old registry “hives” with regedit.exe. The relevant file is not only set to be ‘hidden’, but is also marked as ‘system’.
So to be able to find it, you first might have to enable both the display of hidden and system files in Windows file explorer.
see Accessing Another Windows Computer’s Registry from a Disk in Windows 8.1 | Outside the Asylum
Once you have the data, you will export them into a .reg file. Then open the file with a text editor and replace the path informations in square brackets with the regular paths, so they all start with [HKEY_CURRENT_USER\Software\Plex, Inc.\Plex Media Server...
Then you can double-click this .reg file and import these informations into your new Windows installation.
If the .reg file already contained the key LocalAppDataPath, make sure to edit it and adapt it to the new location of the plex data folder on your new machine.
If the key LocalAppDataPath is not present, go to step 3
3)
Install Plex server
start it and then go to Settings - Server - General - ‘Show Advanced’ - “The path where local application data is stored”
Put the location of the plex data folder into there, but leave out the last part named Plex Media Server.
e.g. if you have moved the plex data folder to D:\plexdata\Plex Media Server, then put only D:\plexdata into there.
(Do not move the folder Plex Media Server to the root folder of a drive.)
The instructions for moving from a dead machine are all very good (especially the linked article about how to access the old machine’s registry files, thanks for that) but…
My question was only about how to discover the configured locations assigned to all of the libraries from the old, dead server by reading the server’s disk.
My interpretation of the answer is, “That cannot be done without fully restoring/moving the old Plex server to the new computer.” Honestly, I did not expect Plex to use the registry (except when required by some Windows function) for anything because Plex runs on other operating systems that do not have the Windows registry. I expected Plex to use a common system for configuration that would be the same for all platforms. (Silly me for thinking portability is valuable.) I figured one of those configuration files might contain the library configuration.
I was wrong and this task is not possible.
FWIW, I have moved my Plex server to a new machine several times, never having any issues. But my sister’s Plex machine just died and while we moved everything from the old drive OK, we wanted to be sure we had the media drives (which are external to the computer) mounted at the expected drive letters before starting the moved Plex server. Alas, we cannot do that, so she will need to go through the process of re-adding every folder to every library from the current locations on the new system. Oh well, it was worth a try.
Plus, I can use the SQL script to extract the config (I hope) and save it in case this problem occurs for me (or again for her.)
That’s not true. If you can read the primary database file off the old hard drive or a backup copy, my first answer has all you need.
My second post was just about showing a possible alternative, because it will retain more of the old server’s data – if the new computer was running Windows as well. If you also want to switch platforms, that’s a more complex task.
Sorry for my misunderstanding. I have occasionally use various SQL products since the late '80s, but they have all required an operating server. Plus, there was no location provided for the database file itself (I finally found it in %LocalAppData%\Plex Media Server\Plug-in Support\Databases and was surprised to find what I considered part of the base plex product located in Plug-in Support) so my incorrect assumption was that a server was needed.
I managed to get it to work for my system like this:
C:\sqlite3\sqlite3 -header -csv "E:\PlexData\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db" "SELECT S.id, name, root_path, agent, scanner FROM section_locations L INNER JOIN library_sections S ON L.library_section_id=S.id ORDER BY name;"
I moved the Plex Media Server data folder to its own drive because it was taking over my 500GB boot drive, but correcting the “E:\PlexData” part of the path should allow this command to work for anyone to produce a nice CSV file that can be opened by any spreadsheet program (and more).
That’s a very good strategy, because you can easily move this whole drive to another machine if the original machine breaks down.
Installing server software, then change “The path where local application data is stored” is almost all to get it working in such an event.
(Bonus points for having a backup of the registry keys, which then also allow seamless transition of shares and sidebar/homescreen personalizations).