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;
  }
Example #2
0
 public OnlineBackup incremental(GraphDatabaseService targetDb) {
   BackupClient client = new BackupClient(hostNameOrIp, port, targetDb);
   try {
     unpackResponse(
         client.incrementalBackup(slaveContextOf(targetDb)), targetDb, MasterUtil.NO_ACTION);
   } finally {
     client.shutdown();
   }
   return this;
 }
 public OnlineBackup incremental(GraphDatabaseService targetDb) {
   BackupClient client =
       new BackupClient(
           hostNameOrIp,
           port,
           ((AbstractGraphDatabase) targetDb).getMessageLog(),
           Client.storeIdGetterForDb(targetDb));
   try {
     unpackResponse(
         client.incrementalBackup(slaveContextOf(targetDb)), targetDb, MasterUtil.NO_ACTION);
   } finally {
     client.shutdown();
   }
   return this;
 }
Example #4
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;
  }