Daniel Werner
Daniel Werner

Reputation: 1370

Efficiently clone a MySQL database on another server

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?

Upvotes: 3

Views: 3748

Answers (3)

David
David

Reputation: 5016

Use load data infile. 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.

Upvotes: 2

Damodharan R
Damodharan R

Reputation: 1507

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.

Upvotes: 2

Pekka
Pekka

Reputation: 449395

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.

Upvotes: 1

Related Questions