mysql backup script
Steve Buehler
steve at ibapp.com
Tue Jun 15 13:04:00 UTC 2004
I am having a problem with a backup script that is written in a shell
(/bin/sh) script to backup my mysql databases. For some reason on any day
with an even number I get the following error:
MySQL could not be stopped, exiting...
It is really weird because it will run on odd number days without a
problem. Should I put some kind of a wait in the script after it stops the
mysqld and before it checks to make sure the pid file is still there? If
so, does anybody know how? I am not sure that that will solve the problem
though because it exits afterward and the mysql daemon is still running
without having to restart it. Below is the relevant part of the script.
The script is run from cron with this line
0 1 * * * /root/backup/backup.sh >/dev/null 2>&1
But since the logs do show it running, That shouldn't be the problem.
Thanks
Steve
######### Perform myisamchk
#mysqladmin -p$MYSQLPWD shutdown
/etc/rc.d/init.d/mysqld stop
if [ -f $mysqlpid ]; then
echo -e "MySQL could not be stopped, exiting... " >>
/tmp/backuplog$date
exit 1
else
echo -e "Checking MYI tables for all databases " >>
/tmp/backuplog$date
myisamchk --silent --force --fast --update-state -O key_buffer=64M \
-O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M \
/var/lib/mysql/*/*.MYI
fi
echo -e "Checks complete, starting MySQL " >> /tmp/backuplog$date
/etc/rc.d/init.d/mysqld restart
sleep 20
if [ ! -f $mysqlpid ]; then
echo -e "MySQL failed to start, exiting... " >> /tmp/backuplog$date
exit 1
fi
##########
More information about the redhat-list
mailing list