[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
How to change library paths to use UNC names instead of drive letters?
Moving my library and improperly matched movies
Rename folder of movie but maintain metadata
Plex Movie Posters - not showing when server was moved
Question Re: Moving Files to New Hard Drive
Rename without losing watched status
What if all Windows drive letters are in use?
Without Reg keys will db transfer be possible
Plex reverting metadata since switching to NAS
Artist Posters from Plex Backup
Moving 1 individual Library's Media Content
Empty Trash just for a specific Show
Server Migration Lost Music Playlists but not Video Playlists?
Relocating TV Library -> rerun all your "Detecting intros:"
Move server info from macos to linux host
How\Whether to Save Metadata from my current installation
How do I migrate hard drives without losing all my formatting and watch progress?
Move library folder on same volume
What's the easiest way to migrate from a Linux server (Raspberry Pi4) to an Nvidia shield server?
Plex crashes randomly after latest update
Moved my music files to another harddrive and I now have two copies of every alblum?
Simple Location Move
RE: Playlists Empty
Non-stacking duplicates after migration
New external hard drive
Random Posters missing after moving to a new server
Movies - Sort by Folder Modified Date or File Modified date
Every folder in TV library being scanned individually = VERY slow scanning
Changing Library Drive Letter Without Losing Data
Changing Library Drive Letter Without Losing Data
Changing Library Drive Letter Without Losing Data
Move DVR media
Edit playlists to reference different drive/location
Updating media path in Plex database
Changing media drive letter in windows WITHOUT data copy
Edit Library Paths in Bulk
Help - re-IP has lost my watched data
Moved my library from Win to NAS, how to maintain music database (covers, etc,?)
Plex Media Server mit vielen angepassten Metadaten von Windows 11 auf Synology NAS migrieren
Moving from Drobo to TrueNAS SCALE
No Extra section in preplay page
Question on Move Media Content to a New Location located at https://support.plex.tv/articles/2011545
Associate Music Playlist to new Library
Change folder name without rescan intro
Chaning mount point for external HDD in FSTAB without having to rebuild database or local cache
Library Re-Arrange
Is there an easy way to rename media files?
Migrating Plex server - sqlite tables empty in database backup
Changing drive letters for media
Way to backup Playlist?
Movie extra paths not surviving library relocation/Media rescan not updating movie extra paths
Slightly different move from one system to another
Database migration from Nvidia Shield Pro to NAS - possible?