How to use the borgmatic.borg.init.initialize_repository 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_init.py View on Github external
def test_initialize_repository_with_log_debug_calls_borg_with_debug_parameter():
    insert_info_command_not_found_mock()
    insert_init_command_mock(INIT_COMMAND + ('--debug', 'repo'))
    insert_logging_mock(logging.DEBUG)

    module.initialize_repository(repository='repo', storage_config={}, encryption_mode='repokey')
github witten / borgmatic / tests / unit / borg / test_init.py View on Github external
def test_initialize_repository_raises_for_unknown_info_command_error():
    flexmock(module).should_receive('execute_command').and_raise(
        subprocess.CalledProcessError(INFO_SOME_UNKNOWN_EXIT_CODE, [])
    )

    with pytest.raises(subprocess.CalledProcessError):
        module.initialize_repository(
            repository='repo', storage_config={}, encryption_mode='repokey'
        )
github witten / borgmatic / tests / unit / borg / test_init.py View on Github external
def test_initialize_repository_with_remote_path_calls_borg_with_remote_path_parameter():
    insert_info_command_not_found_mock()
    insert_init_command_mock(INIT_COMMAND + ('--remote-path', 'borg1', 'repo'))

    module.initialize_repository(
        repository='repo', storage_config={}, encryption_mode='repokey', remote_path='borg1'
    )
github witten / borgmatic / tests / unit / borg / test_init.py View on Github external
def test_initialize_repository_with_storage_quota_calls_borg_with_storage_quota_parameter():
    insert_info_command_not_found_mock()
    insert_init_command_mock(INIT_COMMAND + ('--storage-quota', '5G', 'repo'))

    module.initialize_repository(
        repository='repo', storage_config={}, encryption_mode='repokey', storage_quota='5G'
    )
github witten / borgmatic / tests / unit / borg / test_init.py View on Github external
def test_initialize_repository_skips_initialization_when_repository_already_exists():
    insert_info_command_found_mock()
    flexmock(module).should_receive('execute_command_without_capture').never()

    module.initialize_repository(repository='repo', storage_config={}, encryption_mode='repokey')
github witten / borgmatic / tests / unit / borg / test_init.py View on Github external
def test_initialize_repository_calls_borg_with_parameters():
    insert_info_command_not_found_mock()
    insert_init_command_mock(INIT_COMMAND + ('repo',))

    module.initialize_repository(repository='repo', storage_config={}, encryption_mode='repokey')
github witten / borgmatic / tests / unit / borg / test_init.py View on Github external
def test_initialize_repository_with_append_only_calls_borg_with_append_only_parameter():
    insert_info_command_not_found_mock()
    insert_init_command_mock(INIT_COMMAND + ('--append-only', 'repo'))

    module.initialize_repository(
        repository='repo', storage_config={}, encryption_mode='repokey', append_only=True
    )
github witten / borgmatic / borgmatic / commands / borgmatic.py View on Github external
'''
    Given parsed command-line arguments as an argparse.ArgumentParser instance, several different
    configuration dicts, local and remote paths to Borg, and a repository name, run all actions
    from the command-line arguments on the given repository.

    Yield JSON output strings from executing any actions that produce JSON.

    Raise OSError or subprocess.CalledProcessError if an error occurs running a command for an
    action. Raise ValueError if the arguments or configuration passed to action are invalid.
    '''
    repository = os.path.expanduser(repository_path)
    global_arguments = arguments['global']
    dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''
    if 'init' in arguments:
        logger.info('{}: Initializing repository'.format(repository))
        borg_init.initialize_repository(
            repository,
            storage,
            arguments['init'].encryption_mode,
            arguments['init'].append_only,
            arguments['init'].storage_quota,
            local_path=local_path,
            remote_path=remote_path,
        )
    if 'prune' in arguments:
        logger.info('{}: Pruning archives{}'.format(repository, dry_run_label))
        borg_prune.prune_archives(
            global_arguments.dry_run,
            repository,
            storage,
            retention,
            local_path=local_path,