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 fullBackupIsIgnoredIfNoOtherBackupAndNotFallback() public virtual void FullBackupIsIgnoredIfNoOtherBackupAndNotFallback() { // given there is an existing backup when(_backupCopyService.backupExists(any())).thenReturn(false); // and we don't want to fallback to full backups _requiredArguments = _requiredArguments(false); _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags()); // and incremental backup fails because it's a different store when(_backupStrategyImplementation.performIncrementalBackup(any(), any(), any())).thenReturn(_failure); // when _subject.doBackup(_onlineBackupContext); // then full backup wasnt performed verify(_backupStrategyImplementation, never()).performFullBackup(any(), any(), any()); }