[mythtv-users] Mythbuntu - database not backing up

Nick Rout nick.rout at gmail.com
Tue Feb 10 20:02:37 UTC 2009


On Wed, Feb 11, 2009 at 8:03 AM, John Drescher <drescherjm at gmail.com> wrote:
> On Tue, Feb 10, 2009 at 1:58 PM, Nick Rout <nick.rout at gmail.com> wrote:
>> Had a database go wrong yesterday, luckily the optimize script fixed it (phew).
>>
>> But it brought to my attention that database backups don't seem to be
>> working. I have a series of files in /var/backups,
>>
>> nick at media:/var/backups$ ls -l /var/backups/mythconverg.sql.gz*
>> -rw-r--r-- 1 root root 331 2009-02-08 06:47 /var/backups/mythconverg.sql.gz
>> -rw-r--r-- 1 root root 329 2009-02-01 06:47 /var/backups/mythconverg.sql.gz.0
>> -rw-r--r-- 1 root root 329 2009-01-25 06:47 /var/backups/mythconverg.sql.gz.1
>> -rw-r--r-- 1 root root 329 2009-01-18 06:47 /var/backups/mythconverg.sql.gz.2
>> -rw-r--r-- 1 root root 329 2009-01-11 06:47 /var/backups/mythconverg.sql.gz.3
>> -rw-r--r-- 1 root root 329 2009-01-04 06:47 /var/backups/mythconverg.sql.gz.4
>> -rw-r--r-- 1 root root 329 2008-12-28 06:48 /var/backups/mythconverg.sql.gz.5
>> -rw-r--r-- 1 root root 329 2008-12-21 06:47 /var/backups/mythconverg.sql.gz.6
>>
>>
>> all of which (when unzipped) say:
>>
>> -- MySQL dump 10.11
>> --
>> -- Host: localhost    Database: mythconverg
>> -- ------------------------------------------------------
>> -- Server version       5.0.51a-3ubuntu5.4
>>
>> /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
>> /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
>> /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
>> /*!40101 SET NAMES utf8 */;
>> /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
>> /*!40103 SET TIME_ZONE='+00:00' */;
>> /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
>> /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
>> */;
>> /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
>> /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
>>
>>
>> and thats it.
>>
>> What am i missing?
>>
> How are you running this?
>
> Here is all I do:
>
> jmd0 ~ # cat /etc/cron.daily/mythtv.cron
> #! /bin/sh
> mkdir -p /var/backup/mythtv
> mysqlrepair --all-databases
> /usr/bin/mysqldump -u mythtv -pmythtv mythconverg | /bin/bzip2 -c >
> /var/backup/mythtv/mythtv-`date +%F`.bz2

Distro is mythbuntu (per subject line).

script is /etc/cron.d/cron.weekly/  (seems to be debian/ubuntu provided)

#!/bin/sh
# /etc/cron.weekly/mythtv-database script - check and backup mythconverg tables
# Copyright 2005/12/02 2006/10/08 Paul Andreassen

# Deleting the MySQL database:
# NOTE: Performing this step will remove the entire database. You will lose all
# of your settings and will need to re-run the /usr/share/mythtv/sql/mc.sql
# script to setup the database structure before running the setup program.
# $ mysql -u mythtv -p 'drop database mythconverg'
# To restore: (assuming that you've dropped the database)
# $ mysql -u mythtv -p 'create database mythconverg'
# $ zcat /var/backups/mythconverg.sql.gz | mysql -u mythtv -p mythconverg
# see http://mythtv.org/docs/mythtv-HOWTO.html#toc23.5

set -e -u

if [ -f /etc/mythtv/mysql.txt ]; then
  . /etc/mythtv/mysql.txt
fi

DBNAME="mythconverg"
BACKUP="/var/backups/$DBNAME.sql.gz"
DEBIAN="--defaults-extra-file=/etc/mysql/debian.cnf"
OPTIONS="--all --complete-insert --extended-insert --quick
--quote-names --lock-tables"

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

/usr/bin/savelog -c 7 -l -n -q $BACKUP

/usr/bin/mysqldump $DEBIAN $OPTIONS $DBNAME | gzip > $BACKUP

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

I'll take a look at the script suggested by Michael Dean.


More information about the mythtv-users mailing list