[mythtv-users] mythtv v30 mythtv-database backup

Tim Pletcher pletchtd at gmail.com
Sun Jan 27 16:20:53 UTC 2019


On Sun, Jan 27, 2019 at 6:36 AM James Abernathy <jfabernathy at gmail.com>
wrote:

> When I upgraded from v29.1 to v30 I got a question during the upgrade
> that asked about the cron.weekly job mythtv-database. It asked about
> keeping the current one or installing the packager maintained one. For
> some reason I decided replace mine with the packager's maintained one. I
> wasn't concerned since I've been using a different daily script to
> check, optimize and backup mythconverg.
>
> So Sunday morning early I see and error:
>
> /etc/cron.weekly/mythtv-database:
> /etc/cron.weekly/mythtv-database: 17: /etc/cron.weekly/mythtv-database:
> USER: parameter not set
> run-parts: /etc/cron.weekly/mythtv-database exited with return code 2
>
> I'm not sure if this is problem for others. I see this error because all
> cron and anacron errors and messages are emailed to me.
>

I had the same issue occur this morning with the cron.weekly job.  The old
file was not in /etc/cron.weekly but i have backups of the original thanks
to btrfs snapshotting.

Comparing the two, the new cron job file has some logic that attempts to
set the $USER variable by reading out the 'mythtv-backend' file in
/etc/default if the file exists.  I don't have this file in my installation
and the if/then/else fall-back logic doesn't seem to work properly as it
appears $USER isn't set to "" as expected if the file doesn't exist.

*old file:*
#!/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
/usr/share/mythtv/mythconverg_backup.pl
/usr/bin/logger -p daemon.info -i -t${0##*/} "$DBNAME checked and backed
up."
# End of file.

*new file:*
#!/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.

For now, I just added a new line to the new cron.weekly job that explicitly
sets user to mythtv which allows the cron job to complete. I had never
noticed before but the database backups made with the old job are owned by
root while the new ones are owned by mythtv which makes sense and is
probably preferred.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20190127/9969bba7/attachment.html>


More information about the mythtv-users mailing list