mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
1357 lines
36 KiB
Groff
1357 lines
36 KiB
Groff
.\" Man page generated from reStructuredText.
|
|
.
|
|
.TH "MONGODUMP" "1" "Aug 16, 2019" "4.2" "mongodb-manual"
|
|
.SH NAME
|
|
mongodump \- MongoDB Data Dump Utility
|
|
.
|
|
.nr rst2man-indent-level 0
|
|
.
|
|
.de1 rstReportMargin
|
|
\\$1 \\n[an-margin]
|
|
level \\n[rst2man-indent-level]
|
|
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|
-
|
|
\\n[rst2man-indent0]
|
|
\\n[rst2man-indent1]
|
|
\\n[rst2man-indent2]
|
|
..
|
|
.de1 INDENT
|
|
.\" .rstReportMargin pre:
|
|
. RS \\$1
|
|
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
|
|
. nr rst2man-indent-level +1
|
|
.\" .rstReportMargin post:
|
|
..
|
|
.de UNINDENT
|
|
. RE
|
|
.\" indent \\n[an-margin]
|
|
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|
.nr rst2man-indent-level -1
|
|
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
|
|
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
|
|
..
|
|
.SS On this page
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
\fI\%Synopsis\fP
|
|
.IP \(bu 2
|
|
\fI\%Usage in Backup Strategy\fP
|
|
.IP \(bu 2
|
|
\fI\%Syntax\fP
|
|
.IP \(bu 2
|
|
\fI\%Behavior\fP
|
|
.IP \(bu 2
|
|
\fI\%Required Access\fP
|
|
.IP \(bu 2
|
|
\fI\%Options\fP
|
|
.IP \(bu 2
|
|
\fI\%Examples\fP
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.IP "macOS Sierra and Go 1.6 Incompatibility"
|
|
.sp
|
|
Users running on macOS Sierra require the 3.2.10 or newer version
|
|
of mongodump\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SH SYNOPSIS
|
|
.sp
|
|
\fI\%mongodump\fP is a utility for creating a binary export of the
|
|
contents of a database. \fI\%mongodump\fP can export data from
|
|
either \fBmongod\fP or \fBmongos\fP instances.
|
|
.SH USAGE IN BACKUP STRATEGY
|
|
.SS Standalones/Replica Sets
|
|
.sp
|
|
For standalone or a replica set, \fI\%mongodump\fP can be a part
|
|
of a backup strategy with
|
|
\fBmongorestore\fP for partial backups based on a query,
|
|
syncing from production to staging or development environments, or
|
|
changing the storage engine of a standalone.
|
|
.sp
|
|
For an overview of \fI\%mongodump\fP in conjunction with
|
|
\fBmongorestore\fP part of a backup and recovery strategy, see:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
/tutorial/backup\-and\-restore\-tools
|
|
.IP \(bu 2
|
|
/core/backups
|
|
.UNINDENT
|
|
.SS Sharded Cluster
|
|
.sp
|
|
Starting in MongoDB 4.2, \fI\%mongodump\fP and
|
|
\fBmongorestore\fP \fBcannot\fP be part of a backup
|
|
strategy for sharded clusters. These manual tools do not maintain
|
|
the atomicity guarantees of transactions across shards.
|
|
.sp
|
|
To maintain the atomicity guarantees of transactions across shards,
|
|
use the coordinated backup and restore services provided by:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
\fI\%MongoDB Atlas\fP,
|
|
.IP \(bu 2
|
|
\fI\%MongoDB Cloud Manager\fP, or
|
|
.IP \(bu 2
|
|
\fI\%MongoDB Ops Manager\fP\&.
|
|
.UNINDENT
|
|
.SH SYNTAX
|
|
.sp
|
|
Run \fI\%mongodump\fP from the system command line, not the \fBmongo\fP shell.
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump [options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS Connect to a MongoDB Instance
|
|
.sp
|
|
To connect to a local MongoDB instance running on port 27017 and use
|
|
the default settings to export the content, run
|
|
\fI\%mongodump\fP without any command\-line options:
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
To specify a host and/or port of the MongoDB instance, you can either:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
Specify the hostname and port in the \fI\%\-\-uri connection string\fP:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongodb0.example.com:27017" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
Specify the hostname and port in the \fI\%\-\-host\fP:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "mongodb0.example.com:27017" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
Specify the hostname and port in the \fI\%\-\-host\fP and \fI\%\-\-port\fP:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "mongodb0.example.com" \-\-port 27017 [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
For more information on the options available, see \fI\%Options\fP\&.
|
|
.SS Connect to a Replica Set
|
|
.sp
|
|
To connect to a replica set to export its data, you can either:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
Specify the replica set name and members in the \fI\%\-\-uri connection string\fP:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?replicaSet=myReplicaSetName" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
Specify the replica set name and members in the \fI\%\-\-host\fP:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "myReplicaSetName/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
By default, \fI\%mongodump\fP reads from the primary of the
|
|
replica set. To override the default, you can specify the read
|
|
preference:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
You can specify the read preference in the
|
|
\fI\%\-\-uri connection string\fP
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?replicaSet=myReplicaSetName&readPreference=secondary" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
If specifying the read preference tags, include the
|
|
\fBreadPreferenceTags\fP option:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017/?replicaSet=myReplicaSetName&readPreference=secondary&readPreferenceTags=region:east" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
You can specify the read preference in using the
|
|
\fI\%\-\-readPreference\fP command\-line
|
|
option. The command\-line option takes a string if specifying only the read preference mode:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "myReplicaSetName/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017" \-\-readPreference secondary [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
Or, the command\-line option can takes a quote\-enclosed document
|
|
\fB\(aq{ mode: <mode>, tagSets: [ <tag1>, ... ], maxStalenessSeconds:<num>}\(aq\fP
|
|
to specify the mode, the optional read preference tag
|
|
sets, and the optional
|
|
maxStalenessSeconds:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "myReplicaSetName/mongodb0.example.com:27017,mongodb1.example.com:27017,mongodb2.example.com:27017" \-\-readPreference \(aq{mode: "secondary", tagSets: [ { "region": "east" } ]}\(aq [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
For more information on the options available, see \fI\%Options\fP\&.
|
|
.SS Connect to a Sharded Cluster
|
|
.sp
|
|
To connect to a sharded cluster to export its data, you can either:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
Specify the hostname of the \fBmongos\fP instance in the
|
|
\fI\%\-\-uri connection string\fP
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongos0.example.com:27017" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
Specify the hostname and port of the \fBmongos\fP instance in the \fI\%\-\-host\fP
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "mongos0.example.com:27017" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
By default, \fI\%mongodump\fP reads from the primary of the
|
|
shard replica set. To override the default, you can specify the read
|
|
preference:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
You can specify the read preference in the
|
|
\fI\%\-\-uri connection string\fP
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongos0.example.com:27017/?readPreference=secondary" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
If specifying the read preference tags, include the
|
|
\fBreadPreferenceTags\fP option:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-uri "mongodb://mongos0.example.com:27017/?readPreference=secondary&readPreferenceTags=region:east" [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
You can specify the read preference in using the
|
|
\fI\%\-\-readPreference\fP command\-line
|
|
option. The command\-line option takes a string if specifying only the read preference mode:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "mongos0.example.com:27017" \-\-readPreference secondary [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
Or, the command\-line option can takes a quote\-enclosed document
|
|
\fB\(aq{ mode: <mode>, tagSets: [ <tag1>, ... ], maxStalenessSeconds: <num>}\(aq\fP
|
|
to specify the mode, the optional read preference tag
|
|
sets, and the optional
|
|
maxStalenessSeconds:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host "mongos0.example.com:27017" \-\-readPreference \(aq{mode: "secondary", tagSets: [ { "region": "east" } ]}\(aq [additional options]
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
For more information on the options available, see \fI\%Options\fP\&.
|
|
.sp
|
|
\fBSEE ALSO:\fP
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
\fI\%Examples\fP
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SH BEHAVIOR
|
|
.SS Read Preference
|
|
.sp
|
|
By default, \fI\%mongodump\fP uses read preference
|
|
\fBprimary\fP\&. To override the default, you can specify the
|
|
read preference in the
|
|
\fI\%\-\-readPreference\fP command\-line
|
|
option or in the \fI\%\-\-uri connection string\fP\&.
|
|
.sp
|
|
Starting in version 4.2, if you specify read preference in the URI
|
|
string and the \fI\%\-\-readPreference\fP
|
|
option, the \fI\%\-\-readPreference\fP
|
|
value overrides the read preference specified in the URI string.
|
|
.sp
|
|
In earlier versions, the two options are incompatible.
|
|
.SS Data Exclusion
|
|
.sp
|
|
\fI\%mongodump\fP excludes the content of the \fBlocal\fP database in its output.
|
|
.sp
|
|
\fI\%mongodump\fP output only captures the documents in the
|
|
database and does not include index data. \fBmongorestore\fP
|
|
or \fBmongod\fP must then rebuild the indexes after restoring
|
|
data.
|
|
.sp
|
|
Changed in version 3.4: MongoDB 3.4 added support for
|
|
read\-only views\&. By default,
|
|
\fI\%mongodump\fP only captures a view\(aqs metadata: it does not
|
|
create a binary export of the documents included in the view. To
|
|
capture the documents in a view use \fI\%\-\-viewsAsCollections\fP\&.
|
|
|
|
.SS Metadata Format
|
|
.sp
|
|
Starting in version 4.2, \fI\%mongodump\fP uses Extended
|
|
JSON v2.0 (Canonical) format
|
|
for the metadata files. To parse these files for restore, use
|
|
\fBmongorestore\fP version 4.2+ that supports Extended
|
|
JSON v2.0 (Canonical or Relaxed mode) format.
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.SS Tip
|
|
.sp
|
|
If general, use corresponding versions of \fI\%mongodump\fP
|
|
and \fBmongorestore\fP\&. That is, to restore data files
|
|
created with a specific version of \fI\%mongodump\fP, use the
|
|
corresponding version of \fBmongorestore\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS Overwrite Files
|
|
.sp
|
|
\fI\%mongodump\fP overwrites output files if they exist in the
|
|
backup data folder. Before running the \fI\%mongodump\fP command
|
|
multiple times, either ensure that you no longer need the files in the
|
|
output folder (the default is the \fBdump/\fP folder) or rename the
|
|
folders or files.
|
|
.SS Data Compression Handling
|
|
.sp
|
|
When run against a \fBmongod\fP instance that uses the
|
|
WiredTiger storage engine,
|
|
\fI\%mongodump\fP outputs uncompressed data.
|
|
.SS Working Set
|
|
.sp
|
|
\fI\%mongodump\fP can adversely affect performance of the
|
|
\fBmongod\fP\&. If your data is larger than system memory, the
|
|
\fI\%mongodump\fP will push the working set out of memory.
|
|
.SS FIPS
|
|
.sp
|
|
Starting in version 4.2, MongoDB removes the \fB\-\-sslFIPSMode\fP
|
|
option for mongodump\&. mongodump
|
|
will use FIPS compliant connections to
|
|
\fBmongod\fP/\fBmongos\fP if the
|
|
\fBmongod\fP/\fBmongos\fP instances are
|
|
configured to use FIPS mode\&.
|
|
.SH REQUIRED ACCESS
|
|
.sp
|
|
To run \fI\%mongodump\fP against a MongoDB deployment that has
|
|
access control enabled, you must have
|
|
privileges that grant \fBfind\fP action for each database to
|
|
back up. The built\-in \fBbackup\fP role provides the required
|
|
privileges to perform backup of any and all databases.
|
|
.sp
|
|
Changed in version 3.2.1: The \fBbackup\fP role provides additional privileges to back
|
|
up the \fBsystem.profile\fP
|
|
collection that exists when running with database profiling\&. Previously, users required
|
|
\fBread\fP access on this collection.
|
|
|
|
.SH OPTIONS
|
|
.sp
|
|
Changed in version 3.0.0: \fI\%mongodump\fP removed the \fB\-\-dbpath\fP as well as related
|
|
\fB\-\-directoryperdb\fP and \fB\-\-journal\fP options. To use
|
|
\fI\%mongodump\fP, you must run \fI\%mongodump\fP against a running
|
|
\fBmongod\fP or \fBmongos\fP instance as appropriate.
|
|
|
|
.INDENT 0.0
|
|
.TP
|
|
.B mongodump
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-help
|
|
Returns information on the options and use of \fBmongodump\fP\&.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-verbose, \-v
|
|
Increases the amount of internal reporting returned on standard output
|
|
or in log files. Increase the verbosity with the \fB\-v\fP form by
|
|
including the option multiple times, (e.g. \fB\-vvvvv\fP\&.)
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-quiet
|
|
Runs \fBmongodump\fP in a quiet mode that attempts to limit the amount
|
|
of output.
|
|
.sp
|
|
This option suppresses:
|
|
.INDENT 7.0
|
|
.IP \(bu 2
|
|
output from database commands
|
|
.IP \(bu 2
|
|
replication activity
|
|
.IP \(bu 2
|
|
connection accepted events
|
|
.IP \(bu 2
|
|
connection closed events
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-version
|
|
Returns the \fBmongodump\fP release number.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-uri <connectionString>
|
|
New in version 3.4.6.
|
|
|
|
.sp
|
|
Specify a resolvable URI
|
|
connection string (enclose in quotes) to connect to the MongoDB deployment.
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
\-\-uri "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
For information on the components of the connection string, see
|
|
the Connection String URI Format documentation.
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
For TLS/SSL options, use the command\-line options instead of the
|
|
URI options for TLS/SSL (Available starting in
|
|
4.2)\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
\fBIMPORTANT:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
The following command\-line options cannot be used in conjunction
|
|
with \fI\%\-\-uri\fP option:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
\fI\%\-\-host\fP
|
|
.IP \(bu 2
|
|
\fI\%\-\-port\fP
|
|
.IP \(bu 2
|
|
\fI\%\-\-db\fP
|
|
.IP \(bu 2
|
|
\fI\%\-\-username\fP
|
|
.IP \(bu 2
|
|
\fI\%\-\-password\fP (if the
|
|
URI connection string also includes the password)
|
|
.IP \(bu 2
|
|
\fI\%\-\-authenticationDatabase\fP
|
|
.IP \(bu 2
|
|
\fI\%\-\-authenticationMechanism\fP
|
|
.UNINDENT
|
|
.sp
|
|
Instead, specify these options as part of your \fI\%\-\-uri\fP
|
|
connection string.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-host <hostname><:port>, \-h <hostname><:port>
|
|
\fIDefault\fP: localhost:27017
|
|
.sp
|
|
Specifies a resolvable hostname for the \fBmongod\fP to which to
|
|
connect. By default, the \fBmongodump\fP attempts to connect to a MongoDB
|
|
instance running on the localhost on port number \fB27017\fP\&.
|
|
.sp
|
|
To connect to a replica set, specify the
|
|
\fBreplSetName\fP and a seed list of set members, as in
|
|
the following:
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
\-\-host <replSetName>/<hostname1><:port>,<hostname2><:port>,<...>
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
When specifying the replica set list format, \fBmongodump\fP always connects to
|
|
the primary\&.
|
|
.sp
|
|
You can also connect to any single member of the replica set by specifying
|
|
the host and port of only that member:
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
\-\-host <hostname1><:port>
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
Changed in version 3.0.0: If you use IPv6 and use the \fB<address>:<port>\fP format, you must
|
|
enclose the portion of an address and port combination in
|
|
brackets (e.g. \fB[<address>]\fP).
|
|
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-host\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-port <port>
|
|
\fIDefault\fP: 27017
|
|
.sp
|
|
Specifies the TCP port on which the MongoDB instance listens for
|
|
client connections.
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-port\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-ipv6
|
|
\fIRemoved in version 3.0.\fP
|
|
.sp
|
|
Enables IPv6 support and allows \fBmongodump\fP to connect to the
|
|
MongoDB instance using an IPv6 network. Prior to MongoDB 3.0, you
|
|
had to specify \fI\%\-\-ipv6\fP to use IPv6. In MongoDB 3.0 and later, IPv6
|
|
is always enabled.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-ssl
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Enables connection to a \fBmongod\fP or \fBmongos\fP that has
|
|
TLS/SSL support enabled.
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-sslCAFile <filename>
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Specifies the \fB\&.pem\fP file that contains the root certificate chain
|
|
from the Certificate Authority. Specify the file name of the
|
|
\fB\&.pem\fP file using relative or absolute paths.
|
|
.sp
|
|
Starting in version 3.4, if \fB\-\-tlsCAFile\fP/\fBnet.tls.CAFile\fP (or
|
|
their aliases \fB\-\-sslCAFile\fP/\fBnet.ssl.CAFile\fP) is not specified
|
|
and you are not using x.509 authentication, the system\-wide CA
|
|
certificate store will be used when connecting to an TLS/SSL\-enabled
|
|
server.
|
|
.sp
|
|
To use x.509 authentication, \fB\-\-tlsCAFile\fP or \fBnet.tls.CAFile\fP
|
|
must be specified unless using \fB\-\-tlsCertificateSelector\fP or
|
|
\fB\-\-net.tls.certificateSelector\fP\&. Or if using the \fBssl\fP aliases,
|
|
\fB\-\-sslCAFile\fP or \fBnet.ssl.CAFile\fP must be specified unless using
|
|
\fB\-\-sslCertificateSelector\fP or \fBnet.ssl.certificateSelector\fP\&.
|
|
.sp
|
|
\fBWARNING:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
\fBVersion 3.2 and earlier:\fP For TLS/SSL connections (\fB\-\-ssl\fP) to
|
|
\fBmongod\fP and \fBmongos\fP, if the \fBmongodump\fP runs without the
|
|
\fI\%\-\-sslCAFile\fP, \fBmongodump\fP will not attempt
|
|
to validate the server certificates. This creates a vulnerability
|
|
to expired \fBmongod\fP and \fBmongos\fP certificates as
|
|
well as to foreign processes posing as valid \fBmongod\fP or
|
|
\fBmongos\fP instances. Ensure that you \fIalways\fP specify the
|
|
CA file to validate the server certificates in cases where
|
|
intrusion is a possibility.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-sslPEMKeyFile <filename>
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Specifies the \fB\&.pem\fP file that contains both the TLS/SSL certificate
|
|
and key. Specify the file name of the \fB\&.pem\fP file using relative
|
|
or absolute paths.
|
|
.sp
|
|
This option is required when using the \fI\%\-\-ssl\fP option to connect
|
|
to a \fBmongod\fP or \fBmongos\fP that has
|
|
\fBCAFile\fP enabled \fIwithout\fP
|
|
\fBallowConnectionsWithoutCertificates\fP\&.
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-sslPEMKeyPassword <value>
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Specifies the password to de\-crypt the certificate\-key file (i.e.
|
|
\fI\%\-\-sslPEMKeyFile\fP). Use the \fI\%\-\-sslPEMKeyPassword\fP option only if the
|
|
certificate\-key file is encrypted. In all cases, the \fBmongodump\fP will
|
|
redact the password from all logging and reporting output.
|
|
.sp
|
|
If the private key in the PEM file is encrypted and you do not specify
|
|
the \fI\%\-\-sslPEMKeyPassword\fP option, the \fBmongodump\fP will prompt for a passphrase. See
|
|
ssl\-certificate\-password\&.
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-sslCRLFile <filename>
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Specifies the \fB\&.pem\fP file that contains the Certificate Revocation
|
|
List. Specify the file name of the \fB\&.pem\fP file using relative or
|
|
absolute paths.
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-sslAllowInvalidCertificates
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Bypasses the validation checks for server certificates and allows
|
|
the use of invalid certificates. When using the
|
|
\fBallowInvalidCertificates\fP setting, MongoDB logs as a
|
|
warning the use of the invalid certificate.
|
|
.sp
|
|
Starting in MongoDB 4.0, if you specify
|
|
\fB\-\-sslAllowInvalidCertificates\fP or
|
|
\fBnet.ssl.allowInvalidCertificates: true\fP (or in MongoDB 4.2, the
|
|
alias \fB\-\-tlsAllowInvalidateCertificates\fP or
|
|
\fBnet.tls.allowInvalidCertificates: true\fP) when using x.509
|
|
authentication, an invalid certificate is only sufficient to
|
|
establish a TLS/SSL connection but is \fIinsufficient\fP for
|
|
authentication.
|
|
.sp
|
|
# We created a separate blurb for tls in the ssl\-clients page.
|
|
.sp
|
|
\fBWARNING:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
Although available, avoid using the
|
|
\fB\-\-sslAllowInvalidCertificates\fP option if possible. If the use of
|
|
\fB\-\-sslAllowInvalidCertificates\fP is necessary, only use the option
|
|
on systems where intrusion is not possible.
|
|
.sp
|
|
If the \fBmongo\fP shell (and other
|
|
mongodb\-tools\-support\-ssl) runs with the
|
|
\fB\-\-sslAllowInvalidCertificates\fP option, the
|
|
\fBmongo\fP shell (and other
|
|
mongodb\-tools\-support\-ssl) will not attempt to validate
|
|
the server certificates. This creates a vulnerability to expired
|
|
\fBmongod\fP and \fBmongos\fP certificates as
|
|
well as to foreign processes posing as valid
|
|
\fBmongod\fP or \fBmongos\fP instances. If you
|
|
only need to disable the validation of the hostname in the
|
|
TLS/SSL certificates, see \fB\-\-sslAllowInvalidHostnames\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-sslAllowInvalidHostnames
|
|
New in version 3.0.
|
|
|
|
.sp
|
|
Disables the validation of the hostnames in TLS/SSL certificates. Allows
|
|
\fBmongodump\fP to connect to MongoDB instances even if the hostname in their
|
|
certificates do not match the specified hostname.
|
|
.sp
|
|
For more information about TLS/SSL and MongoDB, see
|
|
/tutorial/configure\-ssl and
|
|
/tutorial/configure\-ssl\-clients .
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-username <username>, \-u <username>
|
|
Specifies a username with which to authenticate to a MongoDB database
|
|
that uses authentication. Use in conjunction with the \fI\%\-\-password\fP and
|
|
\fI\%\-\-authenticationDatabase\fP options.
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-username\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-password <password>, \-p <password>
|
|
Specifies a password with which to authenticate to a MongoDB database
|
|
that uses authentication. Use in conjunction with the \fI\%\-\-username\fP and
|
|
\fI\%\-\-authenticationDatabase\fP options.
|
|
.sp
|
|
Changed in version 3.0.2: To prompt the user
|
|
for the password, pass the \fI\%\-\-username\fP option without
|
|
\fI\%\-\-password\fP or specify an empty string as the \fI\%\-\-password\fP value,
|
|
as in \fB\-\-password ""\fP .
|
|
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-password\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-authenticationDatabase <dbname>
|
|
Specifies the authentication database where the specified \fI\%\-\-username\fP has been created.
|
|
See user\-authentication\-database\&.
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-authenticationDatabase\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
If you do not specify an authentication database, \fBmongodump\fP
|
|
assumes that the database specified to export holds the user\(aqs credentials.
|
|
.sp
|
|
If you do not specify an authentication database or a database to
|
|
export, \fBmongodump\fP assumes the \fBadmin\fP database holds the user\(aqs
|
|
credentials.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-authenticationMechanism <name>
|
|
\fIDefault\fP: SCRAM\-SHA\-1
|
|
.sp
|
|
Specifies the authentication mechanism the \fBmongodump\fP instance uses to
|
|
authenticate to the \fBmongod\fP or \fBmongos\fP\&.
|
|
.sp
|
|
Changed in version 4.0: MongoDB removes support for the deprecated MongoDB
|
|
Challenge\-Response (\fBMONGODB\-CR\fP) authentication mechanism.
|
|
.sp
|
|
MongoDB adds support for SCRAM mechanism using the SHA\-256 hash
|
|
function (\fBSCRAM\-SHA\-256\fP).
|
|
|
|
.TS
|
|
center;
|
|
|l|l|.
|
|
_
|
|
T{
|
|
Value
|
|
T} T{
|
|
Description
|
|
T}
|
|
_
|
|
T{
|
|
SCRAM\-SHA\-1
|
|
T} T{
|
|
\fI\%RFC 5802\fP standard
|
|
Salted Challenge Response Authentication Mechanism using the SHA\-1
|
|
hash function.
|
|
T}
|
|
_
|
|
T{
|
|
SCRAM\-SHA\-256
|
|
T} T{
|
|
\fI\%RFC 7677\fP standard
|
|
Salted Challenge Response Authentication Mechanism using the SHA\-256
|
|
hash function.
|
|
.sp
|
|
Requires featureCompatibilityVersion set to \fB4.0\fP\&.
|
|
.sp
|
|
New in version 4.0.
|
|
T}
|
|
_
|
|
T{
|
|
MONGODB\-X509
|
|
T} T{
|
|
MongoDB TLS/SSL certificate authentication.
|
|
T}
|
|
_
|
|
T{
|
|
GSSAPI (Kerberos)
|
|
T} T{
|
|
External authentication using Kerberos. This mechanism is
|
|
available only in \fI\%MongoDB Enterprise\fP\&.
|
|
T}
|
|
_
|
|
T{
|
|
PLAIN (LDAP SASL)
|
|
T} T{
|
|
External authentication using LDAP. You can also use \fBPLAIN\fP
|
|
for authenticating in\-database users. \fBPLAIN\fP transmits
|
|
passwords in plain text. This mechanism is available only in
|
|
\fI\%MongoDB Enterprise\fP\&.
|
|
T}
|
|
_
|
|
.TE
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-authenticationMechanism\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-gssapiServiceName
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Specify the name of the service using GSSAPI/Kerberos\&. Only required if the service does not use the
|
|
default name of \fBmongodb\fP\&.
|
|
.sp
|
|
This option is available only in MongoDB Enterprise.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-gssapiHostName
|
|
New in version 2.6.
|
|
|
|
.sp
|
|
Specify the hostname of a service using GSSAPI/Kerberos\&. \fIOnly\fP required if the hostname of a machine does
|
|
not match the hostname resolved by DNS.
|
|
.sp
|
|
This option is available only in MongoDB Enterprise.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-db <database>, \-d <database>
|
|
Specifies a database to backup. If you do not specify a database,
|
|
\fI\%mongodump\fP copies all databases in this instance into the dump
|
|
files.
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
You cannot specify both \fI\%\-\-db\fP and \fI\%\-\-uri\fP\&.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-collection <collection>, \-c <collection>
|
|
Specifies a collection to backup. If you do not specify a collection,
|
|
this option copies all collections in the specified database or instance
|
|
to the dump files.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-query <json>, \-q <json>
|
|
Provides a JSON document as a query that optionally limits
|
|
the documents included in the output of \fI\%mongodump\fP\&. To
|
|
use the \fB\-\-query\fP option, you must also specify the
|
|
\fI\%\-\-collection\fP option.
|
|
.sp
|
|
You must enclose the query document in single quotes (\fB\(aq{ ... }\(aq\fP) to ensure that it does
|
|
not interact with your shell environment.
|
|
.sp
|
|
Starting in MongoDB 4.2, the query \fBmust\fP be in
|
|
Extended JSON v2 format (either relaxed or canonical/strict
|
|
mode), including enclosing the
|
|
field names and operators in quotes. For example:
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-d test \-c records \-q \(aq{ "a": { "$gte": 3 }, "date": { "$lt": { "$date": "2016\-01\-01T00:00:00.000Z" } } }\(aq
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-queryFile <path>
|
|
New in version 3.2.
|
|
|
|
.sp
|
|
Specifies the path to a file containing a JSON document as a query
|
|
filter that limits the documents included in the output of
|
|
\fI\%mongodump\fP\&. \fI\%\-\-queryFile\fP enables you to create query filters that
|
|
are too large to fit in your terminal\(aqs buffer.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-readPreference <string|document>
|
|
\fIDefault\fP: \fBprimary\fP
|
|
.sp
|
|
Specifies the read preference for
|
|
\fBmongodump\fP\&. The \fI\%\-\-readPreference\fP option can take:
|
|
.INDENT 7.0
|
|
.IP \(bu 2
|
|
A string if specifying only the read preference mode:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
\-\-readPreference secondary
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.IP \(bu 2
|
|
A quote\-enclosed document to specify the mode, the optional
|
|
read preference tag sets, and the
|
|
optional maxStalenessSeconds:
|
|
.INDENT 2.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
\-\-readPreference \(aq{mode: "secondary", tagSets: [ { "region": "east" } ], maxStalenessSeconds: 120}\(aq
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
If specifying the maxStalenessSeconds, the value must be greater than or equal to 90.
|
|
.sp
|
|
New in version 4.2.
|
|
|
|
.UNINDENT
|
|
.sp
|
|
\fBmongodump\fP defaults to \fBprimary\fP
|
|
read preference\&.
|
|
.sp
|
|
Starting in version 4.2, if the read
|
|
preference is also included in the \fI\%\-\-uri connection string\fP, the command\-line \fI\%\-\-readPreference\fP overrides the read preference
|
|
specified in the URI string.
|
|
.sp
|
|
\fBWARNING:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
Using a read preference other than
|
|
\fBprimary\fP with a connection to a \fBmongos\fP may produce
|
|
inconsistencies, duplicates, or result in missed documents.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-forceTableScan
|
|
By default, \fBmongodump\fP uses the \fB_id\fP index when scanning
|
|
collections with that index is available (e.g.
|
|
3.4\-reference\-views do not have any indexes). Specify \fI\%\-\-forceTableScan\fP
|
|
to direct \fBmongodump\fP to scan collection data without the use of the
|
|
\fB_id\fP index.
|
|
.sp
|
|
\fI\%\-\-forceTableScan\fP does not ensure a point\-in\-time snapshot. Use
|
|
\fI\%\-\-oplog\fP to create a point\-in\-time snapshot.
|
|
.sp
|
|
You cannot use \fI\%\-\-forceTableScan\fP with the \fI\%\-\-query\fP option.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-gzip
|
|
New in version 3.2.
|
|
|
|
.sp
|
|
Compresses the output. If \fI\%mongodump\fP outputs to the dump
|
|
directory, the new feature compresses the individual files. The files
|
|
have the suffix \fB\&.gz\fP\&.
|
|
.sp
|
|
If \fI\%mongodump\fP outputs to an archive file or the standard
|
|
out stream, the new feature compresses the archive file or the data
|
|
output to the stream.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-out <path>, \-o <path>
|
|
Specifies the directory where \fI\%mongodump\fP will write
|
|
BSON files for the dumped databases. By default,
|
|
\fI\%mongodump\fP saves output files in a directory named
|
|
\fBdump\fP in the current working directory.
|
|
.sp
|
|
To send the database dump to standard output, specify "\fB\-\fP" instead of
|
|
a path. Write to standard output if you want process the output before
|
|
saving it, such as to use \fBgzip\fP to compress the dump. When writing
|
|
standard output, \fI\%mongodump\fP does not write the metadata that
|
|
writes in a \fB<dbname>.metadata.json\fP file when writing to files
|
|
directly.
|
|
.sp
|
|
You cannot use the \fB\-\-archive\fP option with the
|
|
\fI\%\-\-out\fP option.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-archive <file or null>
|
|
New in version 3.2.
|
|
|
|
.sp
|
|
Writes the output to a single archive file or to the standard output
|
|
(\fBstdout\fP).
|
|
.sp
|
|
To output the dump to an archive file, run \fI\%mongodump\fP with the new
|
|
\fB\-\-archive\fP option and the archive filename.
|
|
.sp
|
|
To output the dump to the standard output stream in order to pipe to
|
|
another process, run \fI\%mongodump\fP with the \fBarchive\fP option
|
|
but \fIomit\fP the filename.
|
|
.sp
|
|
You cannot use the \fB\-\-archive\fP option with the
|
|
\fI\%\-\-out\fP option.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-oplog
|
|
Creates a file named \fBoplog.bson\fP as part of the
|
|
\fI\%mongodump\fP output. The \fBoplog.bson\fP file, located in
|
|
the top level of the output directory, contains oplog entries that
|
|
occur during the \fI\%mongodump\fP operation. This file provides
|
|
an effective point\-in\-time snapshot of the state of a
|
|
\fBmongod\fP instance. To restore to a specific point\-in\-time
|
|
backup, use the output created with this option in conjunction with
|
|
\fBmongorestore \-\-oplogReplay\fP\&.
|
|
.sp
|
|
Without \fI\%\-\-oplog\fP, if there are write operations during the dump
|
|
operation, the dump will not reflect a single moment in time. Changes
|
|
made to the database during the update process can affect the output of
|
|
the backup.
|
|
.sp
|
|
\fI\%\-\-oplog\fP has no effect when running \fI\%mongodump\fP
|
|
against a \fBmongos\fP instance to dump the entire contents of a
|
|
sharded cluster. However, you can use \fI\%\-\-oplog\fP to dump
|
|
individual shards.
|
|
.sp
|
|
\fI\%\-\-oplog\fP only works against nodes that maintain an
|
|
oplog\&. This includes all members of a replica set.
|
|
.sp
|
|
\fI\%\-\-oplog\fP does not dump the oplog collection.
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
To use \fI\%mongodump\fP with \fI\%\-\-oplog\fP, you must create a full dump of
|
|
a replica set member. \fI\%mongodump\fP with \fI\%\-\-oplog\fP fails
|
|
if you use any of the following options to limit the data to be dumped:
|
|
.INDENT 0.0
|
|
.IP \(bu 2
|
|
\fI\%\-\-db\fP
|
|
.IP \(bu 2
|
|
\fI\%\-\-collection\fP
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
\fBSEE ALSO:\fP
|
|
.INDENT 7.0
|
|
.INDENT 3.5
|
|
\fBmongorestore \-\-oplogReplay\fP
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-dumpDbUsersAndRoles
|
|
Includes user and role definitions in the database\(aqs dump directory
|
|
when performing \fI\%mongodump\fP on a specific database. This
|
|
option applies only when you specify a database in the
|
|
\fI\%\-\-db\fP option. MongoDB always includes user and role
|
|
definitions when \fI\%mongodump\fP applies to an entire instance
|
|
and not just a specific database.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-excludeCollection string
|
|
New in version 3.0.
|
|
|
|
.sp
|
|
Excludes the specified collection from the \fBmongodump\fP output.
|
|
To exclude multiple collections, specify the \fI\%\-\-excludeCollection\fP multiple times.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-excludeCollectionsWithPrefix string
|
|
New in version 3.0.
|
|
|
|
.sp
|
|
Excludes all collections with a specified prefix from the \fBmongodump\fP
|
|
outputs. To specify multiple prefixes, specify the \fI\%\-\-excludeCollectionsWithPrefix\fP multiple
|
|
times.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-numParallelCollections int, \-j int
|
|
\fIDefault\fP: 4
|
|
.sp
|
|
Number of collections \fBmongodump\fP should export
|
|
in parallel.
|
|
.UNINDENT
|
|
.INDENT 0.0
|
|
.TP
|
|
.B \-\-viewsAsCollections
|
|
New in version 3.4.
|
|
|
|
.sp
|
|
When specified, \fBmongodump\fP exports read\-only views as collections. For each view, \fBmongodump\fP will
|
|
produce a BSON file containing the documents in the view. If you
|
|
\fBmongorestore\fP the produced BSON file, the view will be
|
|
restored as a collection\&.
|
|
.sp
|
|
If you do \fInot\fP include \fI\%\-\-viewsAsCollections\fP,
|
|
\fBmongodump\fP captures each view\(aqs metadata. If you include a
|
|
view\(aqs metadata file in a \fBmongorestore\fP operation, the view
|
|
is recreated.
|
|
.UNINDENT
|
|
.SH EXAMPLES
|
|
.SS \fBmongodump\fP a Collection
|
|
.sp
|
|
The following operation creates a dump file that contains only the
|
|
collection named \fBcollection\fP in the database named \fBtest\fP\&. In
|
|
this case the database is running on the local interface on port
|
|
\fB27017\fP:
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-db test \-\-collection collection
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS \fBmongodump\fP a Database Excluding Specified Collections
|
|
.sp
|
|
The following operation dumps all collections in the \fBtest\fP database
|
|
except for \fBusers\fP and \fBsalaries\fP:
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-db test \-\-excludeCollection=users \-\-excludeCollection=salaries
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS \fBmongodump\fP with Access Control
|
|
.sp
|
|
In the next example, \fI\%mongodump\fP creates a database dump
|
|
located at \fB/opt/backup/mongodump\-2011\-10\-24\fP, from a database
|
|
running on port \fB37017\fP on the host \fBmongodb1.example.net\fP and
|
|
authenticating using the username \fBuser\fP and the password
|
|
\fBpass\fP, as follows:
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-host mongodb1.example.net \-\-port 37017 \-\-username user \-\-password "pass" \-\-out /opt/backup/mongodump\-2011\-10\-24
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS Output to an Archive File
|
|
.sp
|
|
New in version 3.2.
|
|
|
|
.sp
|
|
To output the dump to an archive file, run \fI\%mongodump\fP with the
|
|
\fB\-\-archive\fP option and the archive filename. For example, the following
|
|
operation creates a file \fBtest.20150715.archive\fP that contains the dump
|
|
of the \fBtest\fP database.
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-archive=test.20150715.archive \-\-db test
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS Output an Archive to Standard Output
|
|
.sp
|
|
New in version 3.2.
|
|
|
|
.sp
|
|
To output the archive to the standard output stream in order to pipe to
|
|
another process, run \fI\%mongodump\fP with the \fBarchive\fP
|
|
option but \fIomit\fP the filename:
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-archive \-\-db test \-\-port 27017 | mongorestore \-\-archive \-\-port 27018
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
\fBNOTE:\fP
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
You cannot use the \fB\-\-archive\fP option with the
|
|
\fI\%\-\-out\fP option.
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SS Compress the Output
|
|
.sp
|
|
To compress the files in the output dump directory, run
|
|
\fI\%mongodump\fP with the new \fB\-\-gzip\fP option. For example,
|
|
the following operation outputs compressed files into the default
|
|
\fBdump\fP directory.
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-gzip \-\-db test
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.sp
|
|
To compress the archive file output by \fI\%mongodump\fP, use the
|
|
\fB\-\-gzip\fP option in conjunction with the \fI\%\-\-archive\fP
|
|
option, specifying the name of the compressed file.
|
|
.INDENT 0.0
|
|
.INDENT 3.5
|
|
.sp
|
|
.nf
|
|
.ft C
|
|
mongodump \-\-archive=test.20150715.gz \-\-gzip \-\-db test
|
|
.ft P
|
|
.fi
|
|
.UNINDENT
|
|
.UNINDENT
|
|
.SH AUTHOR
|
|
MongoDB Documentation Project
|
|
.SH COPYRIGHT
|
|
2008-2019
|
|
.\" Generated by docutils manpage writer.
|
|
.
|