Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Better (safer) way to back up MySQL databases...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Better (safer) way to back up MySQL databases...
Authored by: dnorman on Jan 12, '04 11:29:00AM
That's a bad way to backup a database - any open connections to the database and you're hooped. It's better to dump the data to a text file, and back that up.
% mysqldump -u username -p --quote-names -B databasename | gz > ~/backups/databasename.sql.gz
Chance username to your mysql user, and databasename (both places) to the name of the database you want to back up. Here, I assume you have a directory named "backups" in your home directory. Change that to anything you want. This will create a nicely gzipped archive of the sql dump, which can be easily backed up, ftp'ed, and of course restored. It's very straightforward to add this to a crontab to run at say 2am every day. That's what I have on all of my servers. And crontab items on other machines to grab the archive every morning at 3am...

[ Reply to This | # ]