0

I'm trying to dump an existing MongoDB into a new MongoDB without using dump files at all.

Is there a way to pass data from mongodump into mongorestore using pipes?

something like this:

mongodump --host=0.0.0.0 --port=27017 --db=database_name | mongorestore --host 0.0.0.0 -d database_name --port 27000

Thanks!

Alon Barad
  • 1,491
  • 1
  • 13
  • 26

1 Answers1

1

I found this solution:

mongodump -vvvvv --host=0.0.0.0 --port=27017 --db=database_name --archive | mongorestore --archive -vvvvv

Explained:

  • mongodump a MongoDB util to dump (backup) a database
  • -vvvvv v for verbose, write to stdout the output of the command, more data per v, you can use -v -vv -vvv etc...
  • --host specify the host of the MongoDB you want to dump
  • --host specify the port of the MongoDB you want to dump
  • --archive writes the output to a specified archive file or, if the archive file is unspecified, writes to the standard output (stdout)
  • | takes the output of the command and passes it as input to the next command
  • mongorestore a MongoDB util to restore a database
Alon Barad
  • 1,491
  • 1
  • 13
  • 26