[HowTo] Plex database modification - Moving media the right/wrong way

Ok, wow! That was surprisingly easy. Everything seems to be working GREAT!

So just so it’s clear. Following my instructions will likely mess up your Library. But it worked wonders for me. AND it is SO easy. Easier than following the nuanced instructions in that article I linked above.

  1. Shutdown plex server
  2. Backup your data Backing Up Plex Media Server Data | Plex Support
  3. Copy your content to the new location
  4. Drop the triggers that prevent editing your database.
  5. Edit your database. Find the location here: Repair a Corrupt Database 1.22.0 and earlier | Plex Support
  6. Add the triggers back.

You will need to drop 2 triggers before you can edit the DB:

drop trigger fts4_metadata_titles_before_update_icu
drop trigger fts4_metadata_titles_after_update_icu

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%'

Now add the triggers back:

CREATE TRIGGER fts4_metadata_titles_before_update_icu BEFORE UPDATE ON metadata_items BEGIN DELETE FROM fts4_metadata_titles_icu WHERE docid=old.rowid; END;
CREATE TRIGGER fts4_metadata_titles_after_update_icu AFTER UPDATE ON metadata_items BEGIN INSERT INTO fts4_metadata_titles_icu(docid, title, title_sort, original_title) VALUES(new.rowid, new.title, new.title_sort, new.original_title); END

7 Start up Plex Server
8 Verify that everything is working (test loading some of the copied files, note the location of that library changed in plex web settings)
9 Delete the old files.
10 Drink a beer for me.

Thanks everyone, I can’t believe how simple it is and how inaccurate that article is. Might be a good idea to just implement a move function in Plex Web…
Joseph Elwell.

[moderator edit: repaired code formatting with Markdown syntax]

19 Likes