BackUp and restore db with MongoDB java driver -
is there possibility in mongodb java driver make backup , restore db?
my solution (just execute command) now:
public void makebackup(string path) { try { runtime.getruntime().exec("mongodump --out " + path); } catch (ioexception ex) { logger.getlogger(mongodb.class.getname()).log(level.severe, null, ex); } } public void restore(string backuppath) { try { runtime.getruntime().exec("mongorestore " + backuppath); } catch (ioexception ex) { logger.getlogger(mongodb.class.getname()).log(level.severe, null, ex); } }
thanks in advance.
the short answer no @ now. these commands can invoked command line. might consider fetch data collections expected slow. can read discussion around here
Comments
Post a Comment