I am new to MongoDB. When I am using "*--directoryperdb*" option in * MongoExport* I am getting an exception.
Here is the query what I am using mongoexport.exe -f <FieldNames> --csv --dbpath d:\devhome\tools\mongodb\data\db --directoryperdb
Error: no collection specified! Export MongoDB data to CSV, TSV or JSON files.
After that I specified a collection name, now my query is mongoexport.exe -f <FieldNames> --csv --dbpath d:\devhome\tools\mongodb\data\db --directoryperdb -c Person Now I am getting exported 0 records Sun Sep 09 17:36:14 dbexit: Sun Sep 09 17:36:14 [tools] shutdown: going to close listening sockets... Sun Sep 09 17:36:14 [tools] shutdown: going to flush diaglog... Sun Sep 09 17:36:14 [tools] shutdown: going to close sockets... Sun Sep 09 17:36:14 [tools] shutdown: waiting for fs preallocator... Sun Sep 09 17:36:14 [tools] shutdown: closing all files... Sun Sep 09 17:36:14 [tools] closeAllFiles() finished Sun Sep 09 17:36:14 [tools] shutdown: removing fs lock... Sun Sep 09 17:36:14 dbexit: really exiting now
Here my doubt is how can we use *--directoryperdb* option. Could anyone help me on this. I stuck over here.
Note: If I remove *--directoryperdb *I am able to export one collection(If I specified dbname and collection name). How can we export all databases using MongoExport.
> Note: If I remove *--directoryperdb *I am able to export one > collection(If I specified dbname and collection name). How can we export > all databases using MongoExport.
If you want to export all databases, you should instead be using mongodump / mongorestore:
Thanks for your reply. So what I understand was MongoExport will export one
collection(from one database) at a time. Is it right stephen..??????
So if we want to export all the databases we need to use "MONGO DUMP"
right??????
So if we export one collection at a time when this *--directoryperdb* come
into picture. I didn't understand clearly. Could you please explain with
one example please.
Thanks & Regards,
Amar
On 9 September 2012 18:08, Stephen Steneker <stephen.stene...@10gen.com>wrote:
>> Note: If I remove *--directoryperdb *I am able to export one
>> collection(If I specified dbname and collection name). How can we export
>> all databases using MongoExport.
> If you want to export all databases, you should instead be using mongodump
> / mongorestore:
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
> Thanks for your reply. So what I understand was MongoExport will export > one collection(from one database) at a time. Is it right stephen..??????
Yes, mongoexport is for exporting one collection to a text format (CSV, TSV, JSON).
So if we want to export all the databases we need to use "MONGO DUMP"
> right??????
If you want to backup and restore all of the collections and databases, mongodump/mongorestore are the correct programs to use.
If you want to export each collection to a text format, you can use mongoexport but you will have to call it once for every collection.
So if we export one collection at a time when this *--directoryperdb* come
> into picture. I didn't understand clearly. Could you please explain with > one example please.
You would only want to use this option if all of the following are true:
- you are using --directoryperdb in your mongod configuration - you want to use --dbpath from mongoexport/mongodump (which reads the data files directly instead of connecting to the mongo server) - you do not have a mongod currently using those db files
This is very likely *not* an option you want to use, which is why I suggested you should not include it.
> Thanks for your reply. So what I understand was MongoExport will export
>> one collection(from one database) at a time. Is it right stephen..??????
> Yes, mongoexport is for exporting one collection to a text format (CSV,
> TSV, JSON).
> So if we want to export all the databases we need to use "MONGO DUMP"
>> right??????
> If you want to backup and restore all of the collections and databases,
> mongodump/mongorestore are the correct programs to use.
> If you want to export each collection to a text format, you can use
> mongoexport but you will have to call it once for every collection.
> So if we export one collection at a time when this *--directoryperdb* come
>> into picture. I didn't understand clearly. Could you please explain with
>> one example please.
> You would only want to use this option if all of the following are true:
> - you are using --directoryperdb in your mongod configuration
> - you want to use --dbpath from mongoexport/mongodump (which reads the
> data files directly instead of connecting to the mongo server)
> - you do not have a mongod currently using those db files
> This is very likely *not* an option you want to use, which is why I
> suggested you should not include it.
> Cheers,
> Stephen
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb