When I do: drush sql-dump > somewhere/database.sql if there will be any warnings printed by Drush, they will be included at the beginning of the created database.sql file. Can we avoid it somehow?

I know there is the --result-file= option that ignores all warnings when creating the file, but is there any way to ignore warnings when piping the output? I would like to parse the output before actually saving it into a file if its possible.

drush 8

  • Which warnings? You could at least avoid that by fixing the underlying issues that trigger these warnings. – leymannx Oct 24 '18 at 11:54
  • Not always feasible. I would like for my script to work also in foreign environments, which may have their own issues, that are not a priority to fix. There are also cases like this: github.com/drush-ops/drush/issues/3410 where the warning is a drush issue. – Łukasz Zaroda Oct 24 '18 at 11:57
  • For now I decided to use | grep -vaE '\[warning\]\s$' > as a middleman to filter out possible warnings, but it would be great if there would be a better way, as not all possible undesired output will be filtered by this. – Łukasz Zaroda Oct 24 '18 at 12:32
  • Actually a better filtering device would be | sed -n '/^--/,$p' > it makes everything before the first comment in the dump ignored, I think it should do a fine job, but it's a workaround nonetheless. – Łukasz Zaroda Oct 24 '18 at 12:41

Seems -q should do the job.

$options['quiet'] = array(
  'short-form' => 'q',
  'description' => 'Suppress non-error messages.',

Source: function drush_get_global_options

  • I tested it. Actually funnily enough, it removes a dump and leaves only warnings in the stdout. :) – Łukasz Zaroda Oct 24 '18 at 12:51
  • Hahaha, maybe that's what is meant with "quite". OK, but then the warnings get raised by mysqldump as you already suggested in the comments to your question. And that seems to be off-topic then I'm afraid. – leymannx Oct 24 '18 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.