-
mongorestore: ERROR: root directory must be a dump of a single collection when specifying a collection name with –collection
Posted on April 21st, 2010 2 commentsmongorestore wants the specific collection's filename rather than the entire database's dump folder:
dwiel@dwiel$ mongodump -d db -c variables -o ../backups/1
connected to: 127.0.0.1
DATABASE: db to ../backups/1/db
db.variables to ../backups/1/db/variables.bson
3 objects
dwiel@dwiel$ mongorestore -d db -c variables --drop ../backups/1
ERROR: root directory must be a dump of a single collection
when specifying a collection name with --collection
usage: ........
dwiel@dwiel$ mongorestore -d db -c variables --drop ../backups/1/db/variables.bson
connected to: 127.0.0.1
../backups/1/db/variables.bson
going into namespace [db.variables]
dropping
3 objectsquite obvious in retrospect given the error message, but the internet didn't know the answer yet and there isn't much documentation about mongorestore.
2 Responses to “mongorestore: ERROR: root directory must be a dump of a single collection when specifying a collection name with –collection”
-
Jesse Clark October 20th, 2010 at 8:49 pm
Actually if you do:
mongorestore -d db ../backups/1/db
it will restore the whole db. -
Thanks for this, your example worked for me in restoring a single collection from a dump.
mongorestore -c users –drop -d my-database ./my-database/users.bson
osh
