Is there any function to import and export all collections of mongodb database using java driver.? like there is mongodump
and mongorestore
using command prompt.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- MongoDB can not create unique sparse index (duplic
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
The short answer is no. These commands can be invoked only from command line. You might consider to fetch all the data from all collections but its expected to be slow.
You can read the discussion around this here
Hope this helps
It exacts with folder as dump with database name sample
Well as of now, Mongo Java driver does not support this.
You can try invoking the mongoimport and mongorestore commands from Java Runtime. Like
(same answer as here)
recently I've started a project called mongodbdump-java-wrapper to wrap
mongodump.exe
andmongorestore.exe
mongodb executable from java.You could clone it from : github project. This project includes integration tests (a way to know how implement backup/restore).