Customize database dump for development

Sometimes it’s useful to dump a production database and import them on a local developer workstation.
In this case we have some issue to solve.

Legal Issues

A production database contains many critical privacy data like customer addresses, email, hashed password, orders
which can produce big trouble if a hacker or someone can access it.
For a development workstation it’s a good advice to exclude the data. In most cases a developer needs no customer data
to create a new module.

Log data

Magento produces many log data. Some tables grow up and can contain many millions of records.
An import of a database could run up to hours. This is unpractical and unwanted for development.

n98-magerun strip option

n98-magerun can help you. The database command comes with a handy strip option.
If you run n98-magerun with –help option you can see this:

If you can see we have predefined some table groups for you.
It’s possible to combine groups. Also tables can be selected with wildcards.

For a developer you can use our group development which excludes the logs (with many million records) and the trade data (customer data and orders)
to prevent legal issues.

Example for a production machine:

If you run the command you can see an output like this:

n98-magerun will strip the data of many tables, but will create the database structure for it.

Add own tables and table groups

If you look inside the dist config bundled with n98-magerun you can see how a table groups are defined.

One great feature of n98-magerun is that you can overwrite or extend the dist config in your own one.
A brief description of the config can be found in our wiki at github.

If we have i.e some log tables with a company prefix like “mycompany_log” we can create our own group in a project config.
Create a new n98-magerun.yaml file inside the app/etc folder of your Magento installation.


If you run n98-magerun.phar db:dump --help again you can see the new table group:

Now you can start the dump again with this command:

It’s also possbible to combine the groups:

Happy coding!