MongoDB java驱动程序中是否有可能备份和恢复数据库?
我现在的解决方案(只需执行命令):
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);
}
}
提前致谢。