Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What's the best way to back up a MySQL server? I would like a method that doesn't require bringing down the server. Is something like InnoDB hot backup necessary, or can I just use the backup tools provided in the MySQL Administrator tools. What advantages does one offer over the other?

share|improve this question
add comment

7 Answers

up vote 11 down vote accepted

We use mysqldump, which works while MySQL is running. We started using mysqldump because it was the easiest to set up when our needs were small, and it seemed to meet those needs. Our databases have grown since then, but we haven't yet outgrown mysqldump. Whether it suits you will depend on the size of your databases, their usual operating load, and probably a bunch of other things.

share|improve this answer
    
mysqldump is great. Unlike the binary dumps of some other RDMS's, by default the files mysqldump generates are text files with full-fledged sql commands -- mostly CREATE TABLE statements and INSERTs for the rows. As simple text files, they can be manipulated, compressed or encrypted easily. –  nedm May 14 '09 at 2:37
3  
mysqldump breaks down when you have big databases, and/or when you rely on MyISAM. We have some 400G databases with a lot of indexes that needs to be rebuilt when importing the dump, so that a recovery from backup takes tree days. LVM snapshot gives a much better recovery time when you've outgrown mysqldump. –  Nils-Anders Nøttseter May 23 '09 at 7:22
add comment

take a look at xtrabackup from percona - it's interesting open source alternative to mysqlhotcopy for innodb databases.

you can read more about it here

share|improve this answer
add comment

Setup MySQL Replication. As a bonus you get a server to run heavy reporting jobs and mysqldump without affecting your main production db.

share|improve this answer
    
Remember that replication may be delayed and so not necessarily a point-in-time backup of your master. –  DavidM Jun 1 '09 at 18:14
2  
Replication isn't backup. If you accidentaly delete something in the master, the slave deletes it also. The slave is good to use mysqldump on though, because it won't affect your production server (as Dave mentioned). –  Martijn Heemels Dec 29 '09 at 15:07
add comment

have a look at this question on stackoverflow

Best practice for backing up a production MySQL database?

it covers this topic well

share|improve this answer
add comment

There is also a tool called mysqlhotcopy which I looked at once, and thought it held alot of promise - never used it though.

share|improve this answer
add comment

mysqldump can be used, but it will not guarantee a consistent dataset, unless you lock all of the tables for the duration of the dump. This will put the database in a read-only mode, but will ensure the dump is consistent.

You can lock the tables with the command:

FLUSH TABLES WITH READ LOCK;

And when you are finished you can release the lock with:

UNLOCK TABLES;
share|improve this answer
7  
mysqldump --single-transaction will ensure a consistent snapshot –  Dave Cheney May 14 '09 at 5:52
    
Thanks! I didn't know that. –  Brent May 14 '09 at 14:34
5  
--single-transaction only works when all your tables are InnoDB. The MyISAM tables don't support transactions. –  Nils-Anders Nøttseter May 23 '09 at 7:13
add comment

The easiest way is to simply use the mysqldump command.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.