[mythtv-users] Backing up mysql database.

Marc drayson at net1plus.com
Sat Sep 8 23:36:06 UTC 2007


-----Original Message-----
From: mythtv-users-bounces at mythtv.org
[mailto:mythtv-users-bounces at mythtv.org] On Behalf Of Marc
Sent: Saturday, September 08, 2007 7:11 PM
To: 'Discussion about mythtv'
Subject: Re: [mythtv-users] Backing up mysql database.

-----Original Message-----
From: mythtv-users-bounces at mythtv.org
[mailto:mythtv-users-bounces at mythtv.org] On Behalf Of sdkovacs
Sent: Wednesday, September 05, 2007 12:02 PM
To: Discussion about mythtv
Subject: Re: [mythtv-users] Backing up mysql database.

On 9/5/07, clemens at dwf.com <clemens at dwf.com> wrote:
> Is there any advantage in using one of the mysql backup programs over
> just taring up /var/lib/mysql/mysql and /var/lib/mysql/mythconverg ?

The advantages have already been mentioned in this thread, and in case
others are interested, 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. Additionally, the cp statement at the end of the script
copies the db dump to another physical disk in case of a root disk
crash.
Edit the script as needed.

#! /bin/bash
#
# Created on 3/22/2006 by sdkovacs
# Script: mythbackup
#
#
#
#
########################################################
BACKFILE="/home/mythtv/mythbackup.`date +%a`.sql.gz"


mysqldump -u mythtv -pmythtv mythconverg -c | gzip -c > ${BACKFILE}
if [ $? -ne "0" ]
then
        echo "Mythtv database backup failed! Exiting..."
        exit 1
fi

cp ${BACKFILE} /videos/backup/myth
_______________________________________________
mythtv-users mailing list
mythtv-users at mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


Thanks. This is great. I have modified it to backup directly to my media
drive which is a raid 5 array without needing to cp to another drive.
Theoretically, I should never need it considering both my frontend and
backend mirrored OS drives. But it's better to have it then not.

Marc


_______________________________________________
mythtv-users mailing list
mythtv-users at mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users


Actually this is not working for me.
This is what I get when I run it.

gzip: invalid option -- e
Try `gzip --help' for more information.
mysqldump: Got errno 32 on write
Mythtv database backup failed! Exiting...

This is my version:

#! /bin/bash
#
# Created on 3/22/2006 by sdkovacs
# Updated on 9/8/2007 by Marc
# Script: mythbackup
#
#
#
########################################################
BACKFILE="/record/mythbackup.`date +%a`.sql.gz"


mysqldump -u mythtv -pmythtv mythconverg -c | gzip -c > ${BACKFILE} if [ $?
-ne "0" ] then
        echo "Mythtv database backup failed! Exiting..."
        exit 1
fi

As you can see all I did was removed the cp command and modified the
location of the backup.
The issue seems to pertain to the If section of the script.
If I move the if statement off the 1st line the backup runs but I get the
following.

/usr/local/bin/mythbackup: line 17: syntax error near unexpected token `fi'
/usr/local/bin/mythbackup: line 17: `fi'

Any help? I would just delete the if statement but it would be good to know
if the backup failed.

Marc




More information about the mythtv-users mailing list