Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoexport exports 0 records

ran this command, and 0 records were exported. [changed the db and collection names for privacy]. doubled checked the syntax.

 mongoexport --db db_name --collection collection_name --out collection_name_delete.json --verbose
    2015-10-15T08:18:02.825+0000    connected to: localhost
    2015-10-15T08:18:02.825+0000    exported 0 records
    root@sever_name:/mnt/data# mongo db_name
    MongoDB shell version: 3.0.0
    connecting to: db_name
    DBReplicaSet:PRIMARY> db.dip_acon_research_finals.count()
    1597113
like image 328
WebQube Avatar asked Oct 15 '15 08:10

WebQube


2 Answers

You have a replica set and not a stand alone setup. You must use correct set of switches for connecting to the replica set. Try again with --host and --port arguments. For more reference see https://docs.mongodb.org/manual/reference/program/mongoexport/

like image 95
Raunak Jhawar Avatar answered Sep 22 '22 13:09

Raunak Jhawar


The mongoexport syntax looks fine. Since you're using an replica set, modify the syntax like the following and try

mongodump --host "<replSetName>/<hostname1><:port>,<hostname2><:port>,<...>" --db db_name --collection collection_name --out output_file.json
like image 28
Avis Avatar answered Sep 20 '22 13:09

Avis