[mythtv-users] DB manipulation

R. G. Newbury newbury at mandamus.org
Thu Aug 7 16:12:12 UTC 2014


On 07/08/14 09:23 AM, Daryl McDonald wrote:
>
>
>
> On Wed, Aug 6, 2014 at 5:38 PM, Daryl McDonald <darylangela at gmail.com
> <mailto:darylangela at gmail.com>> wrote:
>
>
>
>
>     On Tue, Aug 5, 2014 at 5:25 PM, Mark Perkins
>     <perkins1724 at hotmail.com <mailto:perkins1724 at hotmail.com>> wrote:
>
>
>
>         On 6 Aug 2014, at 1:25 am, "Daryl McDonald"
>         <darylangela at gmail.com <mailto:darylangela at gmail.com>> wrote:
>
>>
>>         On Aug 5, 2014 12:22 AM, "Michael T. Dean"
>>         <mtdean at thirdcontact.com <mailto:mtdean at thirdcontact.com>> wrote:
>>         >
>>         > On 08/04/2014 05:58 PM, Doug Lytle wrote:
>>         >>
>>         >> Daryl McDonald wrote:
>>         >>>
>>         >>> Would it work to create the backup, restore it to the new
>>         system, then "mythconverg_restore.pl
>>         <http://mythconverg_restore.pl>
>>         <http://mythconverg_restore.pl> --change_hostname
>>         --old_hostname="XXXX" --new_hostname="YYYY" it?
>>         >>
>>         >>
>>         >> Yes
>>         >
>>         >
>>         > Iff you run the --change_hostname before you run any MythTV
>>         application at all on the new system, and iff you have never
>>         run any MythTV application on any system that used the new
>>         same host name as the new host name.
>>         >
>>         > Mike
>>         >
>>         > _______________________________________________
>>         > mythtv-users mailing list
>>         > mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org>
>>         > http://www.mythtv.org/mailman/listinfo/mythtv-users
>>         > http://wiki.mythtv.org/Mailing_List_etiquette
>>         > MythTV Forums: https://forum.mythtv.org
>>
>>         I'm guessing that you are saying that since I've set up the BE
>>         and added scripts etc., it won't work because I have already
>>         created a Db. In that case, would I have to drop the current
>>         Db before restoring the previous system's Db?
>>         Daryl
>>
>>         _______________________________________________
>
>         No, when a system (frontend or 'slave' backend) first connects
>         to the master backend the master backend populates a heap of
>         default settings into the database which are all keyed off the
>         host name. They will essentially remain in the database for
>         ever. What the --change_hostname command does is change all the
>         settings from an old hostname to a new hostname. However if the
>         new hostname has already been used (at some time in the past)
>         then the --change_hostname command would result in some settings
>         being duplicated which is not permitted under the database rules
>         so the change would fail.
>
>         I guess that the script fails gracefully (ie checks if the
>         proposed new hostname has been used before and refuses to
>         proceed if it has) rather than getting half way through and then
>         corrupting your database but either way make sure you have a
>         known good backup of your database and keep it some place very
>         safe....
>
>         If you have been able to successfully restore your database
>         during your testing so far then just keep doing whatever you
>         have been doing to restore the database. Just make sure that no
>         myth% program runs on the new system and touches the database
>         before the change hostname script has been run. Note MySQL will
>         need to be running with the database restored for the script to
>         work.
>
>         _______________________________________________
>         mythtv-users mailing list
>         mythtv-users at mythtv.org <mailto:mythtv-users at mythtv.org>
>         http://www.mythtv.org/mailman/listinfo/mythtv-users
>         http://wiki.mythtv.org/Mailing_List_etiquette
>         MythTV Forums: https://forum.mythtv.org
>
>
>     Looks like the weekend is when I'll get my window of opportunity to
>     make my changes. What I'm hearing is that it'll be all good if the
>     very next thing I do after restoring the old Db to the new system is
>     to rename it according to the new system's local hostname, right?
>
>     Does anyone know why my previous OS upgrade attempts always resulted
>     in a warning "unable to use any stored monitor configurations" and a
>     blank screen? I used the terminal to get the update manager to offer
>     the dist upgrade, but no joy!
>     Daryl
>
>
> The weekend came early, that is plans changed, and I tried the change
> hostname command, and am baffled with the following result :
>
> daryl at daryl-A780L3C:~$ mythconverg_restore.pl
> <http://mythconverg_restore.pl>
> <http://mythconverg_restore.pl>--change_hostname
> --old_hostname="daryl-A780L3C" --new_hostname="TriMyth"
> bash: http://mythconverg_restore.pl: No such file or directory
> daryl at daryl-A780L3C:~$
>
> any ideas?

You did a copy and paste using a program which "helpfully" expands any 
underlined text that it sees into an href. Note that Thunderbird, as one 
example does that, as there are now TWO hrefs in this reply. All I did 
was hit 'Reply' and voila!

mythconverg.pl took the now fiendishly inserted href as a file reference 
(since it was not preceded by a '--' marker), and asked bash to find 
that 'file', which naturally failed, hence the error message.

Geoff

PS. Once you have your backups safely stored, you can see what is going 
on with some NSFWAF mythconverg spelunking.

"mysql -u mythtv -pmythtv mythconverg"  followed by

"mysql> select * from settings order by value;" will give you something 
like 250+ lines of output. The rightmost column is the hostname. If you 
try this *before* running the mythconverg_restore.pl program, you can 
actually change the hostname with:

"update settings, set hostname="newname" where hostname="oldname";"

The hostname column should *ONLY* have your hostname and NULL as 
entries, if you have a combined BE/FE. Other hostnames should point to 
active slave backends or active frontends. These entries are never 
removed by myth, thus the 'you cannot use an old name, again' comments. 
Well actually you can, but it requires direct manipulation of the db.

delete from settings where hostname="no-longer-used-name";

At noted, this sort of database manipulation is dangerous: NSFWAF

Not Safe For Wife Appreciation Factor.

Some of the mythconverg tables are "safer" to touch, than others. 
'Settings' is a stand-alone, which is not tied to the other tables. 
However, touching say, the capturecard or cardinput tables is 
metaphorically entering into Darwin Award country.

G
		



More information about the mythtv-users mailing list