Need to export a collection on daily basis

Hello Team,

We are trying to export all our Mongo DB database Trigger errors to a collection through ‘Log Forwarder’ module.

Now, we want to take a daily dump of that collection to check the number of errors occurred on daily basis.

Is there any way to achieve this ? In Compass, we have an option to export the collection, however, is there any scheduled process or anything we can configure?

Hello @Saptarsi_Mondal,

Welcome to the MongoDB Community Forum! :wave:

I think from the MongoDB side, the application you are looking for is mongoexport. It is a command-line tool that produces a JSON or CSV export of data stored in a MongoDB instance.

In terms of scheduling jobs:

  • In Linux, you can use cronjob to run the command automatically daily and use it accordingly.
  • For Windows, you can use Windows Task Scheduler to schedule a daily task to run this command.

I believe the most straightforward way to achieve what you wanted (daily export of a collection), is to use cronjob/task scheduler to run a script that executes mongoexport with the required parameters.

However if this is not applicable to your use case, please share below details:

  • your user-case/expectations
  • MongoDB version
  • OS details

Regards,
Tarun

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.