views:

290

answers:

3

We need to regularly create a clone of a production server's live MySQL 4 database (only one schema) and import it on one or more development databases. Our current process is to 'mysqldump' the database, copy it via ssh and restore it on the target machine using the 'mysql' client utility.

Dumping and copying is relatively fast, but restoring the database schema (structure + content) takes hours. Is there a less time-consuming to do the cloning?

+1  A: 

I don't have experience with it myself - mysqldump and mysqldump have always been sufficient for my data volumes - but mysqlhotcopy looks like it could be faster, as it uses cp/scp to copy the data directories.

Pekka
+1  A: 

If you have LVM setup then have a look at this for using LVM for mysql backup . Using LVM the backups can be made really fast. Once the backup is taken tar it and copy the snapshot to the destination and untar it. It should be faster than the loading from mysqldump.

Damodharan R
+2  A: 

Use Load data infile (http://dev.mysql.com/doc/refman/5.1/en/load-data.html). This is an order of magnitude faster than loading from dumps. If you are lucky you could load data using a pipe. If you were able to export the data from one server to this same pipe, then you could have the two servers working simultaneously.

David
Excellent, David! I'm going to have to dump and restore the (potentially changed) schema structure beforehand, but copying the data using OUTFILE/INFILE should take only small changes to the current scripts. Thanks!
Daniel Werner
Glad I could help
David