Best way to back up mysql database

Chris Pratt eagletree at hughes.net
Tue Sep 30 23:12:47 UTC 2008


>
> I am just about to dive into Google in search of a solution, but  
> thought I would fire off a quick request, in case there is an  
> obvious solution that everyone uses. If there is, a name or URL  
> will do. I'll figure out the rest.
>
> Any hints much appreciated. Not going home until this is fixed...
>
>

Most certainly would want you to not not go home having
been there before. Here is a crude way to do this. Find an
elegant solution at leisure.

The downside is that you if you crash at the wrong time,
your job won't start for the next day. Be forewarned, then
you stop making backups. You just need to monitor your
atq. The gzip step should probably be part of a pipe
for efficiency. You could cron this to get around that.

I saw the response about repairing corruptions, REPAIR
TABLE has thus far kept me from ever reloading.

See man on date and use something other than %a to
generate a numeric date unique back, that would give
you numerous backups if you have the storage.

DATE=`date +%a`
#
echo $DATE
#
echo Backup Mysql database
mysqldump -h localhost -u YOURSQLUSERID -pYOURPASSWORD YOURDATABASE >/ 
usr/somedirectory/somefile_$DATE.backup
gzip -f /usr/somedirectory/somefile_$DATE.backup
/usr/bin/at -f /usr/somedirectory/mysqlbackup.sh midnight



More information about the freebsd-questions mailing list