netz98/n98-magerun

Strange behaviour of db:dump

nebojsa-factorblue opened this issue · 8 comments

Hello guys,

Thank you for the great tool, I am using it for years!

I noticed strange behavior at one of our client's production server. When I do:

$ n98-magerun db:dump --strip="@development" --compression="gzip"

I get normal stripped dump. But when I do:

$ n98-magerun db:dump --strip="@development core_url_rewrite" --compression="gzip"

Instead of core_url_rewrite being added to skipping dumping data, I get file name core_url_rewrite.sql.gz.

See the screenshot: https://imgur.com/a/69crrsa

Anyone idea?

Thanks!

@nebojsa-factorblue
2020-07-29_13-16-02

Tested your command against a fresh installed OpenMage and was not able to reproduce the issue.
One thing which is different is that you did not define a filename for the dump. In my case I see a prompt for the filename. In your screenshot it's not there.
Maybe it's an issue with "readline" PHP extension.
Can you check if the extension is installed?

php -m | grep readline

@nebojsa-factorblue And can you check the behavior by adding a dump filename?

n98-magerun.phar db:dump --strip="@development core_url_rewrite" --compression="gzip" db.sql.gz

readline is there: https://i.imgur.com/LjcxdQP.png

See: https://i.imgur.com/PCqfbRL.png

Very strange behavior. Anywhere else it is working, I know, locally, and any other server... But here I've got very strange behavior. The version is 1.103.3 if it helps a little...

@nebojsa-factorblue Could it be that "n98-magerun" is an alias with a pre-configuration.
alias | grep n98-magerun

btw... the 1.103.3 works also in my test machine.

Nothing found... Tried with the rawly downloaded file and making it executable and running with it but the result is the same.
Will see with Hosting as well, maybe the issue is known to them. Will write here if there is something found.

Thank you for effort and keep up with good work! If you get some idea in some time please update this ticket. For now, I'd close it.

Cheers!

@nebojsa-factorblue Maybe you can again with --only-command option to see which mysqldump command is produced. Ix it working if you remove options?

e.g. n98-magerun db:dump --only-command

This is the "Blanco" example: https://i.imgur.com/wCS0qDB.png

Variant of db:dump is:

$> n98-magerun db:dump --strip="@development core_url_rewrite" --compression="gzip" --only-command
Folder /tmp/magento/var found, but not used in n98-magerun

This might cause serious problems. n98-magerun is using the configured var-folder /domains/{folder}/public_html/var
Please refer to https://github.com/netz98/n98-magerun/wiki/File-system-permissions for more information.

mysqldump --single-transaction --quick --no-data -h {DB_DATA} admin_assert admin_role admin_rule admin_user adminnotification_inbox catalogsearch_fulltext catalogsearch_query catalogsearch_result core_email_queue core_email_queue_recipients core_session customer_address_entity customer_address_entity_datetime customer_address_entity_decimal customer_address_entity_int customer_address_entity_text customer_address_entity_varchar customer_entity customer_entity_datetime customer_entity_decimal customer_entity_int customer_entity_text customer_entity_varchar dataflow_batch dataflow_batch_export dataflow_batch_import dataflow_import_data dataflow_session importexport_importdata log_url log_url_info log_visitor log_visitor_info log_visitor_online newsletter_problem newsletter_queue newsletter_queue_link newsletter_queue_store_link newsletter_subscriber report_compared_product_index report_event report_viewed_product_aggregated_daily report_viewed_product_aggregated_monthly report_viewed_product_aggregated_yearly report_viewed_product_index sales_bestsellers_aggregated_daily sales_bestsellers_aggregated_monthly sales_bestsellers_aggregated_yearly sales_flat_creditmemo sales_flat_creditmemo_comment sales_flat_creditmemo_grid sales_flat_creditmemo_item sales_flat_invoice sales_flat_invoice_comment sales_flat_invoice_grid sales_flat_invoice_item sales_flat_order sales_flat_order_address sales_flat_order_grid sales_flat_order_item sales_flat_order_payment sales_flat_order_status_history sales_flat_quote sales_flat_quote_address sales_flat_quote_address_item sales_flat_quote_item sales_flat_quote_item_option sales_flat_quote_payment sales_flat_quote_shipping_rate sales_flat_shipment sales_flat_shipment_comment sales_flat_shipment_grid sales_flat_shipment_item sales_flat_shipment_track sales_order_aggregated_created sales_order_aggregated_updated sales_order_tax sales_order_tax_item sales_payment_transaction sales_recurring_profile sales_recurring_profile_order sales_refunded_aggregated sales_refunded_aggregated_order salesrule_coupon_usage salesrule_customer wishlist wishlist_item wishlist_item_option | LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -c  > 'core_url_rewrite.sql.gz'
mysqldump --single-transaction --quick -h {DB_DATA} --ignore-table=admin_assert --ignore-table=admin_role --ignore-table=admin_rule --ignore-table=admin_user --ignore-table=adminnotification_inbox --ignore-table=catalogsearch_fulltext --ignore-table=catalogsearch_query --ignore-table=catalogsearch_result --ignore-table=core_email_queue --ignore-table=core_email_queue_recipients --ignore-table=core_session --ignore-table=customer_address_entity --ignore-table=customer_address_entity_datetime --ignore-table=customer_address_entity_decimal --ignore-table=customer_address_entity_int --ignore-table=customer_address_entity_text --ignore-table=customer_address_entity_varchar --ignore-table=customer_entity --ignore-table=customer_entity_datetime --ignore-table=customer_entity_decimal --ignore-table=customer_entity_int --ignore-table=customer_entity_text --ignore-table=customer_entity_varchar --ignore-table=dataflow_batch --ignore-table=dataflow_batch_export --ignore-table=dataflow_batch_import --ignore-table=dataflow_import_data --ignore-table=dataflow_session --ignore-table=importexport_importdata --ignore-table=log_url --ignore-table=log_url_info --ignore-table=log_visitor --ignore-table=log_visitor_info --ignore-table=log_visitor_online --ignore-table=newsletter_problem --ignore-table=newsletter_queue --ignore-table=newsletter_queue_link --ignore-table=newsletter_queue_store_link --ignore-table=newsletter_subscriber --ignore-table=report_compared_product_index --ignore-table=report_event --ignore-table=report_viewed_product_aggregated_daily --ignore-table=report_viewed_product_aggregated_monthly --ignore-table=report_viewed_product_aggregated_yearly --ignore-table=report_viewed_product_index --ignore-table=sales_bestsellers_aggregated_daily --ignore-table=sales_bestsellers_aggregated_monthly --ignore-table=sales_bestsellers_aggregated_yearly --ignore-table=sales_flat_creditmemo --ignore-table=sales_flat_creditmemo_comment --ignore-table=sales_flat_creditmemo_grid --ignore-table=sales_flat_creditmemo_item --ignore-table=sales_flat_invoice --ignore-table=sales_flat_invoice_comment --ignore-table=sales_flat_invoice_grid --ignore-table=sales_flat_invoice_item --ignore-table=sales_flat_order --ignore-table=sales_flat_order_address --ignore-table=sales_flat_order_grid --ignore-table=sales_flat_order_item --ignore-table=sales_flat_order_payment --ignore-table=sales_flat_order_status_history --ignore-table=sales_flat_quote --ignore-table=sales_flat_quote_address --ignore-table=sales_flat_quote_address_item --ignore-table=sales_flat_quote_item --ignore-table=sales_flat_quote_item_option --ignore-table=sales_flat_quote_payment --ignore-table=sales_flat_quote_shipping_rate --ignore-table=sales_flat_shipment --ignore-table=sales_flat_shipment_comment --ignore-table=sales_flat_shipment_grid --ignore-table=sales_flat_shipment_item --ignore-table=sales_flat_shipment_track --ignore-table=sales_order_aggregated_created --ignore-table=sales_order_aggregated_updated --ignore-table=sales_order_tax --ignore-table=sales_order_tax_item --ignore-table=sales_payment_transaction --ignore-table=sales_recurring_profile --ignore-table=sales_recurring_profile_order --ignore-table=sales_refunded_aggregated --ignore-table=sales_refunded_aggregated_order --ignore-table=salesrule_coupon_usage --ignore-table=salesrule_customer --ignore-table=wishlist --ignore-table=wishlist_item --ignore-table=wishlist_item_option  | LANG=C LC_CTYPE=C LC_ALL=C sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip -c  >> 'core_url_rewrite.sql.gz'
ktomk commented

From your original report screenshot this looks like an issue with parsing the command-line which is on the level of the shell (first of all):

$ n98-magerun db:dump --strip="@development core_url_rewrite" --compression="gzip"
                                            ^^^^^^^^^^^^^^^^
[...]
starting dumping database XXX to file core_url_rewrite.sql.gz
                                      ^^^^^^^^^^^^^^^^
[...]

This looks to me (did not reproduce this, so might be entirely wrong on it) that instead of stripping the core_url_rewrite table from the dump, the table-name is taken as an independent argument to set the export file basename.

As I understand your report you have this only on a specific system and not on all others. However the command

$ n98-magerun db:dump --strip="@development core_url_rewrite" --compression="gzip"

is entered into that system, if the double-quotes are stripped, the command could end up effectively as:

$ n98-magerun db:dump --strip=@development core_url_rewrite --compression=gzip

Which might enable you to reproduce the behavior on all the other systems as well. If so, this would verify what is happening here.

E.g. if sending the command via SSH, it might require double encoding to preserve the quotes (for the grip switch value, it's not necessary):

$ n98-magerun db:dump '--strip="@development core_url_rewrite"' --compression=gzip

Mind the additional single quotes around the --strip switch.

Please share if this already helps you to deal with the issue and if you can share some more context about how that command is passed to that one system, this might shed some more light.

I assume it's a shell / command passing issue, however magerun could be of some help here if --strip supports separating the table names and table groups not only by space but alternatively as well by comma "," the shell field separation on space would not kick in which can make it more easy to pass along. But that is more a comment in the margin.