Hi Ien,
I’d like to run mongodump so that it only outputs errors (to avoid extraneous logwatch reporting for an automated nightly backup script).
Currently, the --quiet
option of mongodump
and mongoexport
suppresses output from database commands, replication activity, and connection events (as described in the mongodump
page). The documentation, however, neglected to mention that the --quiet
option also suppresses error messages, as you have observed. I have created the DOCS-7853 ticket to document this fact. Thank you for your input in this matter.
Regarding your use case, you may be able to use mongodump
exit status to determine if the command was successful. If there is any error during the execution of mongodump
, its exit status will be non-zero. In UNIX/Linux system, this exit status can be obtained from the $?
variable in bash
shell. For example, this command fails due to permission issue and returns an exit status of 1:
$ mongodump -o /dump --quiet
$ echo $?
1
If the command is successful, its exit status will be zero:
$ mongodump -o dump --quiet
$ echo $?
0
Best regards,
Kevin