public static void recover(File file){
  try {
    ZipInputStream zip=new ZipInputStream(new FileInputStream(file));
    zip.getNextEntry();
    BufferedReader in=new BufferedReader(new InputStreamReader(zip));
    Set<String> c1=getCollections();
    log.debug("collections=" + c1);
    for (    String table : c1) {
      MongoCollection<Document> c2=getCollection(table);
      try {
        c2.drop();
      }
 catch (      Exception e) {
        log.error("table=" + table,e);
      }
    }
    String line=in.readLine();
    while (line != null) {
      _recover(line);
      line=in.readLine();
    }
    zip.closeEntry();
    in.close();
  }
 catch (  Exception e) {
    log.error(e.getMessage(),e);
  }
}

public static void recover ( File file ) { try { ZipInputStream zip = new ZipInputStream ( new FileInputStream ( file ) ) ; zip . getNextEntry ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( zip ) ) ; Set < String > c1 = getCollections ( ) ; log . debug ( "collections=" + c1 ) ; for ( String table : c1 ) { MongoCollection < Document > c2 = getCollection ( table ) ; try { c2 . drop ( ) ; } catch ( Exception e ) { log . error ( "table=" + table , e ) ; } } String line = in . readLine ( ) ; while ( line != null ) { _recover ( line ) ; line = in . readLine ( ) ; } zip . closeEntry ( ) ; in . close ( ) ; } catch ( Exception e ) { log . error ( e . getMessage ( ) , e ) ; } }
recover the database from the file , the old data will be erased , index will be keep
