How to Strip Large Magento 2 Database Dump using N98-MAGERUN2

As a Magento 2 developer, you are frequently doing the setup of the production site into your local machine. The production database consists of live orders, live customers, and large amounts of logs and session data. These data are not needed for development. So it is very important to strip Magento 2 Database dump for two reasons

  1. To Fast import production database into local
  2. To Avoid accidentally email send to live customers

We all know that it is not easy to strip MySQL tables from Magento 2 database. As Magento 2 database tables are inter-related with each other using a foreign key. To easily strip the database we will use n98-magerun2. First, we will see how to install n98-magerun2.

Install n98-magerun2

To install n98-magerun2 run below command in your Linux terminal.

wget https://files.magerun.net/n98-magerun2.phar

chmod +x ./n98-magerun2.phar

./n98-magerun2.phar --version

To Strip large database dump run one of the commands as per your need in the root path of your Magento 2 installation.

Strip customer data from Magento 2 Database Dump

n98-magerun2.phar db:dump --strip="@customers"

Strip order data from Magento 2 Database Dump

n98-magerun2.phar db:dump --strip="@trade"

Strip logs and sessions data from Magento 2 Database Dump

n98-magerun2.phar db:dump --strip="@stripped"

Strip all logs, sessions, admin users, orders, and customers together from Magento 2 Database Dump

n98-magerun2.phar db:dump --strip="@development"

Conclusion

We have seen different commands for strip production database and make it secure and small for development purposes. Apart from these commands, n98-magerun2 offers many other useful commands. You can check full list of commands here.

Want to ask a question or leave a comment?

Leave a Comment

(0 Comments)

All the comments are goes into moderation before approval. Irrelevant comment with links directly goes to spam. Your email address will not be published.

Was this post helpful? Please support Us!

Follow us on twitter or Like us on facebook.

 


Subscribe Here
SUBSCRIBE NOW

Want to Increase your Magento 2 Development Knowledge?

If Yes! Then Subscribe to our newsletter and receive step-by-step tutorials, code snippets once a week!!
close-link

To Avoid Spam Downloads, We Want Your Email

We will send you download link right
away. Please submit form below.
SEND ME DOWNLOAD LINK
Close