How can I move the recordings part of the DB to a new install?

For discussion related to MythTV which doesn't belong in another forum.

Moderator: Forum Moderators

Post Reply
oolizo
Newcomer
Posts: 5
Joined: Mon Mar 30, 2015 3:32 pm
Denmark

How can I move the recordings part of the DB to a new install?

Post by oolizo »

I want to replace my very old MythTV instance with a new one: new hardware, fresh install, fresh database - except for the recordings part of the database (and only the recordings), which I'd like to carry over. At the same time, I'd like to get them cleaned up, i.e. delete all recordings for which no DB entry exists, and delete all DB entries, for which no actual recording exists.

Anybody know how to approach this?
LinuxGeek28
Junior
Posts: 17
Joined: Mon Dec 24, 2018 4:55 pm
United States of America

Re: How can I move the recordings part of the DB to a new install?

Post by LinuxGeek28 »

There is a nice script on the wiki that handles orphans. https://www.mythtv.org/wiki/Find_orphans.py

I don't think a script has been written to "clean the database" and because of the foreign key table dependencies, you could easily break your system if you tried to copy just the recorded table to a new DB.

The DB upgrade process keeps recording rules, recording history, etc. in-place which can be valuable.

There is a method/script to export your recordings. You could export from the old and import them as videos into a new system, but you'll have to refresh the metadata via the videos menu.

Another option, using the mythlink script: https://www.mythtv.org/wiki/Mythlink.pl
You could create symlinks to the recorded programs. For TV shows, you can have it create the links under the TV Show folder name. You could use rsync to move the files to a new location and rename the files according to show/episode name.

If you are really brave and know some SQL, you can install MySQL Workbench and try truncating some tables to clean them. I have know idea what damage you might do, but if you've backed up your DB and tested it before starting, you'll always have a fallback.
oolizo
Newcomer
Posts: 5
Joined: Mon Mar 30, 2015 3:32 pm
Denmark

Re: How can I move the recordings part of the DB to a new install?

Post by oolizo »

Thanks for replying! I'll have a look at the links you posted.
because of the foreign key table dependencies, you could easily break your system if you tried to copy just the recorded table to a new DB.
Can you elaborate on this?
white_haired_uncle
Senior
Posts: 265
Joined: Thu Feb 23, 2023 8:55 pm
Location: Safe outside my gilded cage
United States of America

Re: How can I move the recordings part of the DB to a new install?

Post by white_haired_uncle »

The recorded table has column recordid, which is presumedly a reference to the record table. So if you restore recorded, but not record, you'll have
entries in recorded which reference entries in record that don't exist. As time goes by and record gets populated with new data, you'll have entries in recorded which reference entries in record that are completely wrong.

Don't quote me on the specifics here. That recordid MIGHT not be a reference to the record table (it SHOULD be, but sometimes people do weird stuff), but the example should show why you usually can't just restore/save one table without its friends.
oolizo
Newcomer
Posts: 5
Joined: Mon Mar 30, 2015 3:32 pm
Denmark

Re: How can I move the recordings part of the DB to a new install?

Post by oolizo »

Thanks for the explanation. I'll probably have a deeper look and fall back on exported-recordings-as-videos in combination with some thorough spring cleaning when I give up...

The find_orphans script looks perfect - so far, so good. :)
Post Reply