Mailing List Archive

Moving my MythDB
Does anyone store their Myth DB somewhere other than where Myth puts it?

How would I do that?

--
A little of Jerome's MythTV World: http://mythtv.HeIsJerome.com


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On Tue, 10 May 2022 21:04:27 -0600, you wrote:

>Does anyone store their Myth DB somewhere other than where Myth puts it?
>
>How would I do that?

The location of the mythconverg database is determined by MySQL or
MariaDB, not MythTV. As far as I know, neither has an option to store
the databases anywhere other than one location - if you want to move
the files somewhere else, you have to move the entire set of
databases, not just the mythconverg database. The location for Ubuntu
is /var/lib/mysql. This location is set by the "datadir" option in
the config files under /etc/mysql, and there are various pages on the
web that can tell you how to move the entire directory. You may need
to also change apparmor settings if you move it.

It is possible to store the database on a completely different machine
- MythTV is happy to use a remote database server.

So why do you want to move the database?
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On Tuesday, May 10, 2022 10:18:16 P.M. MDT Stephen Worthington wrote:
> On Tue, 10 May 2022 21:04:27 -0600, you wrote:
> >Does anyone store their Myth DB somewhere other than where Myth puts it?
> >
> >How would I do that?
>
> The location of the mythconverg database is determined by MySQL or
> MariaDB, not MythTV. As far as I know, neither has an option to store
> the databases anywhere other than one location - if you want to move
> the files somewhere else, you have to move the entire set of
> databases, not just the mythconverg database. The location for Ubuntu
> is /var/lib/mysql. This location is set by the "datadir" option in
> the config files under /etc/mysql, and there are various pages on the
> web that can tell you how to move the entire directory. You may need
> to also change apparmor settings if you move it.
>
> It is possible to store the database on a completely different machine
> - MythTV is happy to use a remote database server.
>
> So why do you want to move the database?

I'm doing some "infrastructure" janitorial work on all my machines and noticed
that my "pretty-important" database is buried in /var/lib/mysql and that's
bugging the program/data separation that I usually go for. I haven't cared for
15+ years, but now that I do, I do. :)

--
A little of Jerome's MythTV World: http://mythtv.HeIsJerome.com


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On Tue, 10 May 2022 23:01:04 -0600, you wrote:

>On Tuesday, May 10, 2022 10:18:16 P.M. MDT Stephen Worthington wrote:
>> On Tue, 10 May 2022 21:04:27 -0600, you wrote:
>> >Does anyone store their Myth DB somewhere other than where Myth puts it?
>> >
>> >How would I do that?
>>
>> The location of the mythconverg database is determined by MySQL or
>> MariaDB, not MythTV. As far as I know, neither has an option to store
>> the databases anywhere other than one location - if you want to move
>> the files somewhere else, you have to move the entire set of
>> databases, not just the mythconverg database. The location for Ubuntu
>> is /var/lib/mysql. This location is set by the "datadir" option in
>> the config files under /etc/mysql, and there are various pages on the
>> web that can tell you how to move the entire directory. You may need
>> to also change apparmor settings if you move it.
>>
>> It is possible to store the database on a completely different machine
>> - MythTV is happy to use a remote database server.
>>
>> So why do you want to move the database?
>
>I'm doing some "infrastructure" janitorial work on all my machines and noticed
>that my "pretty-important" database is buried in /var/lib/mysql and that's
>bugging the program/data separation that I usually go for. I haven't cared for
>15+ years, but now that I do, I do. :)

It is not really a problem as you can not just put the database
somewhere under /home and automatically back it up along with all the
normal data there. The databases need to be backed up properly - just
making a copy of the files does not work.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
> On 11 May 2022, at 1:18 pm, Stephen Worthington <stephen_agent@jsw.gen.nz> wrote:
>
> On Tue, 10 May 2022 23:01:04 -0600, you wrote:
>
>> On Tuesday, May 10, 2022 10:18:16 P.M. MDT Stephen Worthington wrote:
>>> On Tue, 10 May 2022 21:04:27 -0600, you wrote:
>>>> Does anyone store their Myth DB somewhere other than where Myth puts it?
>>>>
>>>> How would I do that?
>>>
>>> The location of the mythconverg database is determined by MySQL or
>>> MariaDB, not MythTV. As far as I know, neither has an option to store
>>> the databases anywhere other than one location - if you want to move
>>> the files somewhere else, you have to move the entire set of
>>> databases, not just the mythconverg database. The location for Ubuntu
>>> is /var/lib/mysql. This location is set by the "datadir" option in
>>> the config files under /etc/mysql, and there are various pages on the
>>> web that can tell you how to move the entire directory. You may need
>>> to also change apparmor settings if you move it.
>>>
>>> It is possible to store the database on a completely different machine
>>> - MythTV is happy to use a remote database server.
>>>
>>> So why do you want to move the database?
>>
>> I'm doing some "infrastructure" janitorial work on all my machines and noticed
>> that my "pretty-important" database is buried in /var/lib/mysql and that's
>> bugging the program/data separation that I usually go for. I haven't cared for
>> 15+ years, but now that I do, I do. :)
>
> It is not really a problem as you can not just put the database
> somewhere under /home and automatically back it up along with all the
> normal data there. The databases need to be backed up properly - just
> making a copy of the files does not work.

Use mythconverg_backup.pl Then you can put the backup where you like.

James
Re: Moving my MythDB [ In reply to ]
>
> On Wed, 11 May 2022 at 08:00, James <jam@tigger.ws> wrote:
>
Use mythconverg_backup.pl Then you can put the backup where you like.
>

If backups are the issue here (although I think the OP really wants
separation of data from the system), then it's likely they are already
being made if a packaged version of MythTV is installed. The Ubuntu PPA,
for example, runs a backup via /etc/cron.weekly/mythtv-database which in
turn runs mythconverg_backup.pl. Where that ends up with the PPA I'm not
100% sure as I am personally using an old Debian 0.28 installation, but
it's likely there will be mythconverg.sql.* files in /var/backup which can
be safely backed up. If they are stored elsewhere, hopefully somebody else
can confirm the location. If more frequent backups are wanted, you could
run the backup script in /etc/cron.daily instead.

The other option (moving the data to separate it) could be done by shutting
down mythtv-backend and mysql services, moving the mysql directory from
from /var/lib to say, /home and then either reconfiguring mysql or using a
symbolic link, but as mentioned previously, AppArmor config might need
adjusting in that case depending on your distribution.

Cheers, Ian
Re: Moving my MythDB [ In reply to ]
On Wed, 11 May 2022 10:33:52 +0100, you wrote:

>>
>> On Wed, 11 May 2022 at 08:00, James <jam@tigger.ws> wrote:
>>
>Use mythconverg_backup.pl Then you can put the backup where you like.
>>
>
>If backups are the issue here (although I think the OP really wants
>separation of data from the system), then it's likely they are already
>being made if a packaged version of MythTV is installed. The Ubuntu PPA,
>for example, runs a backup via /etc/cron.weekly/mythtv-database which in
>turn runs mythconverg_backup.pl. Where that ends up with the PPA I'm not
>100% sure as I am personally using an old Debian 0.28 installation, but
>it's likely there will be mythconverg.sql.* files in /var/backup which can
>be safely backed up. If they are stored elsewhere, hopefully somebody else
>can confirm the location. If more frequent backups are wanted, you could
>run the backup script in /etc/cron.daily instead.
>
>The other option (moving the data to separate it) could be done by shutting
>down mythtv-backend and mysql services, moving the mysql directory from
>from /var/lib to say, /home and then either reconfiguring mysql or using a
>symbolic link, but as mentioned previously, AppArmor config might need
>adjusting in that case depending on your distribution.
>
>Cheers, Ian

The default location for backups on a Ubuntu system is
/var/lib/mythtv/db_backups. You can set a storagegroup to change the
backup location, or alter it on the mythconverg_backup.pl command
line.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
Hoi Stephen,

Wednesday, May 11, 2022, 12:05:00 PM, you wrote:

> On Wed, 11 May 2022 10:33:52 +0100, you wrote:

>>>
>>> On Wed, 11 May 2022 at 08:00, James <jam@tigger.ws> wrote:
>>>
>>Use mythconverg_backup.pl Then you can put the backup where you like.
>>>
>>
>>If backups are the issue here (although I think the OP really wants
>>separation of data from the system), then it's likely they are already
>>being made if a packaged version of MythTV is installed. The Ubuntu PPA,
>>for example, runs a backup via /etc/cron.weekly/mythtv-database which in
>>turn runs mythconverg_backup.pl. Where that ends up with the PPA I'm not
>>100% sure as I am personally using an old Debian 0.28 installation, but
>>it's likely there will be mythconverg.sql.* files in /var/backup which can
>>be safely backed up. If they are stored elsewhere, hopefully somebody else
>>can confirm the location. If more frequent backups are wanted, you could
>>run the backup script in /etc/cron.daily instead.
>>
>>The other option (moving the data to separate it) could be done by shutting
>>down mythtv-backend and mysql services, moving the mysql directory from
>>from /var/lib to say, /home and then either reconfiguring mysql or using a
>>symbolic link, but as mentioned previously, AppArmor config might need
>>adjusting in that case depending on your distribution.
>>
>>Cheers, Ian

> The default location for backups on a Ubuntu system is
> /var/lib/mythtv/db_backups. You can set a storagegroup to change the
> backup location, or alter it on the mythconverg_backup.pl command
> line.
> _______________________________________________

If the issue is separation from the system, you can consider using
multiple volumes. I myself use lvm volumes for home, usr, var, opt and
the different tmp directories. And more if needed, like the
recordings. I can resize any of the volumes at need and even add a new
disk to the volume group or migrate the group to a bigger disk. All
without disturbing the system

You can for instance put /var/lib/mysql on its own volume. Thus it
cannot flood the system. Also you can mount volumes that do not need
writing as read-only.

You even can put the root on lvm, but that is a little bit more
tricky.

Tot mails,
Hika mailto:hikavdh@gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On Wednesday, May 11, 2022 6:38:06 A.M. MDT Hika van den Hoven wrote:

> You can for instance put /var/lib/mysql on its own volume. Thus it
> cannot flood the system. Also you can mount volumes that do not need
> writing as read-only.

This is what I'm wanting to know, not to another volume, but not in /var/lib,
and thought some MythTV Merlin had done it already before I put it on my To
Research list. Something I'd like to know for other MySQL databases too.

I already do a mythconverg_backup.pl every morning and tuck that away (date-
stamped) on a couple other machines.


--
A little of Jerome's MythTV World: http://mythtv.HeIsJerome.com


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On 5/11/22 13:22, Jerome Yuzyk via mythtv-users wrote:
> On Wednesday, May 11, 2022 6:38:06 A.M. MDT Hika van den Hoven wrote:
>
>> You can for instance put /var/lib/mysql on its own volume. Thus it
>> cannot flood the system. Also you can mount volumes that do not need
>> writing as read-only.
>
> This is what I'm wanting to know, not to another volume, but not in /var/lib,
> and thought some MythTV Merlin had done it already before I put it on my To
> Research list. Something I'd like to know for other MySQL databases too.
>
> I already do a mythconverg_backup.pl every morning and tuck that away (date-
> stamped) on a couple other machines.

Ignore everything below if you truly want to have *only* the MythTV DB stored
elsewhere and the remaining DB(s) left under /var/lib/mysql or yet another
place.

Stephen had the answer. Here's my (working) configuration. And the steps
I recall doing. Stopped the backend and MySQL before starting.

If you believe in: https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf,
section 5.8.1 suggests /var/lib/mysql is the proper place. I saw the note at
the bottom of page 33 and started in: /srv.

I decided to put ALL MySQL files under /srv/db, maybe /src/mysql would be
more correct:

Create an App Armor local configuration for mysqld:

$ cat /etc/apparmor.d/local/usr.sbin.mysqld
/srv/db/ r,
/srv/db/** rwk,

sudo systemctl restart apparmor.service # I <think> this is required, but
don't remember. Did it in 12/2013.

Update MySQL to look in /srv/db, not /var/lib/mysql:

$ sudo grep --recursive datadir /etc/mysql
/etc/mysql/mysql.conf.d/mythtv.cnf:datadir = /srv/db
/etc/mysql/mysql.conf.d/mysqld.cnf:# datadir = /var/lib/mysql

That leaves the default untouched, because I don't want the MySQL/MariaDB package
manager's changes to change my selection. Note that I build from
source, so I don't have to worry about mythtv.cnf being overwritten
by any MythTV packages. Probably safer to use another .cnf name for
datadir.

Then I *copied* the entire MySQL DB, verified ALL directory and file
permissions and owner:group and restarted mysql. Probably with:

cd /var/lib/mysql
cp --preserve --recursive . /srv/db

Again, this was 9 years ago, test, test, test.

Restarted MySQL. Logged in to the DB just to be sure it was working.
Restarted the backend when it was.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
Hoi Jerome,

Wednesday, May 11, 2022, 8:22:06 PM, you wrote:

> On Wednesday, May 11, 2022 6:38:06 A.M. MDT Hika van den Hoven wrote:

>> You can for instance put /var/lib/mysql on its own volume. Thus it
>> cannot flood the system. Also you can mount volumes that do not need
>> writing as read-only.

> This is what I'm wanting to know, not to another volume, but not in /var/lib,
> and thought some MythTV Merlin had done it already before I put it on my To
> Research list. Something I'd like to know for other MySQL databases too.

> I already do a mythconverg_backup.pl every morning and tuck that away (date-
> stamped) on a couple other machines.


Why? What do you hope to achieve by putting the database in a another
place in the directory tree? Other then the fact itself. And then where?

Anyway all mysql/mariadb databases WILL be in the same location. The
only way to separate on the same machine is to run multiple
independent instances, isolated from each other. This means among
other things different ports or multiple ip-addresses.
I do not know if that is at all possible, but it would be a challenge.



Tot mails,
Hika mailto:hikavdh@gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On Wed, May 11, 2022 at 12:22:06PM -0600, Jerome Yuzyk via mythtv-users wrote:
> On Wednesday, May 11, 2022 6:38:06 A.M. MDT Hika van den Hoven wrote:
> > You can for instance put /var/lib/mysql on its own volume. Thus it
> > cannot flood the system. Also you can mount volumes that do not need
> > writing as read-only.
>
> This is what I'm wanting to know, not to another volume, but not in /var/lib,
> and thought some MythTV Merlin had done it already before I put it on my To
> Research list. Something I'd like to know for other MySQL databases too.

You can also make /var/lib/mysql be a symlink to a directory anywhere you
would like in the filesystem. (If you have other databases, they would be
moved as well as mythtv.)

marcus hall
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On 12/05/2022 09:13, marcus hall wrote:
> On Wed, May 11, 2022 at 12:22:06PM -0600, Jerome Yuzyk via mythtv-users wrote:
>> On Wednesday, May 11, 2022 6:38:06 A.M. MDT Hika van den Hoven wrote:
>>> You can for instance put /var/lib/mysql on its own volume. Thus it
>>> cannot flood the system. Also you can mount volumes that do not need
>>> writing as read-only.
>> This is what I'm wanting to know, not to another volume, but not in /var/lib,
>> and thought some MythTV Merlin had done it already before I put it on my To
>> Research list. Something I'd like to know for other MySQL databases too.
> You can also make /var/lib/mysql be a symlink to a directory anywhere you
> would like in the filesystem. (If you have other databases, they would be
> moved as well as mythtv.)

You could turn on |--innodb-file-per-table and then move the tables you
want to a different location and symlink.
Old solution when we had slower, small disks, spread the IO over
different spindles.
also isl files.

Not sure what is wrong with /var/lib/mysql though... :-)
|

--
'ooroo

Stinga...(:)-)
---------------------------------------------------
Email: stinga+mythtv@wolf-rock.com o
You need only two tools. o /////
A hammer and duct tape. If it /@ `\ /) ~
doesn't move and it should use > (O) X< ~ Fish!!
the hammer. If it moves and `\___/' \) ~
shouldn't, use the tape. \\\
---------------------------------------------------

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
On Thu, May 12, 2022 at 3:55 AM stinga <stinga+mythtv@wolf-rock.com> wrote:

> Not sure what is wrong with /var/lib/mysql though... :-)

/var/lib/<package> is considered FSH compliant,
although not everyone agrees with the FSH, and
containerized solutions and immutable OS images
have changed the landscape to what is stored
where. To each, their own.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Moving my MythDB [ In reply to ]
Thank you to Bill Meek for your reply - I didn't see it here because my Mail
ISP has been flagging _some_ MythTV posts, for no discernible reason, as SPAM,
and it never reached my mailer. Now I know it can be done, I have a place to
start from.

On Wednesday, May 11, 2022 7:13:24 P.M. MDT marcus hall wrote:
> You can also make /var/lib/mysql be a symlink to a directory anywhere you
> would like in the filesystem. (If you have other databases, they would be
> moved as well as mythtv.)

I see that symlinks are allowed in the FSH link Bill sent.

I can also see this from the link:

An application (or a group of inter-related applications) must use a
subdirectory of /var/lib for its data.

So it's kinda built in to the MySQL environment because of the FSH standard.

But, symlinks may just be The Unix Way to deal with this.


--
A little of Jerome's MythTV World: http://mythtv.HeIsJerome.com


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Moving my MythDB [ In reply to ]
> Not sure what is wrong with /var/lib/mysql though... :-)

/var/lib/mysql may be safe on most distros, but with Fedora, the /var
tree or partition gets wiped during a distro install *even if you are
using custom partitioning and do not select for that to happen.*

Been there, had it happen.

So all of my mysql databases live on another partition (/misc/mysql) and
/var/lib/mysql is a symlink to there.

With /home and /misc and /usr/sbin on their own partitions, an install
or upgrade can re-format the "/" and /var partitions without disturbing
the data I want to keep. The symlink is created as a setup portion
/etc/rc.d/rc.local which is normally commented out, and run only once on
the install. (I do all of my upgrades as actual installs, since the data
is protected from being erased).

Geoff




_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org