mongorestore --port <port number> <path to the backup> 

Consider the following example: 

mongorestore dump-2013-10-25/ 

Here, mongorestore imports the database backup in the dump-2013-10-25 directory to the mongod instance running on the localhost interface. 

Restore Point in Time Oplog Backup If you created your database dump using the --oplog option to ensure a point-in-time snapshot, call mongorestore with the --oplogReplay option, as in the following example: 

mongorestore --oplogReplay 

You may also consider using the mongorestore --objcheck option to check the integrity of objects while inserting them into the database, or you may consider the mongorestore --drop option to drop each collection from the database before restoring from backups. 

Restore Backups to Non-Local mongod Instances By default, mongorestore connects to a MongoDB instance running on the localhost interface (e.g. 127.0.0.1 ) and on the default port ( 27017 ). If you want to restore to a different host or port, use the --host and --port options. 

Consider the following example: 

mongorestore --host mongodb1.example.net --port 3017 --username user --password pass 

As above, you may specify username and password connections if your mongod requires authentication. 

## Human Intelligible Import/Export Formats 

MongoDB’s mongoimport and mongoexport tools allow you to work with your data in a human-readable Extended JSON or CSV format. This is useful for simple ingestion to or from a third-party system, and when you want to backup or export a small subset of your data. For more complex data migration tasks, you may want to write your own import and export scripts using a client driver to interact with the database. 

The examples in this section use the MongoDB tools mongoimport and mongoexport . These tools may also be useful for importing data into a MongoDB database from third party applications. 

If you want to simply copy a database or collection from one instance to another, consider using the copydb , clone , or cloneCollection commands, which may be more suited to this task. The mongo shell provides the db.copyDatabase() method. 

## Warning: 

## Collection Export with mongoexport 

Warning: Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods (page 184) for this kind of functionality. 

