Skip to content

Instantly share code, notes, and snippets.

@hthighway
Created August 21, 2018 18:47
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hthighway/d687a9fc07b2af55756e5a8aac94df12 to your computer and use it in GitHub Desktop.
Save hthighway/d687a9fc07b2af55756e5a8aac94df12 to your computer and use it in GitHub Desktop.
Change file path for Plex Media
1 Shutdown plex server
2 Backup your data https://support.plex.tv/hc/en-us/articles/201539237
3 Copy your content to the new location
4 Edit your database. Find the location here: https://support.plex.tv/hc/en-us/articles/201100678-Repair-a-Corrupt-Database
5 There are 4 edits you'll need to make (change pathing to appropriate values):
UPDATE section_locations
SET root_path= replace(root_path, '/Users/jelwell/Shared', '/Volumes/Movies')
where root_path like '%/Users/jelwell/Shared%'
UPDATE metadata_items
SET guid= replace(guid, 'file:///Users/jelwell/Shared', 'file:///Volumes/Movies')
where guid like '%file:///Users/jelwell/Shared%'
UPDATE media_streams
SET url= replace(url, 'file:///Users/jelwell/Shared', 'file:///Volumes/Movies')
where url like '%file:///Users/jelwell/Shared%'
UPDATE media_parts
SET file= replace(file, '/Users/jelwell/Shared', '/Volumes/Movies')
where file like '%/Users/jelwell/Shared%'
5 Start up Plex Server
6 Verify that everything is working (test loading some of the copied files, note the location of that library changed in plex web settings)
7 Delete the old files.
@mkaltner
Copy link

mkaltner commented May 5, 2022

This helped me cleanly port my server from docker to my Synology Diskstation (DSM 7) however I ran into issues updating media_streams, receiving the following error: Error: unknown tokenizer: collating

To properly update media_streams I had to use Plex Media Server itself to run sqlite like so:

Plex\ Media\ Server --sqlite com.plexapp.plugins.library.db

The path on my DSM was /volume1/@appstore/PlexMediaServer/Plex\ Media\ Server.

Hope this helps someone in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment