I'd like to specify the directory to which mongodump dumps, via a switch on the mongodump command. Is this possible?
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.
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.
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.
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.
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>
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