public OnlineBackup full(String targetDirectory, boolean verification) {
    if (directoryContainsDb(targetDirectory)) {
      throw new RuntimeException(targetDirectory + " already contains a database");
    }

    BackupClient client =
        new BackupClient(hostNameOrIp, port, StringLogger.DEV_NULL, Client.NO_STORE_ID_GETTER);
    try {
      Response<Void> response = client.fullBackup(new ToFileStoreWriter(targetDirectory));
      GraphDatabaseService targetDb =
          startTemporaryDb(targetDirectory, VerificationLevel.NONE /* run full check instead */);
      try {
        unpackResponse(response, targetDb, MasterUtil.txHandlerForFullCopy());
      } finally {
        targetDb.shutdown();
      }
      if (verification) {
        StoreAccess newStore = new StoreAccess(targetDirectory);
        try {
          ConsistencyCheck.run(newStore, false);
        } finally {
          newStore.close();
        }
      }
    } finally {
      client.shutdown();
    }
    return this;
  }
Beispiel #2
0
 private void unpackResponse(
     Response<Void> response, GraphDatabaseService graphDb, TxHandler txHandler) {
   try {
     MasterUtil.applyReceivedTransactions(response, graphDb, txHandler);
     getLastCommittedTxs(graphDb);
   } catch (IOException e) {
     throw new RuntimeException("Unable to apply received transactions", e);
   }
 }
Beispiel #3
0
  public OnlineBackup full(String targetDirectory) {
    if (directoryContainsDb(targetDirectory)) {
      throw new RuntimeException(targetDirectory + " already contains a database");
    }

    //                                                     TODO OMG this is ugly
    BackupClient client =
        new BackupClient(hostNameOrIp, port, new NotYetExistingGraphDatabase(targetDirectory));
    try {
      Response<Void> response = client.fullBackup(new ToFileStoreWriter(targetDirectory));
      GraphDatabaseService targetDb = startTemporaryDb(targetDirectory);
      try {
        unpackResponse(response, targetDb, MasterUtil.txHandlerForFullCopy());
      } finally {
        targetDb.shutdown();
      }
    } finally {
      client.shutdown();
      // TODO This is also ugly
      StringLogger.close(targetDirectory + "/messages.log");
    }
    return this;
  }