I get to this part sqlite3 com.plexapp.plugins.library.db < dump.sql
and I get Error: near line 982: UNIQUE constraint failed: media_parts.id Error: near line 383308: no such collation sequence: naturalsort
Might need help from a database person for this one…
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases# sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"
*** in database main *** On tree page 771 cell 1: Rowid 5865 out of order Fragmentation of 1 bytes reported as 0 on page 769 On tree page 808 cell 6: Rowid 1761 out of order row 863 missing from index index_media_parts_on_size row 863 missing from index index_media_parts_on_deleted_at row 863 missing from index index_media_parts_on_file row 863 missing from index index_media_parts_on_hash row 863 missing from index index_media_parts_on_media_item_id row 863 missing from index index_media_parts_on_directory_id row 864 missing from index index_media_parts_on_file row 864 missing from index index_media_parts_on_hash database disk image is malformed
That error means that the unique id has been used twice, which shouldn’t happen normally. You will need to first identify the duplicate, then delete one of them, which should then remove the corruption and things should go back to normal.
First, run
select count(id) from media_parts group by id having count(id) > 1;
That will tell you the id for the duplicate entries. You then need to view these entries:
select * from media_parts where id = 1;
Replace that 1 with the result of the first part. Then after looking at the 2, decide which one you want to delete. Or to make it simple, you can delete both. One of them should get recreated on your next library scan.