[mythtv-users] Mythtv automatic database backup

James Abernathy jfabernathy at gmail.com
Sun Nov 24 16:22:05 UTC 2019


On Sun, Nov 24, 2019 at 10:31 AM Bill Meek <keemllib at gmail.com> wrote:

> On 11/24/19 8:39 AM, Doug Lytle wrote:
> > On 11/24/19 9:30 AM, Don Brett wrote:
> >> Does Mythtv do automatic database backups, or do I need to setup my own
> cron job?  Years ago, I thought it did it by itself.
> >
> >
> > cron job, mine is below; I compile from source, so paths will likely be
> different:
> >
> > 45 18 * * * /usr/local/share/mythtv/mythconverg_backup.pl --rotate 10
> --compress gzip
> >
> >
> > Doug
>
> The only automatic ones are done when the DB is upgraded. Unless "Disable
> automatic database backup"
> is set.
>
> There's also a Services API endpoint. If, for some reason, you wanted to
> start the backup from
> an app or different host/state/country/... It uses the settings in
> ~mythtv/.mythtv/backuprc.
>
> e.g. curl --header 'Accept:application/JSON' --request POST
> yourBackend:6544/Myth/BackupDatabase
>
> Returns: {"bool": "true"} if successful. It uses mythconverg_backup.pl if
> it can be found.
>
> --
> Bill
> _______________________________________________
>
> I got a suggestion many years ago from to do daily database backups and
also optimized the database. I think it was from Stephen Worthington (JSW).
I used his scripts modifying filenames and adding  a send mail message so
I'd know if it was working without having to login to check. It's setup a 2
separate script.
jim at mythbuntu:/etc/cron.daily$ cat mythtv-backup
#!/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

# JSW Modified for /etc/cron.daily backups to a network drive.

set -e -u

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

# Debug:
/usr/bin/logger -p daemon.info -i -t${0##*/} "Debug: $DBNAME cron.daily
checking started."

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

# Debug:
/usr/bin/logger -p daemon.info -i -t${0##*/} "Debug: $DBNAME cron.daily
checking finished, backup starting."

/usr/bin/nice -n 2 /usr/share/mythtv/mythconverg_backup_jsw.pl --directory
"/mnt/md1/samba/public/Backups/MythTV_db_backup/" --tempdir "/mnt/md1/tmp"

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

now="$(date)"
echo "$DBNAME checked and backed up on $now" | mail -s "$DBNAME checked and
backed up" jfabernathy at gmail.com

# End of file.
-------------------
jim at mythbuntu:/etc/cron.daily$ cat optimize_mythdb
#!/bin/sh

OPT_MYTHDB='/usr/share/doc/mythtv-backend/contrib/maintenance/
optimize_mythdb.pl'
LOG='/var/log/mythtv/optimize_mythdb.log'

# Debug:
/usr/bin/logger -p daemon.info -i -t${0##*/} "Debug: cron.daily
optimize_mythdb started."

echo "Started ${OPT_MYTHDB} on `date`" >> ${LOG}
${OPT_MYTHDB} >> ${LOG}
echo "Finished ${OPT_MYTHDB} on `date`" >> ${LOG}

# Debug:
/usr/bin/logger -p daemon.info -i -t${0##*/} "Debug: cron.daily
optimize_mythdb ended."
now="$(date)"
echo "cron.daily optimize_mythdb has been run on $now" | mail -s
"optimized_mythdb" jfabernathy at gmail.com

It's still works great on ubuntu 18.04 and mythtv v30

Jim A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20191124/560e5579/attachment.htm>


More information about the mythtv-users mailing list