Create mongo backup/restore without indexes
sudo mongorestore --db dbName ./dumpPath/ --noIndexRestore
The mongodump
utility creates a binary export of data from MongoDB and saves index definitions and collection options in a metadata.json
associated with each database dumped. The index details do not take any significant space in your backup, and will normally be used by mongorestore
to re-ensure indexes after each data for each collection is imported from a dump.
If you want to avoid creating any new secondary indexes after the restore completes, mongorestore
has a --noIndexRestore
option.
Note: The default _id
index is required, and always created.
incrementally restore a mongo db without restoring the indexes?
The option for --noIndexRestore
applies whether or not you are restoring into an existing database. If you mongorestore
into an existing database with indexes using the --noIndexRestore
option, no new index definitions will be added but existing indexes will still be updated as data is inserted.
Incremental backup & restore is really a separate question unless you have a simplistic use case: inserting new documents from successive dumps.
As at MongoDB 2.6, the mongorestore
utility only inserts documents (i.e. there is no option for updates/upserts). You can use mongorestore
to insert multiple dumps into an existing collection, but any documents causing duplicate key exceptions (eg. _id
) will be skipped.
I would normally expect that an incremental backup & restore implies taking a delta of changes (all inserts/updates/deletions since a prior backup) and being able to re-apply those to an older copy of the same data. To achieve an incremental backup, you need a history of changes to data, which in MongoDB's case would be provided by the replica set operation log (oplog).