Is there a way to dump mongo database to a specific folder name? Lets say I have a db named myDb
When I use:
mongodump --db myDb
It generates a dump folder with a myDb folder inside it
Is it possible to get something like dump/mySpecifiedFolder from mongodump?
You cannot change the name of the myDB folder, since that's named for the database which it contains, but you can change the location of the myDb folder. To do this, use the --out / -o parameter.
From the docs:
--out , -o
Specifies the directory where mongodump will write BSON files for the dumped databases. By default, mongodump saves output files in a directory named dump in the current working directory.
So, this command ...
mongodump --db myDb -o /some/path/
... would cause mongodump to create /some/path/myDb.
In my discovery of doing a mongodump, please note that the default location can be the Desktop when outputting.
Example "C:\Program Files\MongoDB\Server\3.4\bin\mongodump.exe" --host localhost --port 27017 --db local --out dump/dpusers On your Desktop, the dump folder will be created with the subfolder "dpusers" and inside that folder is another folder named the same as your database name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With