Mysql – Strategies for rotating backend production MySQL data into a test environment

MySQL

I've been assigned a task where I need to replicate a web application for creating a test environment, and part of the project is to create a test database with sample production data to help testing. I'm no database expert, and I haven't been able to find any solid strategies online for rotating data. All I know for sure is that I would need to spin up another MySQL instance on our DB server and connect the new instance to that, but how do I go about getting actual data out of our production DB without harming production data? Are there any well-known strategies I can deploy?

Best Answer

Plan A: Have the Production system be a Master; have another machine (or two) be a Slave. At any moment, you could use the Slave (in a couple of different ways) to provide a snapshot of Production at some point in time. The impact on the Master (Production) is zero (after a somewhat painful setup). Master-Slave is the beginnings of any HA (High Availability) solution.

Plan B: Use LVM (Logical Volume Management, an OS tool) as a way of taking a snapshot of the Production machine. This involves taking down the server briefly (about a minute, regardless of amount of data). Them the disk can be copied to elsewhere for whatever use -- such as building a dev box.

Neither of those do what I think of as a "rotate", but perhaps they solve your request?

I suggest you search for either or both of those strategies, then come back for further questions, if needed.