#!/bin/bash # Restoring 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 if [ $# -eq 0 ]; then echo "$0 'db1 db2' /var/backups/mysql daily|weekly backupcnt" 2>/dev/null exit 1 fi #DBS="information_schema mysql phpmyadmin cacti mythconverg" DBS="$1" DEST="${2:-/var/backups/mysql}" TYPE="${3:-daily}" KEEP="${4:-14}" DEBIAN="--defaults-extra-file=/etc/mysql/debian.cnf" OPTIONS="--all --complete-insert --extended-insert --quick --quote-names --lock-tables" mkdir -p "$DEST" for DBNAME in $DBS do BACKUP="$DEST/$DBNAME.$TYPE.sql.gz" /usr/bin/mysqlcheck $DEBIAN -s $DBNAME /usr/bin/savelog -c $KEEP -l -n -q $BACKUP /usr/bin/mysqldump $DEBIAN $OPTIONS $DBNAME | gzip > $BACKUP echo "$DBNAME checked and backed up." /usr/bin/logger -p daemon.info -i -t${0##*/} "$DBNAME checked and backed up." done # Also considering running /var/local/src/mythtv_contrib/optimize_mythdb.pl