MongoDB Documentation, Release 3.0.4 mongodump --collection myCollection --db test This operation creates a dump of the collection named myCollection from the database test in a dump/ subdi- rectory of the current working directory. mongodump overwrites output files if they exist in the backup data folder. Before running the mongodump command multiple times, either ensure that you no longer need the files in the output folder (the default is the dump/ folder) or rename the folders or files. Point in Time Operation Using Oplogs Use the --oplog option with mongodump to collect the oplog entries to build a point-in-time snapshot of a database within a replica set. With --oplog , mongodump copies all the data from the source database as well as all of the oplog entries from the beginning to the end of the backup procedure. This operation, in conjunction with mongorestore --oplogReplay , allows you to restore a backup that reflects the specific moment in time that corresponds to when mongodump completed creating the dump file. Create Backups from Non-Local mongod Instances The --host and --port options for mongodump allow you to connect to and backup from a remote host. Consider the following example: mongodump --host mongodb1.example.net --port 3017 --username user --password pass --out On any mongodump command you may, as above, specify username and password credentials to specify database authentication. Restore a Database with mongorestore To restore collection data to a database with authentication enabled, the connecting user must possess the appropriate user roles. To restore a single database, the connecting user must possess the readWrite (page 406) role for that database. Alternatively, the readWriteAnyDatabase (page 412) provides access to restore any database. The restore (page 411) role also provides the requisite permissions. Changed in version 2.6. To restore users and user-defined roles (page 325) on a given database, you must have access to the admin database. MongoDB stores the user data and role definitions for all databases in the admin database. Specifically, to restore users to a given database, you must have the insert (page 419) action (page 419) on the admin database’s admin.system.users (page 291) collection. The restore (page 411) role provides this privilege. To restore user-defined roles to a database, you must have the insert (page 419) action on the admin database’s admin.system.roles (page 291) collection. The restore (page 411) role provides this privilege. If your database is running with authentication enabled, you must possess the userAdmin (page 407) role on the database you are restoring, or the userAdminAnyDatabase (page 412) role, which allows you to restore user data to any database. The restore (page 411) role also provides the requisite privileges. Basic mongorestore Operations The mongorestore utility restores a binary backup created by mongodump . By default, mongorestore looks for a database backup in the dump/ directory. The mongorestore utility restores data by connecting to a running mongod or mongos directly. mongorestore can restore either an entire database backup or a subset of the backup. To use mongorestore to connect to an active mongod or mongos , use a command with the following prototype form: 251 5.2. Administration Tutorials