[mythtv-users] Copy frontend settings to new frontend keeping both

R. G. Newbury newbury at mandamus.org
Fri Oct 30 13:54:48 UTC 2015


On 10/29/2015 01:28 PM, Mike Perkins wrote:
> On 27/10/15 19:04, R. G. Newbury wrote:
>> On 10/26/2015 11:22 AM, Myth TV wrote:
>>> I know the right answer is to never modify the database directly, but I
>>> have done this in the past:
>>>
>>> Connect to the DB and then:
>>>
>>> INSERT INTO mythconverg.settings SELECT value,data,'<new frontend
>>> name>' FROM
>>> mythconverg.settings WHERE hostname = '<existing frontend name>';
>>
>> To the OP
>> Further to this route, you can start by doing:
>>
>>   mysqldump -u mythtv -pmythtv --extended-insert --no-create-db
>> --add-drop-table --databases mythnew
>>  > junk
>>
>> which will give you a complete text output of the *present* database.
>>
>> grep -n 'hostname' junk
>>
>> will show the lines where 'hostname' appears. You will find that you
>> may have up to a dozen tables
>> which have a 'hostname' entry. Some of those relate to hardware, but
>> most are frontend settings.
>>
>> You could copy each affected table's data into "newfile", do a
>> sed -i -e 's|oldhostname|newhostname|g' newfile,
>>
>> (a global find and replace on the text file) and paste the amended
>> file back into "junk".
>> That would give the database the same settings for the 2 frontends
>> (things like profilegroups, and
>> storagegroups may need to ba fixed anyway).
>>
>> The settings table is a little more.... interesting, as it contains
>> entries specific to the backend,
>> You should have no problems if the backend is on another box, but if
>> your base box is a BE/FE, a
>> full copy/amend/paste may confuse the machine....
>>
>> When you are feeling  lucky, you can do:
>> mysql -u mythtv -pmythtv mythnew  < junk.
>>
>> As you stated in the beginning, there is no easy way to do this.
>> There is especially no non-dangerous way to do this.
>>
>> And of course, a good prophylactic step is to shave your head before
>> beginning. This will stop you
>> from tearing your hair out later.
>>
> Ow! Are you serious? 'hostname' is a column in the recorded table.
> Changing that would move the recordings from the old host to the new...
> and then duplicate those entries when you pasted them back in!
>
> Oh, and I think a few tables use or used 'host', not 'hostname'.

Yes, searching for 'hostname' in the mysqldump file, will show which 
tables contain references to 'hostname and the 'oldhostname'.

He can play with those tables as he wishes, AND, as I pointed out, when 
he feels lucky, he can push his changes back into the database, with a 
'new' front-end created. Some references CANNOT BE CHANGED.
YMMV.... etc.   Shave your head to reduce your pain... etc.

And we already know, it will be damn dangerous. Maybe we should call it 
'changing the hoistname' as in 'hoist on his own petard'...

At the least reviewing the mysqldump output will give an idea of WHERE 
in a new frontend, you have to fix/change settings. Unfortunately, as 
the OP pointed out at the top, there is no easy way to duplicate a 
setup's frontend settings.

Maybe, one of the devs might take note, so that somewhere down the road, 
the database tables are re-arranged to segregate BE and FE settings by 
table name (and value entries in the settings table) so that this could 
be done. But it does not presently exist and we have to live with the 
difficulty.

The only SAFE way to do any of this, is to not start down this road. 
Just fire up the new FE and page through every settings page..

Geoff










More information about the mythtv-users mailing list