Shopware 6 – How to mysqldump
Fabian Blechschmidt
Other posts about mysqldump
# Make sure to define $FILENAME and $DATABASE!
mysqldump --quick -C --hex-blob --single-transaction $DATABASE | LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -c > $FILENAME.sql.gz
mysqldump –quick -C –hex-blob –single-transaction
–quick, -q This option is useful for dumping large tables. It forces mysqldump to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out.–compress, -C Compress all information sent between the client and the server if both support compression.–hex-blob Dump binary columns using hexadecimal notation (for example, ´abc´ becomes 0x616263). The affected data types are BINARY, VARBINARY, the BLOB types, and BIT.–single-transaction Dump all data in one transaction to have a valid state
Thanks Marcel for your comment! When using Mysql 8 you need --no-tablespaces as additional
sed -e ’s/DEFINER[ ]=[ ] [^] */*/‘
Remove DEFINER statement to use default definer (instead of a hard coded mysql user which is most likely not available on any other system)
gzip
gzip the dump
> $FILENAME.sql.gz
And write it to $FILENAME.sql.gz (e.g. 2021-04-07_13:22:12-customer-abc.sql.gz)
How to mysqldump GDPR edition
# Make sure to define $FILENAME and $DATABASE!
mysqldump --quick -C --hex-blob --single-transaction --no-data $DATABASE | LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -c > $FILENAME.sql.gz
mysqldump --quick -C --hex-blob --single-transaction --skip-triggers --no-create-info --ignore-table=$DATABASE.product_search_keyword --ignore-table=$DATABASE.seo_url --ignore-table=$DATABASE.product_keyword_dictionary --ignore-table=$DATABASE.payone_payment_card --ignore-table=$DATABASE.payone_payment_mandate --ignore-table=$DATABASE.payone_payment_redirect --ignore-table=$DATABASE.acl_user_role --ignore-table=$DATABASE.cart --ignore-table=$DATABASE.customer --ignore-table=$DATABASE.customer_address --ignore-table=$DATABASE.customer_recovery --ignore-table=$DATABASE.customer_tag --ignore-table=$DATABASE.customer_wishlist --ignore-table=$DATABASE.customer_wishlist_product --ignore-table=$DATABASE.elasticsearch_index_task --ignore-table=$DATABASE.enqueue --ignore-table=$DATABASE.import_export_file --ignore-table=$DATABASE.import_export_log --ignore-table=$DATABASE.integration --ignore-table=$DATABASE.integration_role --ignore-table=$DATABASE.log_entry --ignore-table=$DATABASE.message_queue_stats --ignore-table=$DATABASE.newsletter_recipient --ignore-table=$DATABASE.newsletter_recipient_tag --ignore-table=$DATABASE.order --ignore-table=$DATABASE.order_address --ignore-table=$DATABASE.order_customer --ignore-table=$DATABASE.order_delivery --ignore-table=$DATABASE.order_delivery_position --ignore-table=$DATABASE.order_line_item --ignore-table=$DATABASE.order_tag --ignore-table=$DATABASE.order_transaction --ignore-table=$DATABASE.product_export --ignore-table=$DATABASE.product_review --ignore-table=$DATABASE.promotion_persona_customer --ignore-table=$DATABASE.refresh_token --ignore-table=$DATABASE.sales_channel_api_context --ignore-table=$DATABASE.state_machine_history --ignore-table=$DATABASE.user --ignore-table=$DATABASE.user_access_key --ignore-table=$DATABASE.user_config --ignore-table=$DATABASE.user_recovery --ignore-table=$DATABASE.version --ignore-table=$DATABASE.version_commit --ignore-table=$DATABASE.version_commit_data --ignore-table=$DATABASE.b2b_audit_log --ignore-table=$DATABASE.b2b_audit_log_author --ignore-table=$DATABASE.b2b_audit_log_index --ignore-table=$DATABASE.b2b_business_partner --ignore-table=$DATABASE.b2b_customer_address_data --ignore-table=$DATABASE.b2b_customer_data --ignore-table=$DATABASE.b2b_debtor_contact --ignore-table=$DATABASE.b2b_line_item_list --ignore-table=$DATABASE.b2b_line_item_reference --ignore-table=$DATABASE.b2b_offer --ignore-table=$DATABASE.b2b_order_context --ignore-table=$DATABASE.b2b_order_employee --ignore-table=$DATABASE.b2b_order_list --ignore-table=$DATABASE.b2b_order_number --ignore-table=$DATABASE.b2b_role_contact --ignore-table=$DATABASE.b2b_store_front_auth --ignore-table=$DATABASE.cbax_analytics_category_impressions --ignore-table=$DATABASE.cbax_analytics_invoice_date --ignore-table=$DATABASE.cbax_analytics_manufacturer_impressions --ignore-table=$DATABASE.cbax_analytics_pool --ignore-table=$DATABASE.cbax_analytics_product_impressions --ignore-table=$DATABASE.cbax_analytics_referer --ignore-table=$DATABASE.cbax_analytics_search --ignore-table=$DATABASE.cbax_analytics_visitors --ignore-table=$DATABASE.esmx_ktconnector_blacklist --ignore-table=$DATABASE.hbcom_voucher_remaining_balance --ignore-table=$DATABASE.klarna_cart --ignore-table=$DATABASE.klarna_order_extension --ignore-table=$DATABASE.klarna_payment_request_log --ignore-table=$DATABASE.magnalister_amazon_prepare --ignore-table=$DATABASE.magnalister_amazon_variantmatching --ignore-table=$DATABASE.magnalister_apirequests --ignore-table=$DATABASE.magnalister_config --ignore-table=$DATABASE.magnalister_errorlog --ignore-table=$DATABASE.magnalister_global_selection --ignore-table=$DATABASE.magnalister_image --ignore-table=$DATABASE.magnalister_listings_deleted --ignore-table=$DATABASE.magnalister_magnacompat_errorlog --ignore-table=$DATABASE.magnalister_marketplace_status --ignore-table=$DATABASE.magnalister_orders --ignore-table=$DATABASE.magnalister_preparedefaults --ignore-table=$DATABASE.magnalister_products --ignore-table=$DATABASE.magnalister_selection --ignore-table=$DATABASE.magnalister_shopware6 --ignore-table=$DATABASE.nb_tracking_visitor_ips --ignore-table=$DATABASE.nb_tracking_visitors --ignore-table=$DATABASE.order_return --ignore-table=$DATABASE.order_return_line_item --ignore-table=$DATABASE.payment_token --ignore-table=$DATABASE.periodrequestform --ignore-table=$DATABASE.pickware_document --ignore-table=$DATABASE.pickware_shipping_document_shipment_mapping --ignore-table=$DATABASE.pickware_shipping_document_tracking_code_mapping --ignore-table=$DATABASE.pickware_shipping_sales_channel_api_context --ignore-table=$DATABASE.pickware_shipping_shipment --ignore-table=$DATABASE.pickware_shipping_shipment_order_mapping --ignore-table=$DATABASE.pickware_shipping_tracking_code --ignore-table=$DATABASE.pickware_shopware_extensions_order_configuration --ignore-table=$DATABASE.promotion_individual_code --ignore-table=$DATABASE.sales_channel_analytics --ignore-table=$DATABASE.solid_ie_cms_slot_instagram_post --ignore-table=$DATABASE.swag_sequence_webhook_event_log --ignore-table=$DATABASE.swag_social_shopping_customer --ignore-table=$DATABASE.swag_social_shopping_order --ignore-table=$DATABASE.swag_social_shopping_product_error --ignore-table=$DATABASE.swag_social_shopping_sales_channel --ignore-table=$DATABASE.swkweb_hide_soldout_products_product_availability $DATABASE | LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -c >> $FILENAME.sql.gz
–ignore-table-data Make Do only write CREATE TABLE and don’t write the table data (like customer data, order data, etc. which contain data to identify people)
Dump all table structures
Dump all data, except GDPR and Indexed tables
* This contains already ignoring for some modules.
Update : added --skip-triggers --no-create-info to not add CREATE TABLE to the second dump
Update: added a bunch more tables to ignore
The tables product_search_keyword, product_keyword_dictionary and seo_url are empty as well. They can be filled by running the following command. It might take a while to generate all the data, though.
bin/console dal:refresh:index
Update 9.12.2012: Remove event_* tables from GDPR ignoring
Other articles from this category
Shopware 6 Hidden Gems #1: Criteria::setTitle() — name tags for your SQL queries
A while ago I stared at the slow query log of a customer’s shop. Three seconds for this one: Great. But who sent it? The listing? A plugin? The sitemap generator? Some CMS element? The DAL generates SQL, and generated SQL looks the same everywhere. So the usual detective work begins: copy the query, grep the codebase, guess which filter combination produces exactly this WHERE clause, attach Xdebug, cry a little. […]
Deliverability („Zustellbarkeit“) – warum „Senden“ nicht gleich „Ankommen“ ist
Deliverability („Zustellbarkeit“) ist der Vorgang, mit dem E-Mails in den Posteingängen der Abonnenten landen – und es ist eine Kunst… und eine Wissenschaft. Denn viele Aspekte liegen in unserer Hand (Infrastruktur, E-Mail-Vorlagen…) und auf andere wiederum haben wir keinen direkten Einfluss, etwa die Regeln, welche die E-Mail-Provider zur Entscheidungsfindung („Das ist Spam!“) benutzen. Das heißt […]
SCUC 2026: Impressions
I attended the fifth SCUC – my third visit overall. Unlike a regular conference with hundreds or even thousands rushing through crowded halls to attend one-sided presentations, SCUC’s format in which themes are proposed and presented by the participants results in compelling panels, presentations, and open discussions. The mixture of Developers, PMs, ecommerce agencies and […]