Exemplo n.º 1
0
  @Test
  public void backupDatabase() throws Exception {
    try (ODatabaseDocumentTx db = createDatabase("test")) {
      ODocument doc = createPerson(db);

      // Backup makes ZIP files
      File file = File.createTempFile("export-", ".zip", util.getTmpDir());
      log("Exporting to: {}", file);

      try (OutputStream output = new BufferedOutputStream(new FileOutputStream(file))) {
        OCommandOutputListener listener =
            new OCommandOutputListener() {
              @Override
              public void onMessage(final String text) {
                log("> {}", text.trim());
              }
            };
        db.backup(output, null, null, listener, 9, 16384);
      }
    }
  }