snippetMinor
How to get mongodump --quiet to still report errors?
Viewed 0 times
mongodumpquietreportgeterrorshowstill
Problem
I'd like to run
I've tried
How do I get only error output from
Here's the error I get when running without
2016-04-17T13:50:26.294-0400 Failed: error dumping metadata: error creating directory for metadata file dump/234-watchdog: mkdir dump: permission denied
MongoDB is running on Ubuntu. I understand why this error is happening. I want errors like this NOT to be suppressed with the
mongodump so that it only outputs errors (to avoid extraneous logwatch reporting for an automated nightly backup script). I've tried
mongodump --quiet but from a quick test this supressess error messages also (running it at root folder without permission suppresses the "error creating directory" message that I get without --quiet). How do I get only error output from
mongodump?Here's the error I get when running without
--quiet but which I do NOT get with --quiet:2016-04-17T13:50:26.294-0400 Failed: error dumping metadata: error creating directory for metadata file dump/234-watchdog: mkdir dump: permission denied
MongoDB is running on Ubuntu. I understand why this error is happening. I want errors like this NOT to be suppressed with the
--quiet option.Solution
You can do:
This save both
output="$(mongodump 2>&1)" || echo -e "$output"This save both
stdout and stderr into output variable, then if the command exit with not 0 exit code, echo the saved output.Code Snippets
output="$(mongodump 2>&1)" || echo -e "$output"Context
StackExchange Database Administrators Q#135578, answer score: 2
Revisions (0)
No revisions yet.