(solved) No more mysql backups?

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

(solved) No more mysql backups?

Post by wesnewell »

Not sure when this happened, but was looking at the db backup dir and noticed the last one was 4 months old. I used to get weekly backups iirc. Not sure what happened. Don't remember when I upgraded to mythtv V30. Checked backend setup and disable backups isn't checked so don't know what's going on. Nothing I could find in backend log. Where to start looking for problem. I upgraded from 29.1 to V30 around the time they stopped iirc.
Last edited by wesnewell on Thu Apr 11, 2019 5:47 am, edited 2 times in total.
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
User avatar
pgbennett
Developer
Posts: 504
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: No more mysql backups?

Post by pgbennett »

The "disable backups" in setup is only to disable backups during upgrades, so that is not relevant to your problem.

There is no automatic backup mechanism in MythTV. The Ubuntu MythTV package installs a cron job to do a weekly backup. The package creates a file /etc/cron.weekly/mythtv-database to do that. I suggest you check that file and see whether the process is running.
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: No more mysql backups?

Post by wesnewell »

Well, it's there, but it was modified in Jan. by something. Not me. Here it is.
wes@mythfe0:~$ cat /etc/cron.weekly/mythtv-database
#!/bin/sh
# /etc/cron.weekly/mythtv-database script - check and backup mythconverg tables
# Copyright 2005/12/02 2006/10/08 Paul Andreassen
# 2010 Mario Limonciello

set -e -u

DBNAME="mythconverg"
DEBIAN="--defaults-extra-file=/etc/mysql/debian.cnf"

/usr/bin/mysqlcheck $DEBIAN -s $DBNAME

if [ -e "/etc/default/mythtv-backend" ]; then
. /etc/default/mythtv-backend
fi

if [ "$USER" = "" ]; then
CMDPREFIX=""
else
CMDPREFIX="sudo -u $USER"
fi

$CMDPREFIX /usr/share/mythtv/mythconverg_backup.pl

/usr/bin/logger -p daemon.info -i -t${0##*/} "$DBNAME checked and backed up."

# End of file.

wes@mythfe0:~$ ll /etc/cron.weekly
total 36
drwxr-xr-x 2 root root 4096 Apr 9 12:14 ./
drwxr-xr-x 159 root root 12288 Apr 10 10:30 ../
-rwxr-xr-x 1 root root 312 Dec 28 2014 0anacron*
-rwxr-xr-x 1 root root 723 Apr 7 2018 man-db*
-rwxr-xr-x 1 root root 623 Jan 26 09:47 mythtv-database*


This did backup the db.
wes@mythfe0:~$ sudo /usr/share/mythtv/mythconverg_backup.pl

wes@mythfe0:~$ ll /sdb/default
total 10596
drwxrwxrwx 2 wes wes 4096 Apr 10 15:02 ./
drwxrwxrwx 8 wes wes 4096 Dec 23 02:28 ../
-rw-r--r-- 1 root root 10840893 Apr 10 15:02 mythconverg-1350-20190410150239.sql.gz

Any quick thoughts?
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: No more mysql backups?

Post by bill6502 »

Hi,

Your test implies that /etc/default/mythtv-backend doesn't exist (or it doesn't have USER=...) in it.
If that's not the case, I'd re-run as CMDPREFIX would be set.

Try running the cron script directly: sudo /etc/cron.weekly/mythtv-database
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: No more mysql backups?

Post by wesnewell »

The script runs fine and creates the backup.
wes@mythfe0:~$ sudo /etc/cron.weekly/mythtv-database
[sudo] password for wes:
wes@mythfe0:~$ ll /sdb/default
total 21152
drwxrwxrwx 2 wes wes 4096 Apr 10 20:39 ./
drwxrwxrwx 8 wes wes 4096 Dec 23 02:28 ../
-rw-r--r-- 1 root root 10840893 Apr 10 15:02 mythconverg-1350-20190410150239.sql.gz
-rw-r--r-- 1 root root 10808841 Apr 10 20:39 mythconverg-1350-20190410203908.sql.gz
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: No more mysql backups?

Post by bill6502 »

Thanks. But how 'bout the contents of /etc/default/mythtv-backend.

When run from the command line, $USER will have a value, "root" in the tests
above.

But when run out of cron, $USER will be empty. Since I don't have that file,
I don't know if USER is set in it. Looking at system logs may help. journalctl --since today
(for example) or /var/log/syslog|cron.log.

I <think> the intent was to be able to set USER to mythtv, but don't know.
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: No more mysql backups?

Post by wesnewell »

I don't have a /etc/default/mythtv-backend file either. Did I ever? Don't know. Don't know why that script even checks for it. Aren't all cron jobs run as root? I think I'll just take all that out of the script and see what happens.
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: No more mysql backups?

Post by wesnewell »

I copied the modified file to cron.daily, so should know it it works tomorrow. just changed the below.
# if [ "$USER" = "" ]; then
CMDPREFIX=""
# else
# CMDPREFIX="sudo -u $USER"
# fi
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
User avatar
bill6502
Developer
Posts: 2323
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: No more mysql backups?

Post by bill6502 »

Agreed, cron jobs are run by the user defined in /etc/crontab, most likely root,
or as modified. However, non-hourly jobs are most likely run by anacron.

There may be an /etc/anacrontab file on your host.

If you're running systemd, you could try these 2:

Code: Select all

$ journalctl --unit anacron | grep cron.weekly # to see if it's logging anything
...
Mar 31 07:41:08 mc0 anacron[17560]: Job `cron.weekly' terminated (mailing output)
...
$ systemctl status anacron.service # to see if it's even running
wesnewell
Senior
Posts: 731
Joined: Mon Jun 23, 2014 6:54 pm
Location: Wylie TX, USA
United States of America

Re: No more mysql backups?

Post by wesnewell »

Yep, anacron just ran the modified mythtv-backup a few minutes ago and I've got a db backup. just need to remove the one in daily and I should be good to go. I'm wondering how many others this has happened to. I didn't notice it not working for a few months as I just stumbled across it. Since I do a system backup every week, I don't really need a db backup often.
root@mythfe0:/home/wes# systemctl status anacron.service
● anacron.service - Run anacron jobs
Loaded: loaded (/lib/systemd/system/anacron.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2019-04-11 00:11:12 CDT; 26min ago
Docs: man:anacron
man:anacrontab
Process: 775 ExecStart=/usr/sbin/anacron -dsq (code=exited, status=0/SUCCESS)
Main PID: 775 (code=exited, status=0/SUCCESS)

Apr 11 00:05:59 mythfe0 anacron[775]: Will run job `cron.daily' in 5 min.
Apr 11 00:05:59 mythfe0 anacron[775]: Jobs will be executed sequentially
Apr 11 00:10:58 mythfe0 anacron[775]: Job `cron.daily' started
Apr 11 00:10:58 mythfe0 anacron[2007]: Updated timestamp for job `cron.daily' to 2019-04-11
Apr 11 00:10:58 mythfe0 cracklib[2046]: no dictionary update necessary.
Apr 11 00:11:05 mythfe0 mythtv-database[2437]: mythconverg checked and backed up.

Just wondering what replaced the mythtv-backup file back in Jan., but not going to worry about it.
BE/FE-Asrock AB350 Pro Ryzen 3 3200G, 6 atsc tuners. FE's-GF8200's Athlon II, Ryzen 3 2200G. Mythtv user since 2005.
Post Reply