mongorestore : don't know what to do with file “/home/path/to/folder/collection1

2,853 views
Skip to first unread message

Meher Hosni

unread,
Apr 10, 2018, 8:54:15 PM4/10/18
to mongodb-user
Hello,

-I'm trying to import a mongodb database

-From a mongodb base version 2.4.10 I exported the database with the command: mongodump -d DBNAME -o / path / folder

-I tried to import the dump to a mongodb engine version 3.6.3 -I got this error:


root@server:~# mongorestore -vvvv  --nsInclude NEWDBNAME    /home/path/to/folder/
2018-04-06T10:16:35.729+0200    checking options
2018-04-06T10:16:35.734+0200            dumping with object check disabled
2018-04-06T10:16:35.734+0200    will listen for SIGTERM, SIGINT, and SIGKILL
2018-04-06T10:16:35.927+0200    connected to node type: standalone
2018-04-06T10:16:35.929+0200    standalone server: setting write concern w to 1
2018-04-06T10:16:35.929+0200    using write concern: w='1', j=false, fsync=false, wtimeout=0
2018-04-06T10:16:35.929+0200    mongorestore target is a directory, not a file
2018-04-06T10:16:35.929+0200    preparing collections to restore from
2018-04-06T10:16:35.929+0200    using /home/path/to/folder/ as dump root directory
2018-04-06T10:16:35.952+0200    don't know what to do with file "/home/path/to/folder/collection1.bson", skipping...
2018-04-06T10:16:35.952+0200    don't know what to do with file "/home/path/to/folder/collection1.metadata.json", skipping...
2018-04-06T10:16:35.952+0200    don't know what to do with file "/home/path/to/folder/collection2.bson", skipping...
2018-04-06T10:16:35.953+0200    don't know what to do with file "/home/path/to/folder/collection2.metadata".json", skipping...
2018-04-06T10:16:35.953+0200    don't know what to do with file "/home/path/to/folder/collection3.bson", skipping...
2018-04-06T10:16:35.953+0200    don't know what to do with file "/home/path/to/folder/collection3.metadata".json", skipping...
2018-04-06T10:16:35.953+0200    don't know what to do with file "/home/path/to/folder/collectionX.bson", skipping...
2018-04-06T10:16:35.953+0200    don't know what to do with file "/home/path/to/folder/collectionX.metadata.json", skipping...
.
.
.
2018-04-06T10:16:35.958+0200    finalizing intent manager with multi-database longest task first prioritizer
2018-04-06T10:16:35.958+0200    restoring up toroot@server:~# mongorestore -vvv  -d  NEWDBName  /home/tmp/path/folder/
2018-04-06T10:47:22.949+0200    checking options
2018-04-06T10:47:22.951+0200            dumping with object check disabled
2018-04-06T10:47:22.954+0200    will listen for SIGTERM, SIGINT, and SIGKILL
2018-04-06T10:47:22.963+0200    connected to node type: standalone
2018-04-06T10:47:22.963+0200    standalone server: setting write concern w to 1
2018-04-06T10:47:22.963+0200    using write concern: w='1', j=false, fsync=false, wtimeout=0
**2018-04-06T10:47:22.963+0200    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead**
2018-04-06T10:47:22.963+0200    mongorestore target is a directory, not a file
2018-04-06T10:47:22.963+0200    building a list of collections to restore from /home/tmp/path/folder dir
2018-04-06T10:47:22.963+0200    reading collections for database DBNAME in folder
2018-04-06T10:47:22.963+0200    found collection DBNAME.collectionX bson to restore to DBNAME.collectionX
2018-04-06T10:47:22.963+0200    found collection metadata from DBNAME.collectionX to restore to DBNAME.collectionX
2018-04-06T10:47:22.963+0200    found collection DBNAME.collectionY bson to restore to DBNAME.collectionY
2018-04-06T10:47:22.963+0200    found collection metadata from DBNAME.collectionY to restore to DBNAME.collectionY
2018-04-06T10:47:22.963+0200    found collection DBNAME.collectionZ bson to restore to DBNAME.collectionZ
2018-04-06T10:47:22.963+0200    found collection metadata from DBNAME.collectionZ to restore to DBNAME.collectionZ
.
.
.

2018-04-06T10:47:22.964+0200    not restoring system.indexes collection because database DBNAME has .metadata.json files
2018-04-06T10:47:22.964+0200    found collection DBNAME.system.users bson to restore to DBNAME.system.users
2018-04-06T10:47:22.964+0200    found collection metadata from DBNAME.system.users to restore to DBNAME.system.users
2018-04-06T10:47:22.964+0200    found collection DBNAME.typeincidents bson to restore to DBNAME.typeincidents
2018-04-06T10:47:22.964+0200    found collection metadata from DBNAME.typeincidents to restore to DBNAME.typeincidents
.
.
.
2018-04-06T10:47:22.964+0200    finalizing intent manager with multi-database longest task first prioritizer
2018-04-06T10:47:22.964+0200    restoring up to 4 collections in parallel
2018-04-06T10:47:22.964+0200    starting restore routine with id=3
2018-04-06T10:47:22.964+0200    starting restore routine with id=0
2018-04-06T10:47:22.964+0200    starting restore routine with id=1
2018-04-06T10:47:22.964+0200    starting restore routine with id=2
2018-04-06T10:47:22.964+0200    reading metadata for DBNAME.evenements from /home/tmp/path/folder/evenements.metadata.json
2018-04-06T10:47:22.964+0200    creating collection DBNAME.evenements using options from metadata
2018-04-06T10:47:22.964+0200    using collection options: bson.D{bson.DocElem{Name:"create", Value:"evenements"}, bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument{Options:bson.M{"name":"_id_", "ns":"DBNAME.evenements"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}}
2018-04-06T10:47:22.965+0200    Failed: DBNAME.evenements: error creating collection DBNAME.evenements: error running create command: BSON field 'OperationSessionInfo.create' is a duplicate field
4 collections in parallel 2018-04-06T10:16:35.958+0200 starting restore routine with id=3 2018-04-06T10:16:35.958+0200 ending restore routine with id=3, no more work to do 2018-04-06T10:16:35.958+0200 starting restore routine with id=0 2018-04-06T10:16:35.958+0200 ending restore routine with id=0, no more work to do 2018-04-06T10:16:35.958+0200 starting restore routine with id=1 2018-04-06T10:16:35.958+0200 ending restore routine with id=1, no more work to do 2018-04-06T10:16:35.959+0200 starting restore routine with id=2 2018-04-06T10:16:35.959+0200 ending restore routine with id=2, no more work to do 2018-04-06T10:16:35.959+0200 done

Result with other command


root@server:~# mongorestore -vvv -d NEWDBName /home/tmp/path/folder/ 2018-04-06T10:47:22.949+0200 checking options 2018-04-06T10:47:22.951+0200 dumping with object check disabled 2018-04-06T10:47:22.954+0200 will listen for SIGTERM, SIGINT, and SIGKILL 2018-04-06T10:47:22.963+0200 connected to node type: standalone 2018-04-06T10:47:22.963+0200 standalone server: setting write concern w to 1 2018-04-06T10:47:22.963+0200 using write concern: w='1', j=false, fsync=false, wtimeout=0 **2018-04-06T10:47:22.963+0200 the --db and --collection args should only be used when restoring from a BSON file.
Other uses are deprecated and will not exist in the future; use --nsInclude instead**
2018-04-06T10:47:22.963+0200 mongorestore target is a directory, not a file 2018-04-06T10:47:22.963+0200 building a list of collections to restore from /home/tmp/path/folder dir 2018-04-06T10:47:22.963+0200 reading collections for database DBNAME in folder 2018-04-06T10:47:22.963+0200 found collection DBNAME.collectionX bson to restore to DBNAME.collectionX 2018-04-06T10:47:22.963+0200 found collection metadata from DBNAME.collectionX to restore to DBNAME.collectionX 2018-04-06T10:47:22.963+0200 found collection DBNAME.collectionY bson to restore to DBNAME.collectionY 2018-04-06T10:47:22.963+0200 found collection metadata from DBNAME.collectionY to restore to DBNAME.collectionY 2018-04-06T10:47:22.963+0200 found collection DBNAME.collectionZ bson to restore to DBNAME.collectionZ 2018-04-06T10:47:22.963+0200 found collection metadata from DBNAME.collectionZ to restore to DBNAME.collectionZ . . . 2018-04-06T10:47:22.964+0200 not restoring system.indexes collection because database DBNAME has .metadata.json files 2018-04-06T10:47:22.964+0200 found collection DBNAME.system.users bson to restore to DBNAME.system.users 2018-04-06T10:47:22.964+0200 found collection metadata from DBNAME.system.users to restore to DBNAME.system.users 2018-04-06T10:47:22.964+0200 found collection DBNAME.typeincidents bson to restore to DBNAME.typeincidents 2018-04-06T10:47:22.964+0200 found collection metadata from DBNAME.typeincidents to restore to DBNAME.typeincidents . . . 2018-04-06T10:47:22.964+0200 finalizing intent manager with multi-database longest task first prioritizer 2018-04-06T10:47:22.964+0200 restoring up to 4 collections in parallel 2018-04-06T10:47:22.964+0200 starting restore routine with id=3 2018-04-06T10:47:22.964+0200 starting restore routine with id=0 2018-04-06T10:47:22.964+0200 starting restore routine with id=1 2018-04-06T10:47:22.964+0200 starting restore routine with id=2 2018-04-06T10:47:22.964+0200 reading metadata for DBNAME.evenements from /home/tmp/path/folder/evenements.metadata.json 2018-04-06T10:47:22.964+0200 creating collection DBNAME.evenements using options from metadata 2018-04-06T10:47:22.964+0200 using collection options: bson.D{bson.DocElem{Name:"create", Value:"evenements"}, bson.DocElem{Name:"idIndex", Value:mongorestore.IndexDocument
{Options:bson.M{"name":"_id_", "ns":"DBNAME.evenements"}, Key:bson.D{bson.DocElem{Name:"_id", Value:1}}, PartialFilterExpression:bson.D(nil)}}} 2018-04-06T10:47:22.965+0200 Failed: DBNAME.evenements: error creating collection DBNAME.evenements: error running create command: BSON field
'OperationSessionInfo.create' is a duplicate field


Thanks for help

Kevin Adistambha

unread,
May 22, 2018, 10:35:21 PM5/22/18
to mongodb-user

Hi Meher

I can replicate the error you’re seeing if I specify a subdirectory under the dump directory to mongorestore.

For example, dumping from MongoDB 2.4.14:

> mongodump -d test -o dump
connected to: 127.0.0.1
Wed May 23 12:22:13.926 DATABASE: test     to     dump/test
Wed May 23 12:22:13.927     test.system.indexes to dump/test/system.indexes.bson
Wed May 23 12:22:13.928          2 objects
Wed May 23 12:22:13.928     test.test to dump/test/test.bson
Wed May 23 12:22:13.929          100 objects
Wed May 23 12:22:13.929     Metadata for test.test to dump/test/test.metadata.json

Restoring to MongoDB 3.6.4 by specifying a subdirectory within the dump directory:

> mongorestore dump/test
2018-05-23T12:27:25.116+1000    preparing collections to restore from
2018-05-23T12:27:25.117+1000    don't know what to do with file "dump/test/system.indexes.bson", skipping...
2018-05-23T12:27:25.117+1000    don't know what to do with file "dump/test/test.bson", skipping...
2018-05-23T12:27:25.117+1000    don't know what to do with file "dump/test/test.metadata.json", skipping...
2018-05-23T12:27:25.117+1000    done

The restore was successful when I specify the root dump directory instead:

> mongorestore dump
2018-05-23T12:27:32.521+1000    preparing collections to restore from
2018-05-23T12:27:32.521+1000    done

Could you confirm that you’re pointing mongorestore to the dump root directory instead of a subdirectory in it?

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages