1

I am using mongodb Atlas (M0), which does not provide db backup feature. I am creating a nodejs script that will export all the collections automatically periodically.

So far I have done the following:

  • created a programmatic api from my login.
  • whitelisted my ip
  • installed mongocli
  • created a default profile using public and private api keys.

And command looks like this:

mongoexport --uri mongodb+srv://${mongoUser}:${mongoPass}@mongoprojectname.lok0l.mongodb.net/${database} --collection ${collection} --type ${fileType} --out ${fileName} --profile default

I am not able to figure out how to run this command. If I run this command in my terminal I get this error: /bin/sh: mongoexport: command not found\n

2 Answers2

0

You have to import MongoDB tools via .

Download, unzip, and use the export path and run the command below on the terminal and try the export command again.

export PATH=$PATH:inputmongodbtoolpath

If you already use brew, you can try with it.

brew install mongodb-community
brew services start mongodb-community
Yunus UYANIK
  • 1,025
  • 1
  • 7
  • 21
  • As of MongoDB v4.4, mongoexport is part of the database tools and is installed separately. See Installing Database Tools. [link](https://docs.mongodb.com/database-tools/installation/installation-macos/#installing-the-database-tools-on-macos) – Jasmohan Singh Feb 22 '21 at 17:15
  • no need to install MongoDB-community if using an atlas. Installing mongocli and database tools worked fine. Originally I installed the mongocli but somehow missed database tools. But now its working fine. – Jasmohan Singh Feb 22 '21 at 17:17
0

For running mongoexport command you need to install database tools separately. Once you install mongocli and database tools then mongoexport runs from the terminal just like any other command.

I did the following to run the mongoexport. some of it might be unnecessary but worked for me:)

  • installed mongocli
  • created api key for the project
  • whitelisted my ip in the mongo settings
  • installed database tools from the mongo website
  • created a default profile using mongocli config command

This is the link to mongo database tools