use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class BackupServiceIT method shouldPrintThatIncrementalBackupIsPerformedAndFallingBackToFull.
@Test
public void shouldPrintThatIncrementalBackupIsPerformedAndFallingBackToFull() throws Exception {
defaultBackupPortHostParams();
Config defaultConfig = dbRule.getConfigCopy();
dbRule.setConfig(GraphDatabaseSettings.keep_logical_logs, "false");
// have logs rotated on every transaction
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
createAndIndexNode(db, 1);
// A full backup
backupService().doFullBackup(BACKUP_HOST, backupPort, backupDir, ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// And the log the backup uses is rotated out
createAndIndexNode(db, 2);
rotateAndCheckPoint(db);
createAndIndexNode(db, 3);
rotateAndCheckPoint(db);
createAndIndexNode(db, 4);
rotateAndCheckPoint(db);
final Log log = mock(Log.class);
LogProvider logProvider = new LogProvider() {
@Override
public Log getLog(Class loggingClass) {
return log;
}
@Override
public Log getLog(String name) {
return log;
}
};
backupService(logProvider).doIncrementalBackupOrFallbackToFull(BACKUP_HOST, backupPort, backupDir, ConsistencyCheck.NONE, dbRule.getConfigCopy(), BackupClient.BIG_READ_TIMEOUT, false);
verify(log).info("Previous backup found, trying incremental backup.");
verify(log).info("Existing backup is too far out of date, a new full backup will be performed.");
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class BackupServiceIT method shouldFallbackToFullBackupIfIncrementalFailsAndExplicitlyAskedToDoThis.
@Test
public void shouldFallbackToFullBackupIfIncrementalFailsAndExplicitlyAskedToDoThis() throws Exception {
// Given
defaultBackupPortHostParams();
Config defaultConfig = dbRule.getConfigCopy();
dbRule.setConfig(GraphDatabaseSettings.keep_logical_logs, "false");
// have logs rotated on every transaction
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
BackupService backupService = backupService();
createAndIndexNode(db, 1);
// A full backup
backupService.doFullBackup(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// And the log the backup uses is rotated out
createAndIndexNode(db, 2);
rotateAndCheckPoint(db);
createAndIndexNode(db, 3);
rotateAndCheckPoint(db);
createAndIndexNode(db, 4);
rotateAndCheckPoint(db);
// when
backupService.doIncrementalBackupOrFallbackToFull(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// Then
db.shutdown();
assertEquals(getDbRepresentation(), getBackupDbRepresentation());
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class BackupServiceIT method shouldGiveHelpfulErrorMessageIfLogsPrunedPastThePointOfNoReturn.
@Test
public void shouldGiveHelpfulErrorMessageIfLogsPrunedPastThePointOfNoReturn() throws Exception {
// Given
defaultBackupPortHostParams();
Config defaultConfig = dbRule.getConfigCopy();
dbRule.setConfig(GraphDatabaseSettings.keep_logical_logs, "false");
// have logs rotated on every transaction
GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
BackupService backupService = backupService();
createAndIndexNode(db, 1);
rotateAndCheckPoint(db);
// A full backup
backupService.doFullBackup(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), ConsistencyCheck.NONE, defaultConfig, BackupClient.BIG_READ_TIMEOUT, false);
// And the log the backup uses is rotated out
createAndIndexNode(db, 2);
rotateAndCheckPoint(db);
createAndIndexNode(db, 3);
rotateAndCheckPoint(db);
createAndIndexNode(db, 4);
rotateAndCheckPoint(db);
createAndIndexNode(db, 5);
rotateAndCheckPoint(db);
// when
try {
backupService.doIncrementalBackup(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), BackupClient.BIG_READ_TIMEOUT, defaultConfig);
fail("Should have thrown exception.");
}// Then
catch (IncrementalBackupNotPossibleException e) {
assertThat(e.getMessage(), equalTo(BackupService.TOO_OLD_BACKUP));
}
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class RestoreDatabaseCli method execute.
@Override
public void execute(String[] incomingArguments) throws IncorrectUsage, CommandFailed {
String databaseName;
String fromPath;
boolean forceOverwrite;
try {
databaseName = arguments.parse("database", incomingArguments);
fromPath = arguments.parse("from", incomingArguments);
forceOverwrite = arguments.parseBoolean("force", incomingArguments);
} catch (IllegalArgumentException e) {
throw new IncorrectUsage(e.getMessage());
}
Config config = loadNeo4jConfig(homeDir, configDir, databaseName);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
RestoreDatabaseCommand restoreDatabaseCommand = new RestoreDatabaseCommand(fileSystem, new File(fromPath), config, databaseName, forceOverwrite);
restoreDatabaseCommand.execute();
} catch (IOException e) {
throw new CommandFailed("Failed to restore database", e);
}
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class BackupLabelIndexIT method backupTo.
private static void backupTo(LabelIndex index, File toDir) {
Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.label_index.name(), index.name()));
new BackupService(DefaultFileSystemAbstraction::new, NullLogProvider.getInstance(), new Monitors()).doIncrementalBackupOrFallbackToFull("localhost", DEFAULT_PORT, toDir, ConsistencyCheck.FULL, config, BackupClient.BIG_READ_TIMEOUT, false);
}
Aggregations