4
mongodump --out "-" 

doesn't work, it gives me this message : "Failed: bad option: can only dump a single collection to stdout". What happens ?...

L.G
  • 1,458
  • 4
  • 14
  • 24

2 Answers2

5

so the exception is self-explanatory that if you use --out "-" it can show only single collection on stdout.

So i would like to know as to what you want to achieve?

if you want to stdout a particular collection command is :

mongodump -o - -d <dbname> -c <collection name>

if you want to take dump of whole mongodatabase ideal command is:

mongodump --gzip --archive=db.tar
richi arora
  • 273
  • 4
  • 11
  • Thanks, it's also possible to dump all in a directory path, example : mongodump -o D:\database\dumps – L.G Sep 29 '18 at 07:21
  • yup. but i usually have practice to archive and gzip to use less space. in mongorestore you may restore with "mongorestore --gzip --drop --archive=db.tar" PS you may provide full path to archive as well – richi arora Sep 30 '18 at 04:38
1

Too dump a complete database to stdout you can use the --archive option (without parameter):

mongodump -d <dbname> --archive

Docs: https://docs.mongodb.com/database-tools/mongodump/#std-option-mongodump.--archive

daniel-sc
  • 1,139
  • 11
  • 23