How to use the borgmatic.borg.check.check_archives function in borgmatic

To help you get started, we’ve selected a few borgmatic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_with_local_path_calls_borg_via_local_path():
    checks = ('repository',)
    check_last = flexmock()
    consistency_config = {'check_last': check_last}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').with_args(
        checks, check_last, module.DEFAULT_PREFIX
    ).and_return(())
    insert_execute_command_mock(('borg1', 'check', 'repo'))

    module.check_archives(
        repository='repo',
        storage_config={},
        consistency_config=consistency_config,
        local_path='borg1',
    )
github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_with_retention_prefix():
    checks = ('repository',)
    check_last = flexmock()
    prefix = 'foo-'
    consistency_config = {'check_last': check_last, 'prefix': prefix}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').with_args(
        checks, check_last, prefix
    ).and_return(())
    insert_execute_command_mock(('borg', 'check', 'repo'))

    module.check_archives(
        repository='repo', storage_config={}, consistency_config=consistency_config
    )
github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_without_any_checks_bails():
    consistency_config = {'check_last': None}
    flexmock(module).should_receive('_parse_checks').and_return(())
    insert_execute_command_never()

    module.check_archives(
        repository='repo', storage_config={}, consistency_config=consistency_config
    )
github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_with_extra_borg_options_calls_borg_with_extra_options():
    checks = ('repository',)
    consistency_config = {'check_last': None}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').and_return(())
    insert_execute_command_mock(('borg', 'check', '--extra', '--options', 'repo'))

    module.check_archives(
        repository='repo',
        storage_config={'extra_borg_options': {'check': '--extra --options'}},
        consistency_config=consistency_config,
    )
github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_with_extract_check_calls_extract_only():
    checks = ('extract',)
    check_last = flexmock()
    consistency_config = {'check_last': check_last}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').never()
    flexmock(module.extract).should_receive('extract_last_archive_dry_run').once()
    insert_execute_command_never()

    module.check_archives(
        repository='repo', storage_config={}, consistency_config=consistency_config
    )
github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_with_repair_calls_borg_with_repair_parameter():
    checks = ('repository',)
    consistency_config = {'check_last': None}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').and_return(())
    flexmock(module).should_receive('execute_command').never()
    flexmock(module).should_receive('execute_command_without_capture').with_args(
        ('borg', 'check', '--repair', 'repo'), error_on_warnings=True
    ).once()

    module.check_archives(
        repository='repo', storage_config={}, consistency_config=consistency_config, repair=True
    )
github witten / borgmatic / tests / unit / borg / test_check.py View on Github external
def test_check_archives_with_log_debug_calls_borg_with_debug_parameter():
    checks = ('repository',)
    consistency_config = {'check_last': None}
    flexmock(module).should_receive('_parse_checks').and_return(checks)
    flexmock(module).should_receive('_make_check_flags').and_return(())
    insert_logging_mock(logging.DEBUG)
    insert_execute_command_mock(('borg', 'check', '--debug', '--show-rc', 'repo'))

    module.check_archives(
        repository='repo', storage_config={}, consistency_config=consistency_config
    )
github witten / borgmatic / borgmatic / commands / borgmatic.py View on Github external
json_output = borg_create.create_archive(
            global_arguments.dry_run,
            repository,
            location,
            storage,
            local_path=local_path,
            remote_path=remote_path,
            progress=arguments['create'].progress,
            stats=arguments['create'].stats,
            json=arguments['create'].json,
        )
        if json_output:
            yield json.loads(json_output)
    if 'check' in arguments and checks.repository_enabled_for_checks(repository, consistency):
        logger.info('{}: Running consistency checks'.format(repository))
        borg_check.check_archives(
            repository,
            storage,
            consistency,
            local_path=local_path,
            remote_path=remote_path,
            repair=arguments['check'].repair,
            only_checks=arguments['check'].only,
        )
    if 'extract' in arguments:
        if arguments['extract'].repository is None or validate.repositories_match(
            repository, arguments['extract'].repository
        ):
            logger.info(
                '{}: Extracting archive {}'.format(repository, arguments['extract'].archive)
            )
            borg_extract.extract_archive(