'Is it possible to specify a directory/folder for mongodump?
I'd like to specify the directory to which mongodump dumps, via a switch on the mongodump command. Is this possible?
Solution 1:[1]
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>
Solution 2:[2]
It Dumps my_db in a gzip format inside tmp/my_db.dump file which is Restoreable
mongodump --db my_db --gzip -o ./tmp/my_db.dump
Solution 3:[3]
When I am using windows I always use the command below because it exports in a folder with export date:
setlocal enableextensions
set FOLDER_NAME=%DATE:/=_%
mongodump --uri "mongodb+srv://USER:PASSWORD@URL/DATABASE_NAME" -o C:\work\scheduled\dump\backup-%FOLDER_NAME%
Save the command in a file with bat extension (dump.bat for example)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | |
| Solution 3 | thiagotrss |
