Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to specify a directory/folder for mongodump?

Tags:

I'd like to specify the directory to which mongodump dumps, via a switch on the mongodump command. Is this possible?

like image 261
ericsoco Avatar asked Apr 12 '12 17:04

ericsoco


People also ask

Where is Mongodump stored?

The mongodump command will overwrite the existing files within the given backup folder. The default location for backups is the dump/ folder. When the WiredTiger storage engine is used in a MongoDB instance, the output will be uncompressed data.

Does Mongodump delete database?

mongodump excludes the content of the local database in its output. mongodump output only captures the documents in the database and does not include index data. mongorestore or mongod must then rebuild the indexes after restoring data.

Does Mongodump lock the database?

Mongdump does not lock the db. It means other read and write operations will continue normally. Actually, both mongodump and mongorestore are non-blocking. So if you want to mongodump mongorestore a db then its your responsibility to make sure that it is really a desired snapshot backup/restore.


2 Answers

You don't need a script. From the docs:

--out <path>, -o <path>

Specifies the directory where mongodump will write BSON files for the dumped databases.

Example:

mongodump -o /mydir/ 

Lots of other options there, check it out.

like image 80
Justin Jenkins Avatar answered Sep 20 '22 13:09

Justin Jenkins


You can view all the commands for mongodump by typing "mongodump --help" in the command prompt (NB. You have to be in the folder that contains mongodump.exe).

You can use a command like:

mongodump /host <hostIP> /port <port> /d <database> /c <collection> /o <outputDirectoryPath>  
like image 27
JavaadPatel Avatar answered Sep 21 '22 13:09

JavaadPatel