mongorestore does not restore all documents in a collection

470 views
Skip to first unread message

Alan Evangelista

unread,
Oct 18, 2016, 12:56:31 PM10/18/16
to mongodb-user
I'm trying to restore a mongo database backup in a new server, but mongorestore only restore 1 document of the 499 found in the backup. Trying to restore the whole database or a single collection brings the same result. I see no errors in /var/log/mongodb/mongodb.log

# mongorestore -d pulp_database -c repos repomgr.ltc.br.ibm.com-repomgr-backup-2016-10-14_23\:00\:01-0300/dump/pulp_database/repos.bson
connected to: 127.0.0.1
Tue Oct 18 10:54:56.301 repomgr.ltc.br.ibm.com-repomgr-backup-2016-10-14_23:00:01-0300/dump/pulp_database/repos.bson
Tue Oct 18 10:54:56.301     going into namespace [pulp_database.repos]
Tue Oct 18 10:54:56.302 warning: Restoring to pulp_database.repos without dropping. Restored data will be inserted without raising errors; check your server log
499 objects found
Tue Oct 18 10:54:56.310     Creating index: { key: { _id: 1 }, ns: "pulp_database.repos", name: "_id_" }
Tue Oct 18 10:54:56.369     Creating index: { key: { id: -1 }, unique: true, ns: "pulp_database.repos", background: true, name: "id_-1" }
 
 
 
# mongo
MongoDB shell version: 2.4.9-rc0
connecting to: test
> use pulp_database
switched to db pulp_database
> db.repos.find()
{ "_id" : ObjectId("56aa20de721673384dbbe4ab"), "scratchpad" : {  }, "display_name" : "set-3.1.1.0.0.0-251-binary", "description" : null, "_ns" : "repos", "notes" : { "inputs" : [     "in-3.1.1.0-alpha-release-20160128120822-binary",   "in-3.1.1.0-alpha-installer-20160122131600-binary",     "in-3.1.1.0-alpha-pmlinux-20150828184000-binary",   "in-3.1.1.0-alpha-sep-20150815081200-binary",   "in-3.1.1.0-alpha-mcp-20160127075100-binary" ], "tags" : [ ], "product_version" : "3.1.1.0.0.0", "set_level" : 1, "signed" : false, "_repo-type" : "rpm-repo", "rpm_type" : "binary", "product_milestone" : "alpha" }, "content_unit_counts" : { "package_group" : 2, "rpm" : 1499 }, "id" : "set-3.1.1.0.0.0-251-binary" }

Any help is welcome.

Kevin Adistambha

unread,
Nov 1, 2016, 3:08:18 AM11/1/16
to mongodb-user

Hi Alan

This line seems to indicate that the collection already exists:

Tue Oct 18 10:54:56.302 warning: Restoring to pulp_database.repos without dropping. Restored data will be inserted without raising errors; check your server log

Have you tried restoring with the --drop option to instruct mongorestore to drop the collection before restoring?

Also, mongorestore performs object checking by default to ensure that it won’t insert invalid data into the database. It could be worthwhile to redo your mongodump just to see if there’s any issue with the earlier dump.

Furthermore, it seems that you are running a very old version of MongoDB:

MongoDB shell version: 2.4.9-rc0

Please note that MongoDB 2.4 series was released in March 2013, and reached its end-of-life on March 2016. The current MongoDB version is 3.2.10, which contains many improvements over 2.4. You may want to review your upgrade options if applicable.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages