class BackupService {

    public BackupFile generateBackup() throws InterruptedException {
        SecurityServerId securityServerId = serverConfService.getSecurityServerId();
        String filename = generateBackupFileName();
        auditDataHelper.putBackupFilename(backupRepository.getFilePath(filename));
        String fullPath = backupRepository.getConfigurationBackupPath() + filename;
        String[] args = new String[] {"-s", securityServerId.toShortString(), "-f", fullPath};

        try {
            log.info("Run configuration backup with command '"
                    + generateBackupScriptPath + " " + Arrays.toString(args) + "'");

            ExternalProcessRunner.ProcessResult processResult = externalProcessRunner
                    .executeAndThrowOnFailure(generateBackupScriptPath, args);

            log.info(" --- Backup script console output - START --- ");
            log.info(String.join("\n", processResult.getProcessOutput()));
            log.info(" --- Backup script console output - END --- ");
        } catch (ProcessNotExecutableException | ProcessFailedException e) {
            throw new DeviationAwareRuntimeException(e, new ErrorDeviation(BACKUP_GENERATION_FAILED));
        }

        Optional<BackupFile> backupFile = getBackup(filename);
        if (!backupFile.isPresent()) {
            throw new DeviationAwareRuntimeException(getFileNotFoundExceptionMessage(filename),
                    new ErrorDeviation(BACKUP_GENERATION_FAILED));
        }
        return backupFile.get();
    }

    @Autowired public  BackupService(BackupRepository backupRepository, ServerConfService serverConfService,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-backup.path}") String generateBackupScriptPath,
            AuditDataHelper auditDataHelper);

}