amir.sh
amir.sh

Reputation: 301

mongodump with different folder name

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?

Upvotes: 4

Views: 6321

Answers (2)

Demetre Phipps
Demetre Phipps

Reputation: 105

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.

Upvotes: 2

glytching
glytching

Reputation: 47935

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.

Upvotes: 7

Related Questions