Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using mongodump with mongodb atlas

Tags:

mongodb

For some reason I cant connect to atlas using the connection string but instead of using mongo use mongodump. I have tried all type of string.

So its either I get "positional argument not allowed" when the I just replace mongo with mongodump or I get

"failed: error connecting to db: no reachable servers" when I change the host from "mongo://replset1:27017,replset2:27017,replset3:271017/test?replicaSet=replicaSetName" to --host replicaSetName/replset1:27017,replset:27017,replset3:27017

Anyone know what the problem is here.

Rememeber I can make connections using mongo client.

like image 486
Ikenna Avatar asked Oct 09 '17 19:10

Ikenna


People also ask

What is Mongodump in MongoDB?

mongodump is a utility for creating a binary export of the contents of a database. mongodump can export data from either mongod or mongos instances; i.e. can export data from standalone, replica set, and sharded cluster deployments. Run mongodump from the system command line, not the mongo shell.

Can you use Mongoose with MongoDB Atlas?

Mongoose can be used to connect to both MongoDB and MongoDB Atlas to your Node. js app.

Where is Mongodump used?

The mongodump is a utility for creating database backups. The utility can be used for creating binary export of the database contents. Mongodump can export data from both mongod and mongos instances, allowing you to create backups from: A standalone, replica set.


2 Answers

Currently mongoDB Atlas has a copy and paste option for "mongodump" in the "Command Line Tools" section of your cluster. First login to your mongoDB Atlas cluster. Next, on the left side of the screen make sure "Clusters" is chosen. Then, you'll see two options "Overview" and "Security", make sure "Overview" is chosen. Directly below "Overview" you should see "Sandbox". Under "Sandbox" you should see the name of your cluster which is a clickable link, click it. You'll then see a number of optional links to click, click "Command Line Tools". Here you'll see the copy and paste option for "mongodump".

like image 178
charliecode_ Avatar answered Sep 24 '22 17:09

charliecode_


In my case I finally got it this way:

# mongodump -d DB-NAME -u SUPERUSER -p "SUPERUSER-PASSWORD" -o "PATH/TO/DUMP/FOLDER" --authenticationDatabase AUTH-DB --ssl --port 27017 -h "REPLICA-SET-NAME/CLUSTER-SHARD-00-00,CLUSTER-SHARD-00-01,CLUSTER-SHARD-00-02"

Where:

  • DB-NAME: Name of the database to backup
  • SUPERUSER: User name with all privileges, the one you got creating the cluster
  • SUPERUSER-PASSWORD: Self explanatory ;)
  • PATH/TO/DUMP/FOLDER: Where you want to save the dump
  • AUTH-DB: The database for authentication, by default is called "admin"
  • REPLICA-SET-NAME: The name of the replica set in the form "cluster-name-shard-0"
  • CLUSTER-SHARD: Name of the cluster shards IE: "cluster-name-shard-00-00-kb2rd.mongodb.net, cluster-name-shard-00-01-kb2rd.mongodb.net, cluster-name-shard-00-02-kb2rd.mongodb.net"
like image 35
razor7 Avatar answered Sep 24 '22 17:09

razor7