summaryrefslogtreecommitdiff
path: root/debian/mongodump.1
blob: e1a3b0ed1ab0cc3ba6aabec3010129db61bc7861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
.\" Man page generated from reStructuredText.
.
.TH "MONGODUMP" "1" "Jun 21, 2018" "4.0" "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\%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 "Mac OSX Sierra and Go 1.6 Incompatibility"
.sp
Users running on Mac OSX 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.
.sp
\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. However, the use of \fI\%mongodump\fP and
\fBmongorestore\fP as a backup strategy can be problematic for
sharded clusters and replica sets.
.sp
Run \fI\%mongodump\fP from the system command line, not the \fBmongo\fP shell.
.sp
For an overview of \fI\%mongodump\fP in conjunction with
\fBmongorestore\fP part of a backup and recovery strategy, see
/tutorial/backup\-and\-restore\-tools\&.
.sp
\fBSEE ALSO:\fP
.INDENT 0.0
.INDENT 3.5
\fBmongorestore\fP,
/tutorial/backup\-sharded\-cluster\-with\-database\-dumps
and /core/backups\&.
.UNINDENT
.UNINDENT
.SH BEHAVIOR
.SS Data Exclusion
.sp
\fI\%mongodump\fP excludes the content of the \fBlocal\fP database in its output.
.sp
\fI\%mongodump\fP only captures the documents in the database in its
backup data 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’s 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 Read Preference
.SS Replica Sets
.sp
Changed in version 3.2.0: The choice of target or targets for the \fI\%\-\-host\fP
parameter affects the read preference of \fI\%mongodump\fP
when connecting to a replica set.
.INDENT 0.0
.IP \(bu 2
If the string passed to \fB\-\-host\fP is prefixed by the replica set name,
\fI\%mongodump\fP reads from the \fBprimary\fP replica set
member by default. For example:
.INDENT 2.0
.INDENT 3.5
.sp
.nf
.ft C
\-\-host "replSet/rep1.example.net:27017,rep2.example.net:27017,rep3.example.net:27017"
.ft P
.fi
.UNINDENT
.UNINDENT
.IP \(bu 2
If the string passed to \fB\-\-host\fP contains a list of
\fBmongod\fP instances, but does not include the replica set
name as a prefix to the host string, \fI\%mongodump\fP
reads from the \fBnearest\fP node by default. For example:
.INDENT 2.0
.INDENT 3.5
.sp
.nf
.ft C
\-\-host "rep1.example.net:27017,rep2.example.net:27017,rep3.example.net:27017"
.ft P
.fi
.UNINDENT
.UNINDENT
.UNINDENT

.SS Sharded Clusters
.sp
Changed in version 3.0.5: For a sharded cluster where the shards are replica sets,
\fI\%mongodump\fP no longer prefers reads from secondary
members when run against the \fBmongos\fP instance.

.sp
For sharded clusters, specify the hostname of a \fBmongos\fP
for the \fB\-\-host\fP option.
\fI\%mongodump\fP reads from the \fBprimary\fP replica set
member on each shard replica set in the cluster.
.sp
Unsharded collections in a sharded cluster are stored on a
primary shard\&.
\fI\%mongodump\fP reads from the primary replica set member on
the primary shard for any unsharded collections. Note: each
database has its own primary shard.
.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.
.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 for the \fBmongod\fP to which to
connect.
.sp
The following is the standard
URI connection scheme:
.INDENT 7.0
.INDENT 3.5
.sp
.nf
.ft C
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
For detailed explanations of the components of this string, refer to
the
Connection String URI Format
documentation.
.sp
\fBIMPORTANT:\fP
.INDENT 7.0
.INDENT 3.5
The following \fI\%mongodump\fP options are incompatible with the
\fB\-\-uri\fP option. Instead, specify these options as part of your
\fB\-\-uri\fP connection string when applicable:
.INDENT 0.0
.IP \(bu 2
\fB\-\-host\fP
.IP \(bu 2
\fB\-\-port\fP
.IP \(bu 2
\fB\-\-db\fP
.IP \(bu 2
\fB\-\-username\fP
.IP \(bu 2
\fB\-\-password\fP (when specifying the password as part of the
URI connection string)
.IP \(bu 2
\fB\-\-authenticationDatabase\fP
.IP \(bu 2
\fB\-\-authenticationMechanism\fP
.UNINDENT
.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
<replSetName>/<hostname1><:port>,<hostname2><:port>,<...>
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
You can always connect directly to a single MongoDB instance by
specifying the host and port number directly.
.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).

.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.
.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\-\-sslCAFile\fP or \fBssl.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
If using x.509 authentication, \fB\-\-sslCAFile\fP or \fBssl.CAFile\fP
must be specified.
.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 \fBssl.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
\fBWARNING:\fP
.INDENT 7.0
.INDENT 3.5
For TLS/SSL connections to \fBmongod\fP and
\fBmongos\fP, avoid using
\fB\-\-sslAllowInvalidCertificates\fP if possible and only use
\fB\-\-sslAllowInvalidCertificates\fP 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.
.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 \-\-sslFIPSMode
New in version 2.6.

.sp
Directs the \fBmongodump\fP to use the FIPS mode of the installed OpenSSL
library. Your system must have a FIPS compliant OpenSSL library to use
the \fI\%\-\-sslFIPSMode\fP option.
.sp
\fBNOTE:\fP
.INDENT 7.0
.INDENT 3.5
FIPS\-compatible TLS/SSL is
available only in \fI\%MongoDB Enterprise\fP\&. See
/tutorial/configure\-fips for more information.
.UNINDENT
.UNINDENT
.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 \fB\-\-password\fP and
\fB\-\-authenticationDatabase\fP options.
.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 \fB\-\-username\fP and
\fB\-\-authenticationDatabase\fP options.
.sp
Changed in version 3.0.0: If you do not specify an argument for \fI\%\-\-password\fP, \fBmongodump\fP returns
an error.

.sp
Changed in version 3.0.2: If you wish \fBmongodump\fP 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 .

.UNINDENT
.INDENT 0.0
.TP
.B \-\-authenticationDatabase <dbname>
Specifies the database in which the user is created.
See user\-authentication\-database\&.
.sp
If you do not specify an authentication database, \fBmongodump\fP
assumes that the database specified to export holds the user’s 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’s
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
.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.
.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\&.
.sp
You must enclose the query in single quotes (e.g. \fB\(aq\fP) to ensure that it does
not interact with your shell environment.
.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’s buffer.
.UNINDENT
.INDENT 0.0
.TP
.B \-\-readPreference <string>
Specify the read preference for
\fBmongodump\fP\&.
.sp
See replica\-set\-read\-preference\-modes\&.
.sp
\fBmongodump\fP defaults to \fBprimary\fP
read preference when connected to a
\fBmongos\fP or a replica set\&.
.sp
Otherwise, \fBmongodump\fP defaults to \fBnearest\fP\&.
.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
.sp
See \fI\%Read Preference\fP\&.
.UNINDENT
.INDENT 0.0
.TP
.B \-\-forceTableScan
Forces \fI\%mongodump\fP to scan the data store directly: typically,
\fI\%mongodump\fP saves entries as they appear in the index of
the \fB_id\fP field. If you specify a query \fI\%\-\-query\fP,
\fBmongodump\fP will use the most appropriate index to support that query.
.sp
Use \fI\%\-\-forceTableScan\fP to skip the index and scan the data directly. Typically
there are two cases where this behavior is preferable to the
default:
.INDENT 7.0
.IP 1. 3
If you have key sizes over 800 bytes that would not be present in the
\fB_id\fP index.
.IP 2. 3
Your database uses a custom \fB_id\fP field.
.UNINDENT
.sp
When you run with \fI\%\-\-forceTableScan\fP, the dump produced by
\fI\%mongodump\fP can reflect the state of the database at many
different points in time.
.sp
\fBIMPORTANT:\fP
.INDENT 7.0
.INDENT 3.5
Use \fI\%\-\-forceTableScan\fP with extreme caution and
consideration.
.UNINDENT
.UNINDENT
.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 \-\-repair
.
\fBNOTE:\fP
.INDENT 7.0
.INDENT 3.5
When repairing a database, you should use \fBmongod \-\-repair\fP
rather than this option. For instructions on repairing a database,
refer to
/tutorial/recover\-data\-following\-unexpected\-shutdown\&.
.UNINDENT
.UNINDENT
.sp
Changes the behavior of \fBmongodump\fP to only write valid data and
exclude data that may be in an invalid state as a result of an
improper shutdown or \fBmongod\fP crash.
.sp
\fI\%\-\-repair\fP is different from \fBmongod \-\-repair\fP, and may produce
a large amount of duplicate documents. It is only available for use
against \fBmongod\fP instances using the \fBmmapv1\fP storage
engine. You cannot run \fI\%\-\-repair\fP against \fBmongos\fP, or against
\fBmongod\fP instances that use the \fBwiredTiger\fP storage
engine.
.sp
For instructions on repairing a database, refer to
/tutorial/recover\-data\-following\-unexpected\-shutdown\&.
.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’s 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’s metadata. If you include a
view’s 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-2018
.\" Generated by docutils manpage writer.
.