MySQLDump – How to Skip Email Addresses When Creating Production to Staging Flow

MySQLmysqldumpPHP

I want to run mysqldump or basically, anything that lets me easily export / import mysql db from one server into another.

Thing is: I want to export production data as staging / integration / demo data. That means, prior to importing the data, all user data must be gone. We had it one time, that the users got imported, and because the system ran a cron job, the server started sending out 200'000 emails. Can you imagine? yes yes, just disable the cronjob prior to import, but accidents happen. So importing user data and then deleting them is not an option.

Optimally I want to just ignore certain columns where there is an email, or replace that email with a test email string.

Is there something that helps me with that?

php is what we use for the application, so any php import export tool is a possibility as well.

Best Answer

  1. Dump the database
  2. Pump it in the temporary database
  3. Empty columns you do not want to transfer
  4. Dump the temporary database
  5. Transfer it