Link to home
Create AccountLog in
Avatar of jballiet3
jballiet3

asked on

mysqldump error 2013: lost connection to mysql

Anybody know how to resolve this issue....

/etc/cron.daily/mysqlbackup:

mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `Attachments` at row: 81506
ASKER CERTIFIED SOLUTION
Avatar of glcummins
glcummins
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of chigs20
chigs20

To get more debugging information from cron you can specify the following:

0 1 * * * /path_to_directory/file_name.sh > /path_to_directory/file_name.out 2>&1

Also, how big is the database you're backing up?
What commands are you using in mysqldump? (ex:  --opt -C )
Avatar of jballiet3

ASKER

#!/bin/sh
#
# mysqlbackup
#
# Script to make daily dumps of MySQL database and RT (if installed)
#
BACKUPDIR=/backup/hq/replicated/mysql

# Backup MySQL
/usr/bin/mysqldump --single-transaction --quick --all-databases --default-character-set=latin1
 > ${BACKUPDIR}/`hostname`-`date +%C%y%m%d`-mysql-all.sql


# Backup RT, if present
if [ -d /usr/local/rt ]; then
    tar cf ${BACKUPDIR}/`hostname`-`date +%C%y%m%d`-rtconfig.tgz -C /usr/local/rt etc
fi

# Clean out old dumps
find ${BACKUPDIR} -ctime +5 -exec rm {} \;
database size is 32107M
Your database is over 30 gigabytes in size? That would definitely take a while to back up. I would again suggest that you examine the other cron scripts to see what runs. That will help you determine what is causing MySQL to stop while your backup is running.
I made an error. The actual database size is 12Gig
The same comment still stands. Your database is 12 GB. Presumably this takes a long time, perhaps hours, to back up. Have you checked your other scheduled tasks to see what may be interfering? I still have not seen you comment on that.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
How would I do this with rsync...

BACKUPDIR=/backup/hq/replicated/mysql

# Backup MySQL
/usr/bin/mysqldump --single-transaction --quick --all-databases --default-character-set=latin1 > ${BACKUPDIR}/`hostname`-`date +%C%y%m%d`-mysql
-all.sql
here is the manual for rsync...
http://www.hmug.org/man/1/rsync.php

what you need to do is stop a slave and copy the files directly.
You can also use scp.