private Fallible <BackupStrategyOutcome> PerformBackupWithoutLifecycle(OnlineBackupContext onlineBackupContext) { Path backupLocation = onlineBackupContext.ResolvedLocationFromName; OptionalHostnamePort userSpecifiedAddress = onlineBackupContext.RequiredArguments.Address; _log.debug("User specified address is %s:%s", userSpecifiedAddress.Hostname.ToString(), userSpecifiedAddress.Port.ToString()); Config config = onlineBackupContext.Config; bool previousBackupExists = _backupCopyService.backupExists(DatabaseLayout.of(backupLocation.toFile())); if (previousBackupExists) { _log.info("Previous backup found, trying incremental backup."); Fallible <BackupStageOutcome> state = _backupStrategy.performIncrementalBackup(DatabaseLayout.of(backupLocation.toFile()), config, userSpecifiedAddress); bool fullBackupWontWork = BackupStageOutcome.WrongProtocol.Equals(state.State); bool incrementalWasSuccessful = BackupStageOutcome.Success.Equals(state.State); if (incrementalWasSuccessful) { _backupRecoveryService.recoverWithDatabase(backupLocation, _pageCache, config); } if (fullBackupWontWork || incrementalWasSuccessful) { ClearIdFiles(backupLocation); return(DescribeOutcome(state)); } if (!onlineBackupContext.RequiredArguments.FallbackToFull) { return(DescribeOutcome(state)); } } if (onlineBackupContext.RequiredArguments.FallbackToFull) { if (!previousBackupExists) { _log.info("Previous backup not found, a new full backup will be performed."); } return(DescribeOutcome(FullBackupWithTemporaryFolderResolutions(onlineBackupContext))); } return(new Fallible <BackupStrategyOutcome>(BackupStrategyOutcome.IncorrectStrategy, null)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void fullBackupIsPerformedWhenNoOtherBackupExists() public virtual void FullBackupIsPerformedWhenNoOtherBackupExists() { // given _requiredArguments = _requiredArguments(true); _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags()); // and when(_backupCopyService.backupExists(any())).thenReturn(false); // when _subject.doBackup(_onlineBackupContext); // then verify(_backupStrategyImplementation).performFullBackup(any(), any(), any()); }