What is a faster way to backup and restore a MySQL DB than mysqldump? (faster than 4 hours)
We have a database that is about 3GB (in text) after mysqldump
is used to dump a text representation of it, and then
mysql < mysqlstatement.sql
is used to restore the database. But it takes 4 hours.
Is there a way to quickly back up / restore the database instead?
It is on a Mac using Ruby on Rails, so one time I set the test
environment to use the development DB, and the test wiped out the whole DB in a few seconds.
I have a way which is to "take a snapshot" of the development environment开发者_如何学C if it is PC -- just use Virtual PC and say the virtual disk image is only 2, 3GB, then we can save that virtual hard drive (VHD), and then the whole thing together with the DB is backed up.
But on Mac, there is no such way? Thanks.
If the database's storage engine is MyISAM, it's safe just to copy the files, and copy them back when needed. With InnoDB it's more complicated. Take a look at Percona's xtrabackup
The DB is just a directory (or maybe a file with some engines...), nothing prevents you to backup it. It is named after the name of the DB and is located in mysql's datadir
(check my.cnf).
I would recommend xtrabackup if you are using Innodb tables.
mydumper is also an alternative that might give you some performance improvements- http://www.mydumper.org/
精彩评论