[mythtv-users] Backing up mysql database.
Tom Metro
tmetro+mythtv-users at gmail.com
Sat Sep 8 22:11:24 UTC 2007
sdkovacs wrote:
> ...here is a short script i run daily in cron to
> backup the mythconverg database. It automatically overwrites the
> backup from the previous week so you always will have 7 days of
> backups.
Nicely done.
> Edit the script as needed.
Attached is a slightly modified version that pulls the database
credentials from /etc/mythtv/mysql.txt and makes a few other tweaks.
-Tom
#! /bin/bash
# Script: mythbackup
# based on a script by sdkovacs at gmail.com, 3/22/2006
########################################################
BACKUP_PATH=/data/backups/mythtv
# specify an optional secondary location for the backup
SECONDARY_PATH=/video/backups/mythtv
. /etc/mythtv/mysql.txt
BACKFILE="${BACKUP_PATH}/${DBName}.`date +%a`.sql.gz"
mysqldump -u ${DBUserName} -p${DBPassword} ${DBName} -c | gzip -c --best
> ${BACKFILE}
if [ $? -ne "0" ]
then
echo "Mythtv database backup failed!"
exit 1
fi
# store a second copy on a different drive
if [ "${SECONDARY_PATH}" != "" ]
then
cp ${BACKFILE} ${SECONDARY_PATH}
fi
More information about the mythtv-users
mailing list