Labels for repositories (#635).
Merge pull request #57 from diivi/feat/tag-repos
This commit is contained in:
commit
3e8e38011b
74 changed files with 614 additions and 461 deletions
|
@ -16,9 +16,9 @@ def run_borg(
|
|||
if borg_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, borg_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository}: Running arbitrary Borg command')
|
||||
logger.info(f'{repository["path"]}: Running arbitrary Borg command')
|
||||
archive_name = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository,
|
||||
repository['path'],
|
||||
borg_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
@ -26,7 +26,7 @@ def run_borg(
|
|||
remote_path,
|
||||
)
|
||||
borgmatic.borg.borg.run_arbitrary_borg(
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
options=borg_arguments.options,
|
||||
|
|
|
@ -15,7 +15,11 @@ def run_break_lock(
|
|||
if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, break_lock_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository}: Breaking repository and cache locks')
|
||||
logger.info(f'{repository["path"]}: Breaking repository and cache locks')
|
||||
borgmatic.borg.break_lock.break_lock(
|
||||
repository, storage, local_borg_version, local_path=local_path, remote_path=remote_path,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
)
|
||||
|
|
|
@ -37,9 +37,9 @@ def run_check(
|
|||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info(f'{repository}: Running consistency checks')
|
||||
logger.info(f'{repository["path"]}: Running consistency checks')
|
||||
borgmatic.borg.check.check_archives(
|
||||
repository,
|
||||
repository['path'],
|
||||
location,
|
||||
storage,
|
||||
consistency,
|
||||
|
|
|
@ -39,10 +39,10 @@ def run_compact(
|
|||
**hook_context,
|
||||
)
|
||||
if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version):
|
||||
logger.info(f'{repository}: Compacting segments{dry_run_label}')
|
||||
logger.info(f'{repository["path"]}: Compacting segments{dry_run_label}')
|
||||
borgmatic.borg.compact.compact_segments(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path=local_path,
|
||||
|
@ -52,7 +52,7 @@ def run_compact(
|
|||
threshold=compact_arguments.threshold,
|
||||
)
|
||||
else: # pragma: nocover
|
||||
logger.info(f'{repository}: Skipping compact (only available/needed in Borg 1.2+)')
|
||||
logger.info(f'{repository["path"]}: Skipping compact (only available/needed in Borg 1.2+)')
|
||||
borgmatic.hooks.command.execute_hook(
|
||||
hooks.get('after_compact'),
|
||||
hooks.get('umask'),
|
||||
|
|
|
@ -42,11 +42,11 @@ def run_create(
|
|||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info(f'{repository}: Creating archive{dry_run_label}')
|
||||
logger.info(f'{repository["path"]}: Creating archive{dry_run_label}')
|
||||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
'remove_database_dumps',
|
||||
hooks,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
|
@ -54,7 +54,7 @@ def run_create(
|
|||
active_dumps = borgmatic.hooks.dispatch.call_hooks(
|
||||
'dump_databases',
|
||||
hooks,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
|
@ -63,7 +63,7 @@ def run_create(
|
|||
|
||||
json_output = borgmatic.borg.create.create_archive(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
repository['path'],
|
||||
location,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
|
|
@ -22,12 +22,14 @@ def run_export_tar(
|
|||
if export_tar_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, export_tar_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository}: Exporting archive {export_tar_arguments.archive} as tar file')
|
||||
logger.info(
|
||||
f'{repository["path"]}: Exporting archive {export_tar_arguments.archive} as tar file'
|
||||
)
|
||||
borgmatic.borg.export_tar.export_tar_archive(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository,
|
||||
repository['path'],
|
||||
export_tar_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
|
|
@ -35,12 +35,12 @@ def run_extract(
|
|||
if extract_arguments.repository is None or borgmatic.config.validate.repositories_match(
|
||||
repository, extract_arguments.repository
|
||||
):
|
||||
logger.info(f'{repository}: Extracting archive {extract_arguments.archive}')
|
||||
logger.info(f'{repository["path"]}: Extracting archive {extract_arguments.archive}')
|
||||
borgmatic.borg.extract.extract_archive(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository,
|
||||
repository['path'],
|
||||
extract_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
|
|
@ -20,9 +20,9 @@ def run_info(
|
|||
repository, info_arguments.repository
|
||||
):
|
||||
if not info_arguments.json: # pragma: nocover
|
||||
logger.answer(f'{repository}: Displaying archive summary information')
|
||||
logger.answer(f'{repository["path"]}: Displaying archive summary information')
|
||||
info_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository,
|
||||
repository['path'],
|
||||
info_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
@ -30,7 +30,7 @@ def run_info(
|
|||
remote_path,
|
||||
)
|
||||
json_output = borgmatic.borg.info.display_archives_info(
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
info_arguments=info_arguments,
|
||||
|
|
|
@ -20,11 +20,11 @@ def run_list(
|
|||
):
|
||||
if not list_arguments.json: # pragma: nocover
|
||||
if list_arguments.find_paths:
|
||||
logger.answer(f'{repository}: Searching archives')
|
||||
logger.answer(f'{repository["path"]}: Searching archives')
|
||||
elif not list_arguments.archive:
|
||||
logger.answer(f'{repository}: Listing archives')
|
||||
logger.answer(f'{repository["path"]}: Listing archives')
|
||||
list_arguments.archive = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository,
|
||||
repository['path'],
|
||||
list_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
@ -32,7 +32,7 @@ def run_list(
|
|||
remote_path,
|
||||
)
|
||||
json_output = borgmatic.borg.list.list_archive(
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
list_arguments=list_arguments,
|
||||
|
|
|
@ -17,14 +17,14 @@ def run_mount(
|
|||
repository, mount_arguments.repository
|
||||
):
|
||||
if mount_arguments.archive:
|
||||
logger.info(f'{repository}: Mounting archive {mount_arguments.archive}')
|
||||
logger.info(f'{repository["path"]}: Mounting archive {mount_arguments.archive}')
|
||||
else: # pragma: nocover
|
||||
logger.info(f'{repository}: Mounting repository')
|
||||
logger.info(f'{repository["path"]}: Mounting repository')
|
||||
|
||||
borgmatic.borg.mount.mount_archive(
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository,
|
||||
repository['path'],
|
||||
mount_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
|
|
|
@ -37,10 +37,10 @@ def run_prune(
|
|||
global_arguments.dry_run,
|
||||
**hook_context,
|
||||
)
|
||||
logger.info(f'{repository}: Pruning archives{dry_run_label}')
|
||||
logger.info(f'{repository["path"]}: Pruning archives{dry_run_label}')
|
||||
borgmatic.borg.prune.prune_archives(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
retention,
|
||||
local_borg_version,
|
||||
|
|
|
@ -23,10 +23,10 @@ def run_rcreate(
|
|||
):
|
||||
return
|
||||
|
||||
logger.info(f'{repository}: Creating repository')
|
||||
logger.info(f'{repository["path"]}: Creating repository')
|
||||
borgmatic.borg.rcreate.create_repository(
|
||||
global_arguments.dry_run,
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
rcreate_arguments.encryption_mode,
|
||||
|
|
|
@ -255,22 +255,35 @@ def run_restore(
|
|||
):
|
||||
return
|
||||
|
||||
logger.info(f'{repository}: Restoring databases from archive {restore_arguments.archive}')
|
||||
logger.info(
|
||||
f'{repository["path"]}: Restoring databases from archive {restore_arguments.archive}'
|
||||
)
|
||||
|
||||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
'remove_database_dumps',
|
||||
hooks,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
)
|
||||
|
||||
archive_name = borgmatic.borg.rlist.resolve_archive_name(
|
||||
repository, restore_arguments.archive, storage, local_borg_version, local_path, remote_path,
|
||||
repository['path'],
|
||||
restore_arguments.archive,
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path,
|
||||
remote_path,
|
||||
)
|
||||
archive_database_names = collect_archive_database_names(
|
||||
repository, archive_name, location, storage, local_borg_version, local_path, remote_path,
|
||||
repository['path'],
|
||||
archive_name,
|
||||
location,
|
||||
storage,
|
||||
local_borg_version,
|
||||
local_path,
|
||||
remote_path,
|
||||
)
|
||||
restore_names = find_databases_to_restore(restore_arguments.databases, archive_database_names)
|
||||
found_names = set()
|
||||
|
@ -290,7 +303,7 @@ def run_restore(
|
|||
|
||||
found_names.add(database_name)
|
||||
restore_single_database(
|
||||
repository,
|
||||
repository['path'],
|
||||
location,
|
||||
storage,
|
||||
hooks,
|
||||
|
@ -319,7 +332,7 @@ def run_restore(
|
|||
database['name'] = database_name
|
||||
|
||||
restore_single_database(
|
||||
repository,
|
||||
repository['path'],
|
||||
location,
|
||||
storage,
|
||||
hooks,
|
||||
|
@ -335,7 +348,7 @@ def run_restore(
|
|||
borgmatic.hooks.dispatch.call_hooks_even_if_unconfigured(
|
||||
'remove_database_dumps',
|
||||
hooks,
|
||||
repository,
|
||||
repository['path'],
|
||||
borgmatic.hooks.dump.DATABASE_HOOK_NAMES,
|
||||
location,
|
||||
global_arguments.dry_run,
|
||||
|
|
|
@ -19,10 +19,10 @@ def run_rinfo(
|
|||
repository, rinfo_arguments.repository
|
||||
):
|
||||
if not rinfo_arguments.json: # pragma: nocover
|
||||
logger.answer(f'{repository}: Displaying repository summary information')
|
||||
logger.answer(f'{repository["path"]}: Displaying repository summary information')
|
||||
|
||||
json_output = borgmatic.borg.rinfo.display_repository_info(
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
rinfo_arguments=rinfo_arguments,
|
||||
|
|
|
@ -19,10 +19,10 @@ def run_rlist(
|
|||
repository, rlist_arguments.repository
|
||||
):
|
||||
if not rlist_arguments.json: # pragma: nocover
|
||||
logger.answer(f'{repository}: Listing repository')
|
||||
logger.answer(f'{repository["path"]}: Listing repository')
|
||||
|
||||
json_output = borgmatic.borg.rlist.list_repository(
|
||||
repository,
|
||||
repository['path'],
|
||||
storage,
|
||||
local_borg_version,
|
||||
rlist_arguments=rlist_arguments,
|
||||
|
|
|
@ -13,7 +13,7 @@ BORG_SUBCOMMANDS_WITHOUT_REPOSITORY = (('debug', 'info'), ('debug', 'convert-pro
|
|||
|
||||
|
||||
def run_arbitrary_borg(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
options,
|
||||
|
@ -44,10 +44,10 @@ def run_arbitrary_borg(
|
|||
repository_archive_flags = ()
|
||||
elif archive:
|
||||
repository_archive_flags = flags.make_repository_archive_flags(
|
||||
repository, archive, local_borg_version
|
||||
repository_path, archive, local_borg_version
|
||||
)
|
||||
else:
|
||||
repository_archive_flags = flags.make_repository_flags(repository, local_borg_version)
|
||||
repository_archive_flags = flags.make_repository_flags(repository_path, local_borg_version)
|
||||
|
||||
full_command = (
|
||||
(local_path,)
|
||||
|
|
|
@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def break_lock(
|
||||
repository, storage_config, local_borg_version, local_path='borg', remote_path=None,
|
||||
repository_path, storage_config, local_borg_version, local_path='borg', remote_path=None,
|
||||
):
|
||||
'''
|
||||
Given a local or remote repository path, a storage configuration dict, the local Borg version,
|
||||
|
@ -24,7 +24,7 @@ def break_lock(
|
|||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
borg_environment = environment.make_environment(storage_config)
|
||||
|
|
|
@ -243,7 +243,7 @@ def read_check_time(path):
|
|||
|
||||
|
||||
def check_archives(
|
||||
repository,
|
||||
repository_path,
|
||||
location_config,
|
||||
storage_config,
|
||||
consistency_config,
|
||||
|
@ -268,7 +268,7 @@ def check_archives(
|
|||
try:
|
||||
borg_repository_id = json.loads(
|
||||
rinfo.display_repository_info(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
argparse.Namespace(json=True),
|
||||
|
@ -277,7 +277,7 @@ def check_archives(
|
|||
)
|
||||
)['repository']['id']
|
||||
except (json.JSONDecodeError, KeyError):
|
||||
raise ValueError(f'Cannot determine Borg repository ID for {repository}')
|
||||
raise ValueError(f'Cannot determine Borg repository ID for {repository_path}')
|
||||
|
||||
checks = filter_checks_on_frequency(
|
||||
location_config,
|
||||
|
@ -310,7 +310,7 @@ def check_archives(
|
|||
+ verbosity_flags
|
||||
+ (('--progress',) if progress else ())
|
||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
borg_environment = environment.make_environment(storage_config)
|
||||
|
@ -329,6 +329,6 @@ def check_archives(
|
|||
|
||||
if 'extract' in checks:
|
||||
extract.extract_last_archive_dry_run(
|
||||
storage_config, local_borg_version, repository, lock_wait, local_path, remote_path
|
||||
storage_config, local_borg_version, repository_path, lock_wait, local_path, remote_path
|
||||
)
|
||||
write_check_time(make_check_time_path(location_config, borg_repository_id, 'extract'))
|
||||
|
|
|
@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
def compact_segments(
|
||||
dry_run,
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
local_path='borg',
|
||||
|
@ -36,11 +36,11 @@ def compact_segments(
|
|||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
if dry_run:
|
||||
logging.info(f'{repository}: Skipping compact (dry run)')
|
||||
logging.info(f'{repository_path}: Skipping compact (dry run)')
|
||||
return
|
||||
|
||||
execute_command(
|
||||
|
|
|
@ -322,7 +322,7 @@ def check_all_source_directories_exist(source_directories):
|
|||
|
||||
def create_archive(
|
||||
dry_run,
|
||||
repository,
|
||||
repository_path,
|
||||
location_config,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
|
@ -411,7 +411,7 @@ def create_archive(
|
|||
|
||||
if stream_processes and location_config.get('read_special') is False:
|
||||
logger.warning(
|
||||
f'{repository}: Ignoring configured "read_special" value of false, as true is needed for database hooks.'
|
||||
f'{repository_path}: Ignoring configured "read_special" value of false, as true is needed for database hooks.'
|
||||
)
|
||||
|
||||
create_command = (
|
||||
|
@ -446,7 +446,9 @@ def create_archive(
|
|||
)
|
||||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||
+ flags.make_repository_archive_flags(repository, archive_name_format, local_borg_version)
|
||||
+ flags.make_repository_archive_flags(
|
||||
repository_path, archive_name_format, local_borg_version
|
||||
)
|
||||
+ (sources if not pattern_file else ())
|
||||
)
|
||||
|
||||
|
@ -466,7 +468,7 @@ def create_archive(
|
|||
# If database hooks are enabled (as indicated by streaming processes), exclude files that might
|
||||
# cause Borg to hang. But skip this if the user has explicitly set the "read_special" to True.
|
||||
if stream_processes and not location_config.get('read_special'):
|
||||
logger.debug(f'{repository}: Collecting special file paths')
|
||||
logger.debug(f'{repository_path}: Collecting special file paths')
|
||||
special_file_paths = collect_special_file_paths(
|
||||
create_command,
|
||||
local_path,
|
||||
|
@ -477,7 +479,7 @@ def create_archive(
|
|||
|
||||
if special_file_paths:
|
||||
logger.warning(
|
||||
f'{repository}: Excluding special files to prevent Borg from hanging: {", ".join(special_file_paths)}'
|
||||
f'{repository_path}: Excluding special files to prevent Borg from hanging: {", ".join(special_file_paths)}'
|
||||
)
|
||||
exclude_file = write_pattern_file(
|
||||
expand_home_directories(
|
||||
|
|
|
@ -9,7 +9,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
def export_tar_archive(
|
||||
dry_run,
|
||||
repository,
|
||||
repository_path,
|
||||
archive,
|
||||
paths,
|
||||
destination_path,
|
||||
|
@ -45,7 +45,7 @@ def export_tar_archive(
|
|||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (('--tar-filter', tar_filter) if tar_filter else ())
|
||||
+ (('--strip-components', str(strip_components)) if strip_components else ())
|
||||
+ flags.make_repository_archive_flags(repository, archive, local_borg_version,)
|
||||
+ flags.make_repository_archive_flags(repository_path, archive, local_borg_version,)
|
||||
+ (destination_path,)
|
||||
+ (tuple(paths) if paths else ())
|
||||
)
|
||||
|
@ -56,7 +56,7 @@ def export_tar_archive(
|
|||
output_log_level = logging.INFO
|
||||
|
||||
if dry_run:
|
||||
logging.info(f'{repository}: Skipping export to tar file (dry run)')
|
||||
logging.info(f'{repository_path}: Skipping export to tar file (dry run)')
|
||||
return
|
||||
|
||||
execute_command(
|
||||
|
|
|
@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
|||
def extract_last_archive_dry_run(
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
repository,
|
||||
repository_path,
|
||||
lock_wait=None,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
|
@ -30,7 +30,7 @@ def extract_last_archive_dry_run(
|
|||
|
||||
try:
|
||||
last_archive_name = rlist.resolve_archive_name(
|
||||
repository, 'latest', storage_config, local_borg_version, local_path, remote_path
|
||||
repository_path, 'latest', storage_config, local_borg_version, local_path, remote_path
|
||||
)
|
||||
except ValueError:
|
||||
logger.warning('No archives found. Skipping extract consistency check.')
|
||||
|
@ -44,7 +44,9 @@ def extract_last_archive_dry_run(
|
|||
+ lock_wait_flags
|
||||
+ verbosity_flags
|
||||
+ list_flag
|
||||
+ flags.make_repository_archive_flags(repository, last_archive_name, local_borg_version)
|
||||
+ flags.make_repository_archive_flags(
|
||||
repository_path, last_archive_name, local_borg_version
|
||||
)
|
||||
)
|
||||
|
||||
execute_command(
|
||||
|
|
|
@ -33,7 +33,7 @@ def make_flags_from_arguments(arguments, excludes=()):
|
|||
)
|
||||
|
||||
|
||||
def make_repository_flags(repository, local_borg_version):
|
||||
def make_repository_flags(repository_path, local_borg_version):
|
||||
'''
|
||||
Given the path of a Borg repository and the local Borg version, return Borg-version-appropriate
|
||||
command-line flags (as a tuple) for selecting that repository.
|
||||
|
@ -42,17 +42,17 @@ def make_repository_flags(repository, local_borg_version):
|
|||
('--repo',)
|
||||
if feature.available(feature.Feature.SEPARATE_REPOSITORY_ARCHIVE, local_borg_version)
|
||||
else ()
|
||||
) + (repository,)
|
||||
) + (repository_path,)
|
||||
|
||||
|
||||
def make_repository_archive_flags(repository, archive, local_borg_version):
|
||||
def make_repository_archive_flags(repository_path, archive, local_borg_version):
|
||||
'''
|
||||
Given the path of a Borg repository, an archive name or pattern, and the local Borg version,
|
||||
return Borg-version-appropriate command-line flags (as a tuple) for selecting that repository
|
||||
and archive.
|
||||
'''
|
||||
return (
|
||||
('--repo', repository, archive)
|
||||
('--repo', repository_path, archive)
|
||||
if feature.available(feature.Feature.SEPARATE_REPOSITORY_ARCHIVE, local_borg_version)
|
||||
else (f'{repository}::{archive}',)
|
||||
else (f'{repository_path}::{archive}',)
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def display_archives_info(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
info_arguments,
|
||||
|
@ -49,7 +49,7 @@ def display_archives_info(
|
|||
+ flags.make_flags_from_arguments(
|
||||
info_arguments, excludes=('repository', 'archive', 'prefix')
|
||||
)
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
+ (
|
||||
flags.make_flags('match-archives', info_arguments.archive)
|
||||
if feature.available(feature.Feature.MATCH_ARCHIVES, local_borg_version)
|
||||
|
|
|
@ -21,7 +21,7 @@ MAKE_FLAGS_EXCLUDES = (
|
|||
|
||||
|
||||
def make_list_command(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
list_arguments,
|
||||
|
@ -52,10 +52,10 @@ def make_list_command(
|
|||
+ flags.make_flags_from_arguments(list_arguments, excludes=MAKE_FLAGS_EXCLUDES)
|
||||
+ (
|
||||
flags.make_repository_archive_flags(
|
||||
repository, list_arguments.archive, local_borg_version
|
||||
repository_path, list_arguments.archive, local_borg_version
|
||||
)
|
||||
if list_arguments.archive
|
||||
else flags.make_repository_flags(repository, local_borg_version)
|
||||
else flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
+ (tuple(list_arguments.paths) if list_arguments.paths else ())
|
||||
)
|
||||
|
@ -86,7 +86,7 @@ def make_find_paths(find_paths):
|
|||
|
||||
|
||||
def capture_archive_listing(
|
||||
repository,
|
||||
repository_path,
|
||||
archive,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
|
@ -104,11 +104,11 @@ def capture_archive_listing(
|
|||
return tuple(
|
||||
execute_command_and_capture_output(
|
||||
make_list_command(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
argparse.Namespace(
|
||||
repository=repository,
|
||||
repository=repository_path,
|
||||
archive=archive,
|
||||
paths=[f'sh:{list_path}'],
|
||||
find_paths=None,
|
||||
|
@ -126,7 +126,7 @@ def capture_archive_listing(
|
|||
|
||||
|
||||
def list_archive(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
list_arguments,
|
||||
|
@ -149,7 +149,7 @@ def list_archive(
|
|||
)
|
||||
|
||||
rlist_arguments = argparse.Namespace(
|
||||
repository=repository,
|
||||
repository=repository_path,
|
||||
short=list_arguments.short,
|
||||
format=list_arguments.format,
|
||||
json=list_arguments.json,
|
||||
|
@ -160,7 +160,12 @@ def list_archive(
|
|||
last=list_arguments.last,
|
||||
)
|
||||
return rlist.list_repository(
|
||||
repository, storage_config, local_borg_version, rlist_arguments, local_path, remote_path
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
rlist_arguments,
|
||||
local_path,
|
||||
remote_path,
|
||||
)
|
||||
|
||||
if list_arguments.archive:
|
||||
|
@ -181,7 +186,7 @@ def list_archive(
|
|||
# getting a list of archives to search.
|
||||
if list_arguments.find_paths and not list_arguments.archive:
|
||||
rlist_arguments = argparse.Namespace(
|
||||
repository=repository,
|
||||
repository=repository_path,
|
||||
short=True,
|
||||
format=None,
|
||||
json=None,
|
||||
|
@ -196,7 +201,7 @@ def list_archive(
|
|||
archive_lines = tuple(
|
||||
execute_command_and_capture_output(
|
||||
rlist.make_rlist_command(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
rlist_arguments,
|
||||
|
@ -213,7 +218,7 @@ def list_archive(
|
|||
|
||||
# For each archive listed by Borg, run list on the contents of that archive.
|
||||
for archive in archive_lines:
|
||||
logger.answer(f'{repository}: Listing archive {archive}')
|
||||
logger.answer(f'{repository_path}: Listing archive {archive}')
|
||||
|
||||
archive_arguments = copy.copy(list_arguments)
|
||||
archive_arguments.archive = archive
|
||||
|
@ -224,7 +229,7 @@ def list_archive(
|
|||
setattr(archive_arguments, name, None)
|
||||
|
||||
main_command = make_list_command(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
archive_arguments,
|
||||
|
|
|
@ -7,7 +7,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def mount_archive(
|
||||
repository,
|
||||
repository_path,
|
||||
archive,
|
||||
mount_point,
|
||||
paths,
|
||||
|
@ -38,7 +38,7 @@ def mount_archive(
|
|||
+ (('-o', options) if options else ())
|
||||
+ (
|
||||
(
|
||||
flags.make_repository_flags(repository, local_borg_version)
|
||||
flags.make_repository_flags(repository_path, local_borg_version)
|
||||
+ (
|
||||
('--match-archives', archive)
|
||||
if feature.available(feature.Feature.MATCH_ARCHIVES, local_borg_version)
|
||||
|
@ -47,9 +47,9 @@ def mount_archive(
|
|||
)
|
||||
if feature.available(feature.Feature.SEPARATE_REPOSITORY_ARCHIVE, local_borg_version)
|
||||
else (
|
||||
flags.make_repository_archive_flags(repository, archive, local_borg_version)
|
||||
flags.make_repository_archive_flags(repository_path, archive, local_borg_version)
|
||||
if archive
|
||||
else flags.make_repository_flags(repository, local_borg_version)
|
||||
else flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
)
|
||||
+ (mount_point,)
|
||||
|
|
|
@ -39,7 +39,7 @@ def make_prune_flags(retention_config, local_borg_version):
|
|||
|
||||
def prune_archives(
|
||||
dry_run,
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
retention_config,
|
||||
local_borg_version,
|
||||
|
@ -74,7 +74,7 @@ def prune_archives(
|
|||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
if stats or list_archives:
|
||||
|
|
|
@ -13,7 +13,7 @@ RINFO_REPOSITORY_NOT_FOUND_EXIT_CODE = 2
|
|||
|
||||
def create_repository(
|
||||
dry_run,
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
encryption_mode,
|
||||
|
@ -33,14 +33,14 @@ def create_repository(
|
|||
'''
|
||||
try:
|
||||
rinfo.display_repository_info(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
argparse.Namespace(json=True),
|
||||
local_path,
|
||||
remote_path,
|
||||
)
|
||||
logger.info(f'{repository}: Repository already exists. Skipping creation.')
|
||||
logger.info(f'{repository_path}: Repository already exists. Skipping creation.')
|
||||
return
|
||||
except subprocess.CalledProcessError as error:
|
||||
if error.returncode != RINFO_REPOSITORY_NOT_FOUND_EXIT_CODE:
|
||||
|
@ -65,11 +65,11 @@ def create_repository(
|
|||
+ (('--debug',) if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (tuple(extra_borg_options.split(' ')) if extra_borg_options else ())
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
if dry_run:
|
||||
logging.info(f'{repository}: Skipping repository creation (dry run)')
|
||||
logging.info(f'{repository_path}: Skipping repository creation (dry run)')
|
||||
return
|
||||
|
||||
# Do not capture output here, so as to support interactive prompts.
|
||||
|
|
|
@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def display_repository_info(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
rinfo_arguments,
|
||||
|
@ -43,7 +43,7 @@ def display_repository_info(
|
|||
+ flags.make_flags('remote-path', remote_path)
|
||||
+ flags.make_flags('lock-wait', lock_wait)
|
||||
+ (('--json',) if rinfo_arguments.json else ())
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
extra_environment = environment.make_environment(storage_config)
|
||||
|
|
|
@ -8,7 +8,12 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def resolve_archive_name(
|
||||
repository, archive, storage_config, local_borg_version, local_path='borg', remote_path=None
|
||||
repository_path,
|
||||
archive,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
local_path='borg',
|
||||
remote_path=None,
|
||||
):
|
||||
'''
|
||||
Given a local or remote repository path, an archive name, a storage config dict, a local Borg
|
||||
|
@ -31,7 +36,7 @@ def resolve_archive_name(
|
|||
+ flags.make_flags('lock-wait', lock_wait)
|
||||
+ flags.make_flags('last', 1)
|
||||
+ ('--short',)
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
output = execute_command_and_capture_output(
|
||||
|
@ -42,7 +47,7 @@ def resolve_archive_name(
|
|||
except IndexError:
|
||||
raise ValueError('No archives found in the repository')
|
||||
|
||||
logger.debug(f'{repository}: Latest archive is {latest_archive}')
|
||||
logger.debug(f'{repository_path}: Latest archive is {latest_archive}')
|
||||
|
||||
return latest_archive
|
||||
|
||||
|
@ -51,7 +56,7 @@ MAKE_FLAGS_EXCLUDES = ('repository', 'prefix')
|
|||
|
||||
|
||||
def make_rlist_command(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
rlist_arguments,
|
||||
|
@ -92,12 +97,12 @@ def make_rlist_command(
|
|||
else ()
|
||||
)
|
||||
+ flags.make_flags_from_arguments(rlist_arguments, excludes=MAKE_FLAGS_EXCLUDES)
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
)
|
||||
|
||||
|
||||
def list_repository(
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
rlist_arguments,
|
||||
|
@ -113,7 +118,12 @@ def list_repository(
|
|||
borg_environment = environment.make_environment(storage_config)
|
||||
|
||||
main_command = make_rlist_command(
|
||||
repository, storage_config, local_borg_version, rlist_arguments, local_path, remote_path
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
rlist_arguments,
|
||||
local_path,
|
||||
remote_path,
|
||||
)
|
||||
|
||||
if rlist_arguments.json:
|
||||
|
|
|
@ -9,7 +9,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
def transfer_archives(
|
||||
dry_run,
|
||||
repository,
|
||||
repository_path,
|
||||
storage_config,
|
||||
local_borg_version,
|
||||
transfer_arguments,
|
||||
|
@ -38,7 +38,7 @@ def transfer_archives(
|
|||
transfer_arguments,
|
||||
excludes=('repository', 'source_repository', 'archive', 'match_archives'),
|
||||
)
|
||||
+ flags.make_repository_flags(repository, local_borg_version)
|
||||
+ flags.make_repository_flags(repository_path, local_borg_version)
|
||||
+ flags.make_flags('other-repo', transfer_arguments.source_repository)
|
||||
+ flags.make_flags('dry-run', dry_run)
|
||||
)
|
||||
|
|
|
@ -106,7 +106,8 @@ def run_configuration(config_filename, config, arguments):
|
|||
repo_queue.put((repo, 0),)
|
||||
|
||||
while not repo_queue.empty():
|
||||
repository_path, retry_num = repo_queue.get()
|
||||
repository, retry_num = repo_queue.get()
|
||||
logger.debug(f'{repository["path"]}: Running actions for repository')
|
||||
timeout = retry_num * retry_wait
|
||||
if timeout:
|
||||
logger.warning(f'{config_filename}: Sleeping {timeout}s before next retry')
|
||||
|
@ -123,14 +124,14 @@ def run_configuration(config_filename, config, arguments):
|
|||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
local_borg_version=local_borg_version,
|
||||
repository_path=repository_path,
|
||||
repository=repository,
|
||||
)
|
||||
except (OSError, CalledProcessError, ValueError) as error:
|
||||
if retry_num < retries:
|
||||
repo_queue.put((repository_path, retry_num + 1),)
|
||||
repo_queue.put((repository, retry_num + 1),)
|
||||
tuple( # Consume the generator so as to trigger logging.
|
||||
log_error_records(
|
||||
f'{repository_path}: Error running actions for repository',
|
||||
f'{repository["path"]}: Error running actions for repository',
|
||||
error,
|
||||
levelno=logging.WARNING,
|
||||
log_command_error_output=True,
|
||||
|
@ -145,10 +146,10 @@ def run_configuration(config_filename, config, arguments):
|
|||
return
|
||||
|
||||
yield from log_error_records(
|
||||
f'{repository_path}: Error running actions for repository', error
|
||||
f'{repository["path"]}: Error running actions for repository', error
|
||||
)
|
||||
encountered_error = error
|
||||
error_repository = repository_path
|
||||
error_repository = repository['path']
|
||||
|
||||
try:
|
||||
if using_primary_action:
|
||||
|
@ -167,7 +168,7 @@ def run_configuration(config_filename, config, arguments):
|
|||
return
|
||||
|
||||
encountered_error = error
|
||||
yield from log_error_records(f'{repository_path}: Error pinging monitor', error)
|
||||
yield from log_error_records(f'{repository["path"]}: Error pinging monitor', error)
|
||||
|
||||
if not encountered_error:
|
||||
try:
|
||||
|
@ -244,7 +245,7 @@ def run_actions(
|
|||
local_path,
|
||||
remote_path,
|
||||
local_borg_version,
|
||||
repository_path,
|
||||
repository,
|
||||
):
|
||||
'''
|
||||
Given parsed command-line arguments as an argparse.ArgumentParser instance, the configuration
|
||||
|
@ -259,13 +260,13 @@ def run_actions(
|
|||
invalid.
|
||||
'''
|
||||
add_custom_log_levels()
|
||||
repository = os.path.expanduser(repository_path)
|
||||
repository_path = os.path.expanduser(repository['path'])
|
||||
global_arguments = arguments['global']
|
||||
dry_run_label = ' (dry run; not making any changes)' if global_arguments.dry_run else ''
|
||||
hook_context = {
|
||||
'repository': repository_path,
|
||||
# Deprecated: For backwards compatibility with borgmatic < 1.6.0.
|
||||
'repositories': ','.join(location['repositories']),
|
||||
'repositories': ','.join([repo['path'] for repo in location['repositories']]),
|
||||
}
|
||||
|
||||
command.execute_hook(
|
||||
|
|
|
@ -57,9 +57,15 @@ def normalize(config_filename, config):
|
|||
# Upgrade remote repositories to ssh:// syntax, required in Borg 2.
|
||||
repositories = location.get('repositories')
|
||||
if repositories:
|
||||
if isinstance(repositories[0], str):
|
||||
config['location']['repositories'] = [
|
||||
{'path': repository} for repository in repositories
|
||||
]
|
||||
repositories = config['location']['repositories']
|
||||
config['location']['repositories'] = []
|
||||
for repository in repositories:
|
||||
if '~' in repository:
|
||||
for repository_dict in repositories:
|
||||
repository_path = repository_dict['path']
|
||||
if '~' in repository_path:
|
||||
logs.append(
|
||||
logging.makeLogRecord(
|
||||
dict(
|
||||
|
@ -69,26 +75,31 @@ def normalize(config_filename, config):
|
|||
)
|
||||
)
|
||||
)
|
||||
if ':' in repository:
|
||||
if repository.startswith('file://'):
|
||||
config['location']['repositories'].append(
|
||||
os.path.abspath(repository.partition('file://')[-1])
|
||||
if ':' in repository_path:
|
||||
if repository_path.startswith('file://'):
|
||||
updated_repository_path = os.path.abspath(
|
||||
repository_path.partition('file://')[-1]
|
||||
)
|
||||
elif repository.startswith('ssh://'):
|
||||
config['location']['repositories'].append(repository)
|
||||
config['location']['repositories'].append(
|
||||
dict(repository_dict, path=updated_repository_path,)
|
||||
)
|
||||
elif repository_path.startswith('ssh://'):
|
||||
config['location']['repositories'].append(repository_dict)
|
||||
else:
|
||||
rewritten_repository = f"ssh://{repository.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}"
|
||||
rewritten_repository_path = f"ssh://{repository_path.replace(':~', '/~').replace(':/', '/').replace(':', '/./')}"
|
||||
logs.append(
|
||||
logging.makeLogRecord(
|
||||
dict(
|
||||
levelno=logging.WARNING,
|
||||
levelname='WARNING',
|
||||
msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated. Interpreting "{repository}" as "{rewritten_repository}"',
|
||||
msg=f'{config_filename}: Remote repository paths without ssh:// syntax are deprecated. Interpreting "{repository_path}" as "{rewritten_repository_path}"',
|
||||
)
|
||||
)
|
||||
)
|
||||
config['location']['repositories'].append(rewritten_repository)
|
||||
config['location']['repositories'].append(
|
||||
dict(repository_dict, path=rewritten_repository_path,)
|
||||
)
|
||||
else:
|
||||
config['location']['repositories'].append(repository)
|
||||
config['location']['repositories'].append(repository_dict)
|
||||
|
||||
return logs
|
||||
|
|
|
@ -40,19 +40,40 @@ properties:
|
|||
repositories:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- path
|
||||
properties:
|
||||
path:
|
||||
type: string
|
||||
description: |
|
||||
Paths to local or remote repositories (required). Tildes are
|
||||
expanded. Multiple repositories are backed up to in
|
||||
sequence. Borg placeholders can be used. See the output of
|
||||
"borg help placeholders" for details. See ssh_command for
|
||||
SSH options like identity file or port. If systemd service
|
||||
is used, then add local repository paths in the systemd
|
||||
service file to the ReadWritePaths list.
|
||||
Path to local or remote repository
|
||||
(required). Tildes are expanded.
|
||||
Multiple repositories are backed up
|
||||
to in sequence. Borg placeholders
|
||||
can be used. See the output of
|
||||
"borg help placeholders" for
|
||||
details. See ssh_command for SSH
|
||||
options like identity file or port.
|
||||
If systemd service is used, then
|
||||
add local repository paths in the
|
||||
systemd service file to the
|
||||
ReadWritePaths list.
|
||||
example: ssh://user@backupserver/./{fqdn}
|
||||
label:
|
||||
type: string
|
||||
description: |
|
||||
Optional label for the repository. This
|
||||
can be used with the --repository flag
|
||||
to select a repository to backup to.
|
||||
If not specified, the repository path is
|
||||
used as the label.
|
||||
example: backupserver
|
||||
example:
|
||||
- ssh://user@backupserver/./sourcehostname.borg
|
||||
- ssh://user@backupserver/./{fqdn}
|
||||
- /var/local/backups/local.borg
|
||||
- path: ssh://user@backupserver/./sourcehostname.borg
|
||||
label: backupserver
|
||||
- path: /mnt/backup
|
||||
label: local
|
||||
working_directory:
|
||||
type: string
|
||||
description: |
|
||||
|
|
|
@ -137,9 +137,17 @@ def normalize_repository_path(repository):
|
|||
|
||||
def repositories_match(first, second):
|
||||
'''
|
||||
Given two repository paths (relative and/or absolute), return whether they match.
|
||||
Given two repository dicts with keys 'path' (relative and/or absolute),
|
||||
and 'label', or two repository paths, return whether they match.
|
||||
'''
|
||||
return normalize_repository_path(first) == normalize_repository_path(second)
|
||||
if isinstance(first, str):
|
||||
first = {'path': first, 'label': first}
|
||||
if isinstance(second, str):
|
||||
second = {'path': second, 'label': second}
|
||||
return (first.get('label') == second.get('label')) or (
|
||||
normalize_repository_path(first.get('path'))
|
||||
== normalize_repository_path(second.get('path'))
|
||||
)
|
||||
|
||||
|
||||
def guard_configuration_contains_repository(repository, configurations):
|
||||
|
@ -159,7 +167,7 @@ def guard_configuration_contains_repository(repository, configurations):
|
|||
config_repository
|
||||
for config in configurations.values()
|
||||
for config_repository in config['location']['repositories']
|
||||
if repositories_match(repository, config_repository)
|
||||
if repositories_match(config_repository, repository)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -277,7 +277,8 @@ If you have a single repository in your borgmatic configuration file(s), no
|
|||
problem: the `restore` action figures out which repository to use.
|
||||
|
||||
But if you have multiple repositories configured, then you'll need to specify
|
||||
the repository path containing the archive to restore. Here's an example:
|
||||
the repository to use via the `--repository` flag. This can be done either
|
||||
with the repository's path or its label as configured in your borgmatic configuration file.
|
||||
|
||||
```bash
|
||||
borgmatic restore --repository repo.borg --archive host-2023-...
|
||||
|
|
|
@ -51,7 +51,8 @@ If you have a single repository in your borgmatic configuration file(s), no
|
|||
problem: the `extract` action figures out which repository to use.
|
||||
|
||||
But if you have multiple repositories configured, then you'll need to specify
|
||||
the repository path containing the archive to extract. Here's an example:
|
||||
the repository to use via the `--repository` flag. This can be done either
|
||||
with the repository's path or its label as configured in your borgmatic configuration file.
|
||||
|
||||
```bash
|
||||
borgmatic extract --repository repo.borg --archive host-2023-...
|
||||
|
|
|
@ -53,7 +53,8 @@ This runs Borg's `rlist` command once on each configured borgmatic repository.
|
|||
(The native `borgmatic rlist` action should be preferred for most use.)
|
||||
|
||||
What if you only want to run Borg on a single configured borgmatic repository
|
||||
when you've got several configured? Not a problem.
|
||||
when you've got several configured? Not a problem. The `--repository` argument
|
||||
lets you specify the repository to use, either by its path or its label:
|
||||
|
||||
```bash
|
||||
borgmatic borg --repository repo.borg break-lock
|
||||
|
|
|
@ -17,9 +17,8 @@ def generate_configuration(config_path, repository_path):
|
|||
open(config_path)
|
||||
.read()
|
||||
.replace('ssh://user@backupserver/./sourcehostname.borg', repository_path)
|
||||
.replace('- ssh://user@backupserver/./{fqdn}', '') # noqa: FS003
|
||||
.replace('- /var/local/backups/local.borg', '')
|
||||
.replace('- /home/user/path with spaces', '')
|
||||
.replace('- path: /mnt/backup', '')
|
||||
.replace('label: local', '')
|
||||
.replace('- /home', f'- {config_path}')
|
||||
.replace('- /etc', '')
|
||||
.replace('- /var/log/syslog*', '')
|
||||
|
|
|
@ -63,7 +63,10 @@ def test_parse_configuration_transforms_file_into_mapping():
|
|||
config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
|
||||
|
||||
assert config == {
|
||||
'location': {'source_directories': ['/home', '/etc'], 'repositories': ['hostname.borg']},
|
||||
'location': {
|
||||
'source_directories': ['/home', '/etc'],
|
||||
'repositories': [{'path': 'hostname.borg'}],
|
||||
},
|
||||
'retention': {'keep_daily': 7, 'keep_hourly': 24, 'keep_minutely': 60},
|
||||
'consistency': {'checks': [{'name': 'repository'}, {'name': 'archives'}]},
|
||||
}
|
||||
|
@ -89,7 +92,7 @@ def test_parse_configuration_passes_through_quoted_punctuation():
|
|||
assert config == {
|
||||
'location': {
|
||||
'source_directories': [f'/home/{string.punctuation}'],
|
||||
'repositories': ['test.borg'],
|
||||
'repositories': [{'path': 'test.borg'}],
|
||||
}
|
||||
}
|
||||
assert logs == []
|
||||
|
@ -151,7 +154,7 @@ def test_parse_configuration_inlines_include():
|
|||
config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
|
||||
|
||||
assert config == {
|
||||
'location': {'source_directories': ['/home'], 'repositories': ['hostname.borg']},
|
||||
'location': {'source_directories': ['/home'], 'repositories': [{'path': 'hostname.borg'}]},
|
||||
'retention': {'keep_daily': 7, 'keep_hourly': 24},
|
||||
}
|
||||
assert logs == []
|
||||
|
@ -185,7 +188,7 @@ def test_parse_configuration_merges_include():
|
|||
config, logs = module.parse_configuration('/tmp/config.yaml', '/tmp/schema.yaml')
|
||||
|
||||
assert config == {
|
||||
'location': {'source_directories': ['/home'], 'repositories': ['hostname.borg']},
|
||||
'location': {'source_directories': ['/home'], 'repositories': [{'path': 'hostname.borg'}]},
|
||||
'retention': {'keep_daily': 1, 'keep_hourly': 24},
|
||||
}
|
||||
assert logs == []
|
||||
|
@ -247,7 +250,7 @@ def test_parse_configuration_applies_overrides():
|
|||
assert config == {
|
||||
'location': {
|
||||
'source_directories': ['/home'],
|
||||
'repositories': ['hostname.borg'],
|
||||
'repositories': [{'path': 'hostname.borg'}],
|
||||
'local_path': 'borg2',
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +276,7 @@ def test_parse_configuration_applies_normalization():
|
|||
assert config == {
|
||||
'location': {
|
||||
'source_directories': ['/home'],
|
||||
'repositories': ['hostname.borg'],
|
||||
'repositories': [{'path': 'hostname.borg'}],
|
||||
'exclude_if_present': ['.nobackup'],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ def test_run_borg_does_not_raise():
|
|||
borg_arguments = flexmock(repository=flexmock(), archive=flexmock(), options=flexmock())
|
||||
|
||||
module.run_borg(
|
||||
repository='repo',
|
||||
repository={'path': 'repos'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
borg_arguments=borg_arguments,
|
||||
|
|
|
@ -10,7 +10,7 @@ def test_run_break_lock_does_not_raise():
|
|||
break_lock_arguments = flexmock(repository=flexmock())
|
||||
|
||||
module.run_break_lock(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
break_lock_arguments=break_lock_arguments,
|
||||
|
|
|
@ -18,7 +18,7 @@ def test_run_check_calls_hooks_for_configured_repository():
|
|||
|
||||
module.run_check(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location={'repositories': ['repo']},
|
||||
storage={},
|
||||
consistency={},
|
||||
|
@ -49,7 +49,7 @@ def test_run_check_runs_with_selected_repository():
|
|||
|
||||
module.run_check(
|
||||
config_filename='test.yaml',
|
||||
repository=flexmock(),
|
||||
repository={'path': 'repo'},
|
||||
location={'repositories': ['repo']},
|
||||
storage={},
|
||||
consistency={},
|
||||
|
@ -80,7 +80,7 @@ def test_run_check_bails_if_repository_does_not_match():
|
|||
|
||||
module.run_check(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location={'repositories': ['repo']},
|
||||
storage={},
|
||||
consistency={},
|
||||
|
|
|
@ -16,7 +16,7 @@ def test_compact_actions_calls_hooks_for_configured_repository():
|
|||
|
||||
module.run_compact(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
retention={},
|
||||
hooks={},
|
||||
|
@ -44,7 +44,7 @@ def test_compact_runs_with_selected_repository():
|
|||
|
||||
module.run_compact(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
retention={},
|
||||
hooks={},
|
||||
|
@ -72,7 +72,7 @@ def test_compact_bails_if_repository_does_not_match():
|
|||
|
||||
module.run_compact(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
retention={},
|
||||
hooks={},
|
||||
|
|
|
@ -24,7 +24,7 @@ def test_run_create_executes_and_calls_hooks_for_configured_repository():
|
|||
list(
|
||||
module.run_create(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location={},
|
||||
storage={},
|
||||
hooks={},
|
||||
|
@ -57,7 +57,7 @@ def test_run_create_runs_with_selected_repository():
|
|||
list(
|
||||
module.run_create(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location={},
|
||||
storage={},
|
||||
hooks={},
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_run_export_tar_does_not_raise():
|
|||
global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
|
||||
|
||||
module.run_export_tar(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
export_tar_arguments=export_tar_arguments,
|
||||
|
|
|
@ -20,7 +20,7 @@ def test_run_extract_calls_hooks():
|
|||
|
||||
module.run_extract(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location={'repositories': ['repo']},
|
||||
storage={},
|
||||
hooks={},
|
||||
|
|
|
@ -14,7 +14,7 @@ def test_run_info_does_not_raise():
|
|||
|
||||
list(
|
||||
module.run_info(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
info_arguments=info_arguments,
|
||||
|
|
|
@ -14,7 +14,7 @@ def test_run_list_does_not_raise():
|
|||
|
||||
list(
|
||||
module.run_list(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
list_arguments=list_arguments,
|
||||
|
|
|
@ -17,7 +17,7 @@ def test_run_mount_does_not_raise():
|
|||
)
|
||||
|
||||
module.run_mount(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
mount_arguments=mount_arguments,
|
||||
|
|
|
@ -13,7 +13,7 @@ def test_run_prune_calls_hooks_for_configured_repository():
|
|||
|
||||
module.run_prune(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
retention={},
|
||||
hooks={},
|
||||
|
@ -38,7 +38,7 @@ def test_run_prune_runs_with_selected_repository():
|
|||
|
||||
module.run_prune(
|
||||
config_filename='test.yaml',
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
retention={},
|
||||
hooks={},
|
||||
|
|
|
@ -18,7 +18,7 @@ def test_run_rcreate_does_not_raise():
|
|||
)
|
||||
|
||||
module.run_rcreate(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
rcreate_arguments=arguments,
|
||||
|
@ -45,7 +45,7 @@ def test_run_rcreate_bails_if_repository_does_not_match():
|
|||
)
|
||||
|
||||
module.run_rcreate(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
rcreate_arguments=arguments,
|
||||
|
|
|
@ -67,7 +67,7 @@ def test_collect_archive_database_names_parses_archive_paths():
|
|||
)
|
||||
|
||||
archive_database_names = module.collect_archive_database_names(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
archive='archive',
|
||||
location={'borgmatic_source_directory': '.borgmatic'},
|
||||
storage=flexmock(),
|
||||
|
@ -92,7 +92,7 @@ def test_collect_archive_database_names_parses_directory_format_archive_paths():
|
|||
)
|
||||
|
||||
archive_database_names = module.collect_archive_database_names(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
archive='archive',
|
||||
location={'borgmatic_source_directory': '.borgmatic'},
|
||||
storage=flexmock(),
|
||||
|
@ -113,7 +113,7 @@ def test_collect_archive_database_names_skips_bad_archive_paths():
|
|||
)
|
||||
|
||||
archive_database_names = module.collect_archive_database_names(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
archive='archive',
|
||||
location={'borgmatic_source_directory': '.borgmatic'},
|
||||
storage=flexmock(),
|
||||
|
@ -251,7 +251,7 @@ def test_run_restore_restores_each_database():
|
|||
flexmock(module).should_receive('ensure_databases_found')
|
||||
|
||||
module.run_restore(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location=flexmock(),
|
||||
storage=flexmock(),
|
||||
hooks=flexmock(),
|
||||
|
@ -273,7 +273,7 @@ def test_run_restore_bails_for_non_matching_repository():
|
|||
flexmock(module).should_receive('restore_single_database').never()
|
||||
|
||||
module.run_restore(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location=flexmock(),
|
||||
storage=flexmock(),
|
||||
hooks=flexmock(),
|
||||
|
@ -345,7 +345,7 @@ def test_run_restore_restores_database_configured_with_all_name():
|
|||
flexmock(module).should_receive('ensure_databases_found')
|
||||
|
||||
module.run_restore(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location=flexmock(),
|
||||
storage=flexmock(),
|
||||
hooks=flexmock(),
|
||||
|
@ -417,7 +417,7 @@ def test_run_restore_skips_missing_database():
|
|||
flexmock(module).should_receive('ensure_databases_found')
|
||||
|
||||
module.run_restore(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location=flexmock(),
|
||||
storage=flexmock(),
|
||||
hooks=flexmock(),
|
||||
|
@ -483,7 +483,7 @@ def test_run_restore_restores_databases_from_different_hooks():
|
|||
flexmock(module).should_receive('ensure_databases_found')
|
||||
|
||||
module.run_restore(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
location=flexmock(),
|
||||
storage=flexmock(),
|
||||
hooks=flexmock(),
|
||||
|
|
|
@ -11,7 +11,7 @@ def test_run_rinfo_does_not_raise():
|
|||
|
||||
list(
|
||||
module.run_rinfo(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
rinfo_arguments=rinfo_arguments,
|
||||
|
|
|
@ -11,7 +11,7 @@ def test_run_rlist_does_not_raise():
|
|||
|
||||
list(
|
||||
module.run_rlist(
|
||||
repository='repo',
|
||||
repository={'path': 'repo'},
|
||||
storage={},
|
||||
local_borg_version=None,
|
||||
rlist_arguments=rlist_arguments,
|
||||
|
|
|
@ -21,7 +21,10 @@ def test_run_arbitrary_borg_calls_borg_with_parameters():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', options=['break-lock'],
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -40,7 +43,10 @@ def test_run_arbitrary_borg_with_log_info_calls_borg_with_info_parameter():
|
|||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', options=['break-lock'],
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -59,7 +65,10 @@ def test_run_arbitrary_borg_with_log_debug_calls_borg_with_debug_parameter():
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', options=['break-lock'],
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -80,7 +89,7 @@ def test_run_arbitrary_borg_with_lock_wait_calls_borg_with_lock_wait_parameters(
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
|
@ -103,7 +112,7 @@ def test_run_arbitrary_borg_with_archive_calls_borg_with_archive_parameter():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
|
@ -125,7 +134,7 @@ def test_run_arbitrary_borg_with_local_path_calls_borg_via_local_path():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
|
@ -149,7 +158,7 @@ def test_run_arbitrary_borg_with_remote_path_calls_borg_with_remote_path_paramet
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['break-lock'],
|
||||
|
@ -171,7 +180,7 @@ def test_run_arbitrary_borg_passes_borg_specific_parameters_to_borg():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['list', '--progress'],
|
||||
|
@ -192,7 +201,7 @@ def test_run_arbitrary_borg_omits_dash_dash_in_parameters_passed_to_borg():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['--', 'break-lock'],
|
||||
|
@ -213,7 +222,7 @@ def test_run_arbitrary_borg_without_borg_specific_parameters_does_not_raise():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', options=[],
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3', options=[],
|
||||
)
|
||||
|
||||
|
||||
|
@ -231,7 +240,10 @@ def test_run_arbitrary_borg_passes_key_sub_command_to_borg_before_repository():
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', options=['key', 'export'],
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['key', 'export'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -249,7 +261,7 @@ def test_run_arbitrary_borg_passes_debug_sub_command_to_borg_before_repository()
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['debug', 'dump-manifest', 'path'],
|
||||
|
@ -270,7 +282,10 @@ def test_run_arbitrary_borg_with_debug_info_command_does_not_pass_borg_repositor
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', options=['debug', 'info'],
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['debug', 'info'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -288,7 +303,7 @@ def test_run_arbitrary_borg_with_debug_convert_profile_command_does_not_pass_bor
|
|||
)
|
||||
|
||||
module.run_arbitrary_borg(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
options=['debug', 'convert-profile', 'in', 'out'],
|
||||
|
|
|
@ -19,7 +19,7 @@ def test_break_lock_calls_borg_with_required_flags():
|
|||
insert_execute_command_mock(('borg', 'break-lock', 'repo'))
|
||||
|
||||
module.break_lock(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3',
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3',
|
||||
)
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ def test_break_lock_calls_borg_with_remote_path_flags():
|
|||
insert_execute_command_mock(('borg', 'break-lock', '--remote-path', 'borg1', 'repo'))
|
||||
|
||||
module.break_lock(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', remote_path='borg1',
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3', remote_path='borg1',
|
||||
)
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ def test_break_lock_calls_borg_with_umask_flags():
|
|||
insert_execute_command_mock(('borg', 'break-lock', '--umask', '0770', 'repo'))
|
||||
|
||||
module.break_lock(
|
||||
repository='repo', storage_config={'umask': '0770'}, local_borg_version='1.2.3',
|
||||
repository_path='repo', storage_config={'umask': '0770'}, local_borg_version='1.2.3',
|
||||
)
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ def test_break_lock_calls_borg_with_lock_wait_flags():
|
|||
insert_execute_command_mock(('borg', 'break-lock', '--lock-wait', '5', 'repo'))
|
||||
|
||||
module.break_lock(
|
||||
repository='repo', storage_config={'lock_wait': '5'}, local_borg_version='1.2.3',
|
||||
repository_path='repo', storage_config={'lock_wait': '5'}, local_borg_version='1.2.3',
|
||||
)
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ def test_break_lock_with_log_info_calls_borg_with_info_parameter():
|
|||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.break_lock(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3',
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3',
|
||||
)
|
||||
|
||||
|
||||
|
@ -66,5 +66,5 @@ def test_break_lock_with_log_debug_calls_borg_with_debug_flags():
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.break_lock(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3',
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3',
|
||||
)
|
||||
|
|
|
@ -370,7 +370,7 @@ def test_check_archives_with_progress_calls_borg_with_progress_parameter():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -400,7 +400,7 @@ def test_check_archives_with_repair_calls_borg_with_repair_parameter():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -435,7 +435,7 @@ def test_check_archives_calls_borg_with_parameters(checks):
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -455,7 +455,7 @@ def test_check_archives_with_json_error_raises():
|
|||
|
||||
with pytest.raises(ValueError):
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -473,7 +473,7 @@ def test_check_archives_with_missing_json_keys_raises():
|
|||
|
||||
with pytest.raises(ValueError):
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -497,7 +497,7 @@ def test_check_archives_with_extract_check_calls_extract_only():
|
|||
insert_execute_command_never()
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -521,7 +521,7 @@ def test_check_archives_with_log_info_calls_borg_with_info_parameter():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -545,7 +545,7 @@ def test_check_archives_with_log_debug_calls_borg_with_debug_parameter():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -563,7 +563,7 @@ def test_check_archives_without_any_checks_bails():
|
|||
insert_execute_command_never()
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -589,7 +589,7 @@ def test_check_archives_with_local_path_calls_borg_via_local_path():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -616,7 +616,7 @@ def test_check_archives_with_remote_path_calls_borg_with_remote_path_parameters(
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -643,7 +643,7 @@ def test_check_archives_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={'lock_wait': 5},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -670,7 +670,7 @@ def test_check_archives_with_retention_prefix():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={},
|
||||
consistency_config=consistency_config,
|
||||
|
@ -693,7 +693,7 @@ def test_check_archives_with_extra_borg_options_calls_borg_with_extra_options():
|
|||
flexmock(module).should_receive('write_check_time')
|
||||
|
||||
module.check_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={},
|
||||
storage_config={'extra_borg_options': {'check': '--extra --options'}},
|
||||
consistency_config=consistency_config,
|
||||
|
|
|
@ -25,7 +25,7 @@ def test_compact_segments_calls_borg_with_parameters():
|
|||
insert_execute_command_mock(COMPACT_COMMAND + ('repo',), logging.INFO)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False, repository='repo', storage_config={}, local_borg_version='1.2.3'
|
||||
dry_run=False, repository_path='repo', storage_config={}, local_borg_version='1.2.3'
|
||||
)
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ def test_compact_segments_with_log_info_calls_borg_with_info_parameter():
|
|||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.compact_segments(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', dry_run=False
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3', dry_run=False
|
||||
)
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ def test_compact_segments_with_log_debug_calls_borg_with_debug_parameter():
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.compact_segments(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', dry_run=False
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3', dry_run=False
|
||||
)
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ def test_compact_segments_with_dry_run_skips_borg_call():
|
|||
flexmock(module).should_receive('execute_command').never()
|
||||
|
||||
module.compact_segments(
|
||||
repository='repo', storage_config={}, local_borg_version='1.2.3', dry_run=True
|
||||
repository_path='repo', storage_config={}, local_borg_version='1.2.3', dry_run=True
|
||||
)
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ def test_compact_segments_with_local_path_calls_borg_via_local_path():
|
|||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
local_path='borg1',
|
||||
|
@ -76,7 +76,7 @@ def test_compact_segments_with_remote_path_calls_borg_with_remote_path_parameter
|
|||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
remote_path='borg1',
|
||||
|
@ -89,7 +89,7 @@ def test_compact_segments_with_progress_calls_borg_with_progress_parameter():
|
|||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
progress=True,
|
||||
|
@ -102,7 +102,7 @@ def test_compact_segments_with_cleanup_commits_calls_borg_with_cleanup_commits_p
|
|||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
cleanup_commits=True,
|
||||
|
@ -115,7 +115,7 @@ def test_compact_segments_with_threshold_calls_borg_with_threshold_parameter():
|
|||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
threshold=20,
|
||||
|
@ -128,7 +128,10 @@ def test_compact_segments_with_umask_calls_borg_with_umask_parameters():
|
|||
insert_execute_command_mock(COMPACT_COMMAND + ('--umask', '077', 'repo'), logging.INFO)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False, repository='repo', storage_config=storage_config, local_borg_version='1.2.3'
|
||||
dry_run=False,
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
local_borg_version='1.2.3',
|
||||
)
|
||||
|
||||
|
||||
|
@ -138,7 +141,10 @@ def test_compact_segments_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|||
insert_execute_command_mock(COMPACT_COMMAND + ('--lock-wait', '5', 'repo'), logging.INFO)
|
||||
|
||||
module.compact_segments(
|
||||
dry_run=False, repository='repo', storage_config=storage_config, local_borg_version='1.2.3'
|
||||
dry_run=False,
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
local_borg_version='1.2.3',
|
||||
)
|
||||
|
||||
|
||||
|
@ -148,7 +154,7 @@ def test_compact_segments_with_extra_borg_options_calls_borg_with_extra_options(
|
|||
|
||||
module.compact_segments(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={'extra_borg_options': {'compact': '--extra --options'}},
|
||||
local_borg_version='1.2.3',
|
||||
)
|
||||
|
|
|
@ -484,7 +484,7 @@ def test_create_archive_calls_borg_with_parameters():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -527,7 +527,7 @@ def test_create_archive_calls_borg_with_environment():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -572,7 +572,7 @@ def test_create_archive_with_patterns_calls_borg_with_patterns_including_convert
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -617,7 +617,7 @@ def test_create_archive_with_exclude_patterns_calls_borg_with_excludes():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -660,7 +660,7 @@ def test_create_archive_with_log_info_calls_borg_with_info_parameter():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -700,7 +700,7 @@ def test_create_archive_with_log_info_and_json_suppresses_most_borg_output():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -744,7 +744,7 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_parameter():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -784,7 +784,7 @@ def test_create_archive_with_log_debug_and_json_suppresses_most_borg_output():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -827,7 +827,7 @@ def test_create_archive_with_dry_run_calls_borg_with_dry_run_parameter():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=True,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -872,7 +872,7 @@ def test_create_archive_with_stats_and_dry_run_calls_borg_without_stats_paramete
|
|||
|
||||
module.create_archive(
|
||||
dry_run=True,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -915,7 +915,7 @@ def test_create_archive_with_checkpoint_interval_calls_borg_with_checkpoint_inte
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -957,7 +957,7 @@ def test_create_archive_with_checkpoint_volume_calls_borg_with_checkpoint_volume
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -999,7 +999,7 @@ def test_create_archive_with_chunker_params_calls_borg_with_chunker_params_param
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1041,7 +1041,7 @@ def test_create_archive_with_compression_calls_borg_with_compression_parameters(
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1088,7 +1088,7 @@ def test_create_archive_with_upload_rate_limit_calls_borg_with_upload_ratelimit_
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1132,7 +1132,7 @@ def test_create_archive_with_working_directory_calls_borg_with_working_directory
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1175,7 +1175,7 @@ def test_create_archive_with_one_file_system_calls_borg_with_one_file_system_par
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1223,7 +1223,7 @@ def test_create_archive_with_numeric_ids_calls_borg_with_numeric_ids_parameter(
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1276,7 +1276,7 @@ def test_create_archive_with_read_special_calls_borg_with_read_special_parameter
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1326,7 +1326,7 @@ def test_create_archive_with_basic_option_calls_borg_with_corresponding_paramete
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1380,7 +1380,7 @@ def test_create_archive_with_atime_option_calls_borg_with_corresponding_paramete
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1434,7 +1434,7 @@ def test_create_archive_with_flags_option_calls_borg_with_corresponding_paramete
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1477,7 +1477,7 @@ def test_create_archive_with_files_cache_calls_borg_with_files_cache_parameters(
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1520,7 +1520,7 @@ def test_create_archive_with_local_path_calls_borg_via_local_path():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1563,7 +1563,7 @@ def test_create_archive_with_remote_path_calls_borg_with_remote_path_parameters(
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1606,7 +1606,7 @@ def test_create_archive_with_umask_calls_borg_with_umask_parameters():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1648,7 +1648,7 @@ def test_create_archive_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1690,7 +1690,7 @@ def test_create_archive_with_stats_calls_borg_with_stats_parameter_and_answer_ou
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1733,7 +1733,7 @@ def test_create_archive_with_files_calls_borg_with_list_parameter_and_answer_out
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1777,7 +1777,7 @@ def test_create_archive_with_progress_and_log_info_calls_borg_with_progress_para
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1820,7 +1820,7 @@ def test_create_archive_with_progress_calls_borg_with_progress_parameter():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1880,7 +1880,7 @@ def test_create_archive_with_progress_and_stream_processes_calls_borg_with_progr
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -1943,7 +1943,7 @@ def test_create_archive_with_stream_processes_ignores_read_special_false_and_log
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2011,7 +2011,7 @@ def test_create_archive_with_stream_processes_adds_special_files_to_excludes():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2074,7 +2074,7 @@ def test_create_archive_with_stream_processes_and_read_special_does_not_add_spec
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2115,7 +2115,7 @@ def test_create_archive_with_json_calls_borg_with_json_parameter():
|
|||
|
||||
json_output = module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2157,7 +2157,7 @@ def test_create_archive_with_stats_and_json_calls_borg_without_stats_parameter()
|
|||
|
||||
json_output = module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2204,7 +2204,7 @@ def test_create_archive_with_source_directories_glob_expands():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo*'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2247,7 +2247,7 @@ def test_create_archive_with_non_matching_source_directories_glob_passes_through
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo*'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2289,7 +2289,7 @@ def test_create_archive_with_glob_calls_borg_with_expanded_directories():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo*'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2331,7 +2331,7 @@ def test_create_archive_with_archive_name_format_calls_borg_with_archive_name():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2374,7 +2374,7 @@ def test_create_archive_with_archive_name_format_accepts_borg_placeholders():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2417,7 +2417,7 @@ def test_create_archive_with_repository_accepts_borg_placeholders():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='{fqdn}', # noqa: FS003
|
||||
repository_path='{fqdn}', # noqa: FS003
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['{fqdn}'], # noqa: FS003
|
||||
|
@ -2459,7 +2459,7 @@ def test_create_archive_with_extra_borg_options_calls_borg_with_extra_options():
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2519,7 +2519,7 @@ def test_create_archive_with_stream_processes_calls_borg_with_processes_and_read
|
|||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
@ -2543,7 +2543,7 @@ def test_create_archive_with_non_existent_directory_and_source_directories_must_
|
|||
with pytest.raises(ValueError):
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
|
|
|
@ -32,7 +32,7 @@ def test_export_tar_archive_calls_borg_with_path_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=['path1', 'path2'],
|
||||
destination_path='test.tar',
|
||||
|
@ -53,7 +53,7 @@ def test_export_tar_archive_calls_borg_with_local_path_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -75,7 +75,7 @@ def test_export_tar_archive_calls_borg_with_remote_path_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -97,7 +97,7 @@ def test_export_tar_archive_calls_borg_with_umask_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -118,7 +118,7 @@ def test_export_tar_archive_calls_borg_with_lock_wait_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -138,7 +138,7 @@ def test_export_tar_archive_with_log_info_calls_borg_with_info_parameter():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -160,7 +160,7 @@ def test_export_tar_archive_with_log_debug_calls_borg_with_debug_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -179,7 +179,7 @@ def test_export_tar_archive_calls_borg_with_dry_run_parameter():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=True,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -200,7 +200,7 @@ def test_export_tar_archive_calls_borg_with_tar_filter_parameters():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -223,7 +223,7 @@ def test_export_tar_archive_calls_borg_with_list_parameter():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -245,7 +245,7 @@ def test_export_tar_archive_calls_borg_with_strip_components_parameter():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -265,7 +265,7 @@ def test_export_tar_archive_skips_abspath_for_remote_repository_parameter():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='server:repo',
|
||||
repository_path='server:repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='test.tar',
|
||||
|
@ -284,7 +284,7 @@ def test_export_tar_archive_calls_borg_with_stdout_destination_path():
|
|||
|
||||
module.export_tar_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
paths=None,
|
||||
destination_path='-',
|
||||
|
|
|
@ -23,7 +23,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_last_archive():
|
|||
)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
storage_config={}, local_borg_version='1.2.3', repository='repo', lock_wait=None
|
||||
storage_config={}, local_borg_version='1.2.3', repository_path='repo', lock_wait=None
|
||||
)
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ def test_extract_last_archive_dry_run_without_any_archives_should_not_raise():
|
|||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(('repo',))
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
storage_config={}, local_borg_version='1.2.3', repository='repo', lock_wait=None
|
||||
storage_config={}, local_borg_version='1.2.3', repository_path='repo', lock_wait=None
|
||||
)
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ def test_extract_last_archive_dry_run_with_log_info_calls_borg_with_info_paramet
|
|||
)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
storage_config={}, local_borg_version='1.2.3', repository='repo', lock_wait=None
|
||||
storage_config={}, local_borg_version='1.2.3', repository_path='repo', lock_wait=None
|
||||
)
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ def test_extract_last_archive_dry_run_with_log_debug_calls_borg_with_debug_param
|
|||
)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
storage_config={}, local_borg_version='1.2.3', repository='repo', lock_wait=None
|
||||
storage_config={}, local_borg_version='1.2.3', repository_path='repo', lock_wait=None
|
||||
)
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ def test_extract_last_archive_dry_run_calls_borg_via_local_path():
|
|||
module.extract_last_archive_dry_run(
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
lock_wait=None,
|
||||
local_path='borg1',
|
||||
)
|
||||
|
@ -92,7 +92,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_remote_path_parameters():
|
|||
module.extract_last_archive_dry_run(
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
lock_wait=None,
|
||||
remote_path='borg1',
|
||||
)
|
||||
|
@ -108,7 +108,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_lock_wait_parameters():
|
|||
)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
storage_config={}, local_borg_version='1.2.3', repository='repo', lock_wait=5
|
||||
storage_config={}, local_borg_version='1.2.3', repository_path='repo', lock_wait=5
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ def test_make_flags_from_arguments_omits_excludes():
|
|||
def test_make_repository_flags_with_borg_features_includes_repo_flag():
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
|
||||
assert module.make_repository_flags(repository='repo', local_borg_version='1.2.3') == (
|
||||
assert module.make_repository_flags(repository_path='repo', local_borg_version='1.2.3') == (
|
||||
'--repo',
|
||||
'repo',
|
||||
)
|
||||
|
@ -59,14 +59,16 @@ def test_make_repository_flags_with_borg_features_includes_repo_flag():
|
|||
def test_make_repository_flags_without_borg_features_includes_omits_flag():
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
|
||||
assert module.make_repository_flags(repository='repo', local_borg_version='1.2.3') == ('repo',)
|
||||
assert module.make_repository_flags(repository_path='repo', local_borg_version='1.2.3') == (
|
||||
'repo',
|
||||
)
|
||||
|
||||
|
||||
def test_make_repository_archive_flags_with_borg_features_separates_repository_and_archive():
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
|
||||
assert module.make_repository_archive_flags(
|
||||
repository='repo', archive='archive', local_borg_version='1.2.3'
|
||||
repository_path='repo', archive='archive', local_borg_version='1.2.3'
|
||||
) == ('--repo', 'repo', 'archive',)
|
||||
|
||||
|
||||
|
@ -74,5 +76,5 @@ def test_make_repository_archive_flags_with_borg_features_joins_repository_and_a
|
|||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
|
||||
assert module.make_repository_archive_flags(
|
||||
repository='repo', archive='archive', local_borg_version='1.2.3'
|
||||
repository_path='repo', archive='archive', local_borg_version='1.2.3'
|
||||
) == ('repo::archive',)
|
||||
|
|
|
@ -23,7 +23,7 @@ def test_display_archives_info_calls_borg_with_parameters():
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None),
|
||||
|
@ -45,7 +45,7 @@ def test_display_archives_info_with_log_info_calls_borg_with_info_parameter():
|
|||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None),
|
||||
|
@ -65,7 +65,7 @@ def test_display_archives_info_with_log_info_and_json_suppresses_most_borg_outpu
|
|||
|
||||
insert_logging_mock(logging.INFO)
|
||||
json_output = module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=True, prefix=None),
|
||||
|
@ -90,7 +90,7 @@ def test_display_archives_info_with_log_debug_calls_borg_with_debug_parameter():
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None),
|
||||
|
@ -110,7 +110,7 @@ def test_display_archives_info_with_log_debug_and_json_suppresses_most_borg_outp
|
|||
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
json_output = module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=True, prefix=None),
|
||||
|
@ -131,7 +131,7 @@ def test_display_archives_info_with_json_calls_borg_with_json_parameter():
|
|||
).and_return('[]')
|
||||
|
||||
json_output = module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=True, prefix=None),
|
||||
|
@ -158,7 +158,7 @@ def test_display_archives_info_with_archive_calls_borg_with_match_archives_param
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive='archive', json=False, prefix=None),
|
||||
|
@ -180,7 +180,7 @@ def test_display_archives_info_with_local_path_calls_borg_via_local_path():
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None),
|
||||
|
@ -206,7 +206,7 @@ def test_display_archives_info_with_remote_path_calls_borg_with_remote_path_para
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None),
|
||||
|
@ -233,7 +233,7 @@ def test_display_archives_info_with_lock_wait_calls_borg_with_lock_wait_paramete
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None),
|
||||
|
@ -258,7 +258,7 @@ def test_display_archives_info_with_prefix_calls_borg_with_match_archives_parame
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix='foo'),
|
||||
|
@ -284,7 +284,7 @@ def test_display_archives_info_passes_through_arguments_to_borg(argument_name):
|
|||
)
|
||||
|
||||
module.display_archives_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
info_arguments=flexmock(archive=None, json=False, prefix=None, **{argument_name: 'value'}),
|
||||
|
|
|
@ -16,7 +16,7 @@ def test_make_list_command_includes_log_info():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
|
@ -32,7 +32,7 @@ def test_make_list_command_includes_json_but_not_info():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=True),
|
||||
|
@ -48,7 +48,7 @@ def test_make_list_command_includes_log_debug():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
|
@ -64,7 +64,7 @@ def test_make_list_command_includes_json_but_not_debug():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=True),
|
||||
|
@ -79,7 +79,7 @@ def test_make_list_command_includes_json():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=True),
|
||||
|
@ -96,7 +96,7 @@ def test_make_list_command_includes_lock_wait():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={'lock_wait': 5},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
|
@ -113,7 +113,7 @@ def test_make_list_command_includes_archive():
|
|||
)
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive='archive', paths=None, json=False),
|
||||
|
@ -130,7 +130,7 @@ def test_make_list_command_includes_archive_and_path():
|
|||
)
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive='archive', paths=['var/lib'], json=False),
|
||||
|
@ -145,7 +145,7 @@ def test_make_list_command_includes_local_path():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
|
@ -163,7 +163,7 @@ def test_make_list_command_includes_remote_path():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=False),
|
||||
|
@ -179,7 +179,7 @@ def test_make_list_command_includes_short():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(archive=None, paths=None, json=False, short=True),
|
||||
|
@ -210,7 +210,7 @@ def test_make_list_command_includes_additional_flags(argument_name):
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_list_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=flexmock(
|
||||
|
@ -259,7 +259,7 @@ def test_capture_archive_listing_does_not_raise():
|
|||
flexmock(module).should_receive('make_list_command')
|
||||
|
||||
module.capture_archive_listing(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
storage_config=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
|
@ -284,7 +284,7 @@ def test_list_archive_calls_borg_with_parameters():
|
|||
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module).should_receive('make_list_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -301,7 +301,7 @@ def test_list_archive_calls_borg_with_parameters():
|
|||
).once()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -318,7 +318,7 @@ def test_list_archive_with_archive_and_json_errors():
|
|||
|
||||
with pytest.raises(ValueError):
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -343,7 +343,7 @@ def test_list_archive_calls_borg_with_local_path():
|
|||
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module).should_receive('make_list_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -360,7 +360,7 @@ def test_list_archive_calls_borg_with_local_path():
|
|||
).once()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -408,7 +408,7 @@ def test_list_archive_calls_borg_multiple_times_with_find_paths():
|
|||
).once()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -433,7 +433,7 @@ def test_list_archive_calls_borg_with_archive():
|
|||
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module).should_receive('make_list_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -450,7 +450,7 @@ def test_list_archive_calls_borg_with_archive():
|
|||
).once()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -480,7 +480,7 @@ def test_list_archive_without_archive_delegates_to_list_repository():
|
|||
flexmock(module).should_receive('execute_command').never()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -510,7 +510,7 @@ def test_list_archive_with_borg_features_without_archive_delegates_to_list_repos
|
|||
flexmock(module).should_receive('execute_command').never()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=list_arguments,
|
||||
|
@ -537,7 +537,7 @@ def test_list_archive_with_archive_ignores_archive_filter_flag(archive_filter_fl
|
|||
module.feature.Feature.RLIST, '1.2.3'
|
||||
).and_return(False)
|
||||
flexmock(module).should_receive('make_list_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=argparse.Namespace(
|
||||
|
@ -556,7 +556,7 @@ def test_list_archive_with_archive_ignores_archive_filter_flag(archive_filter_fl
|
|||
).once()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=argparse.Namespace(
|
||||
|
@ -586,7 +586,7 @@ def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes
|
|||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
|
||||
flexmock(module.rlist).should_receive('make_rlist_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=argparse.Namespace(
|
||||
|
@ -601,7 +601,7 @@ def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes
|
|||
).and_return('archive1\narchive2').once()
|
||||
|
||||
flexmock(module).should_receive('make_list_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=argparse.Namespace(
|
||||
|
@ -619,7 +619,7 @@ def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes
|
|||
).and_return(('borg', 'list', '--repo', 'repo', 'archive1'))
|
||||
|
||||
flexmock(module).should_receive('make_list_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=argparse.Namespace(
|
||||
|
@ -652,7 +652,7 @@ def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes
|
|||
).once()
|
||||
|
||||
module.list_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
list_arguments=argparse.Namespace(
|
||||
|
|
|
@ -20,7 +20,7 @@ def test_mount_archive_calls_borg_with_required_flags():
|
|||
insert_execute_command_mock(('borg', 'mount', 'repo', '/mnt'))
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive=None,
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -39,7 +39,7 @@ def test_mount_archive_with_borg_features_calls_borg_with_repository_and_match_a
|
|||
)
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -58,7 +58,7 @@ def test_mount_archive_without_archive_calls_borg_with_repository_flags_only():
|
|||
insert_execute_command_mock(('borg', 'mount', 'repo::archive', '/mnt'))
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -77,7 +77,7 @@ def test_mount_archive_calls_borg_with_path_flags():
|
|||
insert_execute_command_mock(('borg', 'mount', 'repo::archive', '/mnt', 'path1', 'path2'))
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=['path1', 'path2'],
|
||||
|
@ -98,7 +98,7 @@ def test_mount_archive_calls_borg_with_remote_path_flags():
|
|||
)
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -118,7 +118,7 @@ def test_mount_archive_calls_borg_with_umask_flags():
|
|||
insert_execute_command_mock(('borg', 'mount', '--umask', '0770', 'repo::archive', '/mnt'))
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -137,7 +137,7 @@ def test_mount_archive_calls_borg_with_lock_wait_flags():
|
|||
insert_execute_command_mock(('borg', 'mount', '--lock-wait', '5', 'repo::archive', '/mnt'))
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -157,7 +157,7 @@ def test_mount_archive_with_log_info_calls_borg_with_info_parameter():
|
|||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -177,7 +177,7 @@ def test_mount_archive_with_log_debug_calls_borg_with_debug_flags():
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -202,7 +202,7 @@ def test_mount_archive_calls_borg_with_foreground_parameter():
|
|||
).once()
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
@ -221,7 +221,7 @@ def test_mount_archive_calls_borg_with_options_flags():
|
|||
insert_execute_command_mock(('borg', 'mount', '-o', 'super_mount', 'repo::archive', '/mnt'))
|
||||
|
||||
module.mount_archive(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
archive='archive',
|
||||
mount_point='/mnt',
|
||||
paths=None,
|
||||
|
|
|
@ -98,7 +98,7 @@ def test_prune_archives_calls_borg_with_parameters():
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -114,7 +114,7 @@ def test_prune_archives_with_log_info_calls_borg_with_info_parameter():
|
|||
insert_logging_mock(logging.INFO)
|
||||
|
||||
module.prune_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
dry_run=False,
|
||||
retention_config=flexmock(),
|
||||
|
@ -131,7 +131,7 @@ def test_prune_archives_with_log_debug_calls_borg_with_debug_parameter():
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.prune_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
dry_run=False,
|
||||
retention_config=flexmock(),
|
||||
|
@ -147,7 +147,7 @@ def test_prune_archives_with_dry_run_calls_borg_with_dry_run_parameter():
|
|||
insert_execute_command_mock(PRUNE_COMMAND + ('--dry-run', 'repo'), logging.INFO)
|
||||
|
||||
module.prune_archives(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
dry_run=True,
|
||||
retention_config=flexmock(),
|
||||
|
@ -164,7 +164,7 @@ def test_prune_archives_with_local_path_calls_borg_via_local_path():
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -181,7 +181,7 @@ def test_prune_archives_with_remote_path_calls_borg_with_remote_path_parameters(
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -198,7 +198,7 @@ def test_prune_archives_with_stats_calls_borg_with_stats_parameter_and_answer_ou
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -215,7 +215,7 @@ def test_prune_archives_with_files_calls_borg_with_list_parameter_and_answer_out
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -233,7 +233,7 @@ def test_prune_archives_with_umask_calls_borg_with_umask_parameters():
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -250,7 +250,7 @@ def test_prune_archives_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
@ -266,7 +266,7 @@ def test_prune_archives_with_extra_borg_options_calls_borg_with_extra_options():
|
|||
|
||||
module.prune_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={'extra_borg_options': {'prune': '--extra --options'}},
|
||||
retention_config=flexmock(),
|
||||
local_borg_version='1.2.3',
|
||||
|
|
|
@ -40,7 +40,7 @@ def test_create_repository_calls_borg_with_flags():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -55,7 +55,7 @@ def test_create_repository_with_dry_run_skips_borg_call():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=True,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -74,7 +74,7 @@ def test_create_repository_raises_for_borg_rcreate_error():
|
|||
with pytest.raises(subprocess.CalledProcessError):
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -88,7 +88,7 @@ def test_create_repository_skips_creation_when_repository_already_exists():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -103,7 +103,7 @@ def test_create_repository_raises_for_unknown_rinfo_command_error():
|
|||
with pytest.raises(subprocess.CalledProcessError):
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -118,7 +118,7 @@ def test_create_repository_with_source_repository_calls_borg_with_other_repo_fla
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -134,7 +134,7 @@ def test_create_repository_with_copy_crypt_key_calls_borg_with_copy_crypt_key_fl
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -150,7 +150,7 @@ def test_create_repository_with_append_only_calls_borg_with_append_only_flag():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -166,7 +166,7 @@ def test_create_repository_with_storage_quota_calls_borg_with_storage_quota_flag
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -182,7 +182,7 @@ def test_create_repository_with_make_parent_dirs_calls_borg_with_make_parent_dir
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -199,7 +199,7 @@ def test_create_repository_with_log_info_calls_borg_with_info_flag():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -215,7 +215,7 @@ def test_create_repository_with_log_debug_calls_borg_with_debug_flag():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -230,7 +230,7 @@ def test_create_repository_with_local_path_calls_borg_via_local_path():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -246,7 +246,7 @@ def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
@ -262,7 +262,7 @@ def test_create_repository_with_extra_borg_options_calls_borg_with_extra_options
|
|||
|
||||
module.create_repository(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={'extra_borg_options': {'rcreate': '--extra --options'}},
|
||||
local_borg_version='2.3.4',
|
||||
encryption_mode='repokey',
|
||||
|
|
|
@ -21,7 +21,7 @@ def test_display_repository_info_calls_borg_with_parameters():
|
|||
)
|
||||
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
@ -42,7 +42,7 @@ def test_display_repository_info_without_borg_features_calls_borg_with_info_sub_
|
|||
)
|
||||
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
@ -63,7 +63,7 @@ def test_display_repository_info_with_log_info_calls_borg_with_info_parameter():
|
|||
)
|
||||
insert_logging_mock(logging.INFO)
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
@ -82,7 +82,7 @@ def test_display_repository_info_with_log_info_and_json_suppresses_most_borg_out
|
|||
|
||||
insert_logging_mock(logging.INFO)
|
||||
json_output = module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=True),
|
||||
|
@ -106,7 +106,7 @@ def test_display_repository_info_with_log_debug_calls_borg_with_debug_parameter(
|
|||
insert_logging_mock(logging.DEBUG)
|
||||
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
@ -125,7 +125,7 @@ def test_display_repository_info_with_log_debug_and_json_suppresses_most_borg_ou
|
|||
|
||||
insert_logging_mock(logging.DEBUG)
|
||||
json_output = module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=True),
|
||||
|
@ -145,7 +145,7 @@ def test_display_repository_info_with_json_calls_borg_with_json_parameter():
|
|||
).and_return('[]')
|
||||
|
||||
json_output = module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=True),
|
||||
|
@ -168,7 +168,7 @@ def test_display_repository_info_with_local_path_calls_borg_via_local_path():
|
|||
)
|
||||
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
@ -190,7 +190,7 @@ def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_pa
|
|||
)
|
||||
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
@ -213,7 +213,7 @@ def test_display_repository_info_with_lock_wait_calls_borg_with_lock_wait_parame
|
|||
)
|
||||
|
||||
module.display_repository_info(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
local_borg_version='2.3.4',
|
||||
rinfo_arguments=flexmock(json=False),
|
||||
|
|
|
@ -131,7 +131,7 @@ def test_make_rlist_command_includes_log_info():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
|
@ -147,7 +147,7 @@ def test_make_rlist_command_includes_json_but_not_info():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True, prefix=None),
|
||||
|
@ -163,7 +163,7 @@ def test_make_rlist_command_includes_log_debug():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
|
@ -179,7 +179,7 @@ def test_make_rlist_command_includes_json_but_not_debug():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True, prefix=None),
|
||||
|
@ -194,7 +194,7 @@ def test_make_rlist_command_includes_json():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=True, prefix=None),
|
||||
|
@ -211,7 +211,7 @@ def test_make_rlist_command_includes_lock_wait():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={'lock_wait': 5},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
|
@ -226,7 +226,7 @@ def test_make_rlist_command_includes_local_path():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
|
@ -244,7 +244,7 @@ def test_make_rlist_command_includes_remote_path():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None),
|
||||
|
@ -262,7 +262,7 @@ def test_make_rlist_command_transforms_prefix_into_match_archives():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
|
||||
|
@ -277,7 +277,7 @@ def test_make_rlist_command_includes_short():
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix=None, short=True),
|
||||
|
@ -307,7 +307,7 @@ def test_make_rlist_command_includes_additional_flags(argument_name):
|
|||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
command = module.make_rlist_command(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=flexmock(
|
||||
|
@ -331,7 +331,7 @@ def test_list_repository_calls_borg_with_parameters():
|
|||
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module).should_receive('make_rlist_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=rlist_arguments,
|
||||
|
@ -347,7 +347,7 @@ def test_list_repository_calls_borg_with_parameters():
|
|||
).once()
|
||||
|
||||
module.list_repository(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=rlist_arguments,
|
||||
|
@ -362,7 +362,7 @@ def test_list_repository_with_json_returns_borg_output():
|
|||
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module).should_receive('make_rlist_command').with_args(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=rlist_arguments,
|
||||
|
@ -374,7 +374,7 @@ def test_list_repository_with_json_returns_borg_output():
|
|||
|
||||
assert (
|
||||
module.list_repository(
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='1.2.3',
|
||||
rlist_arguments=rlist_arguments,
|
||||
|
|
|
@ -25,7 +25,7 @@ def test_transfer_archives_calls_borg_with_flags():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -54,7 +54,7 @@ def test_transfer_archives_with_dry_run_calls_borg_with_dry_run_flag():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=True,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -80,7 +80,7 @@ def test_transfer_archives_with_log_info_calls_borg_with_info_flag():
|
|||
insert_logging_mock(logging.INFO)
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -107,7 +107,7 @@ def test_transfer_archives_with_log_debug_calls_borg_with_debug_flag():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -136,7 +136,7 @@ def test_transfer_archives_with_archive_calls_borg_with_match_archives_flag():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -165,7 +165,7 @@ def test_transfer_archives_with_match_archives_calls_borg_with_match_archives_fl
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -191,7 +191,7 @@ def test_transfer_archives_with_local_path_calls_borg_via_local_path():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -221,7 +221,7 @@ def test_transfer_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -252,7 +252,7 @@ def test_transfer_archives_with_lock_wait_calls_borg_with_lock_wait_flags():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config=storage_config,
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -278,7 +278,7 @@ def test_transfer_archives_with_progress_calls_borg_with_progress_flag():
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -308,7 +308,7 @@ def test_transfer_archives_passes_through_arguments_to_borg(argument_name):
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
@ -340,7 +340,7 @@ def test_transfer_archives_with_source_repository_calls_borg_with_other_repo_fla
|
|||
|
||||
module.transfer_archives(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
repository_path='repo',
|
||||
storage_config={},
|
||||
local_borg_version='2.3.4',
|
||||
transfer_arguments=flexmock(
|
||||
|
|
|
@ -15,7 +15,7 @@ def test_run_configuration_runs_actions_for_each_repository():
|
|||
flexmock(module).should_receive('run_actions').and_return(expected_results[:1]).and_return(
|
||||
expected_results[1:]
|
||||
)
|
||||
config = {'location': {'repositories': ['foo', 'bar']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1)}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -75,7 +75,7 @@ def test_run_configuration_logs_actions_error():
|
|||
expected_results = [flexmock()]
|
||||
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
||||
flexmock(module).should_receive('run_actions').and_raise(OSError)
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -91,7 +91,7 @@ def test_run_configuration_bails_for_actions_soft_failure():
|
|||
flexmock(module).should_receive('run_actions').and_raise(error)
|
||||
flexmock(module).should_receive('log_error_records').never()
|
||||
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -108,7 +108,7 @@ def test_run_configuration_logs_monitor_log_error():
|
|||
expected_results = [flexmock()]
|
||||
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
||||
flexmock(module).should_receive('run_actions').and_return([])
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -126,7 +126,7 @@ def test_run_configuration_bails_for_monitor_log_soft_failure():
|
|||
flexmock(module).should_receive('log_error_records').never()
|
||||
flexmock(module).should_receive('run_actions').and_return([])
|
||||
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -143,7 +143,7 @@ def test_run_configuration_logs_monitor_finish_error():
|
|||
expected_results = [flexmock()]
|
||||
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
||||
flexmock(module).should_receive('run_actions').and_return([])
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -161,7 +161,7 @@ def test_run_configuration_bails_for_monitor_finish_soft_failure():
|
|||
flexmock(module).should_receive('log_error_records').never()
|
||||
flexmock(module).should_receive('run_actions').and_return([])
|
||||
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -178,7 +178,7 @@ def test_run_configuration_logs_on_error_hook_error():
|
|||
expected_results[:1]
|
||||
).and_return(expected_results[1:])
|
||||
flexmock(module).should_receive('run_actions').and_raise(OSError)
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -194,7 +194,7 @@ def test_run_configuration_bails_for_on_error_hook_soft_failure():
|
|||
expected_results = [flexmock()]
|
||||
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
||||
flexmock(module).should_receive('run_actions').and_raise(OSError)
|
||||
config = {'location': {'repositories': ['foo']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
|
@ -209,7 +209,7 @@ def test_run_configuration_retries_soft_error():
|
|||
flexmock(module.command).should_receive('execute_hook')
|
||||
flexmock(module).should_receive('run_actions').and_raise(OSError).and_return([])
|
||||
flexmock(module).should_receive('log_error_records').and_return([flexmock()]).once()
|
||||
config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 1}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
assert results == []
|
||||
|
@ -231,7 +231,7 @@ def test_run_configuration_retries_hard_error():
|
|||
flexmock(module).should_receive('log_error_records').with_args(
|
||||
'foo: Error running actions for repository', OSError,
|
||||
).and_return(error_logs)
|
||||
config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 1}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
assert results == error_logs
|
||||
|
@ -249,13 +249,13 @@ def test_run_configuration_repos_ordered():
|
|||
flexmock(module).should_receive('log_error_records').with_args(
|
||||
'bar: Error running actions for repository', OSError
|
||||
).and_return(expected_results[1:]).ordered()
|
||||
config = {'location': {'repositories': ['foo', 'bar']}}
|
||||
config = {'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
assert results == expected_results
|
||||
|
||||
|
||||
def test_run_configuration_retries_round_robbin():
|
||||
def test_run_configuration_retries_round_robin():
|
||||
flexmock(module).should_receive('verbosity_to_log_level').and_return(logging.INFO)
|
||||
flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock())
|
||||
flexmock(module.command).should_receive('execute_hook')
|
||||
|
@ -280,7 +280,10 @@ def test_run_configuration_retries_round_robbin():
|
|||
flexmock(module).should_receive('log_error_records').with_args(
|
||||
'bar: Error running actions for repository', OSError
|
||||
).and_return(bar_error_logs).ordered()
|
||||
config = {'location': {'repositories': ['foo', 'bar']}, 'storage': {'retries': 1}}
|
||||
config = {
|
||||
'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
|
||||
'storage': {'retries': 1},
|
||||
}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
assert results == foo_error_logs + bar_error_logs
|
||||
|
@ -309,7 +312,10 @@ def test_run_configuration_retries_one_passes():
|
|||
flexmock(module).should_receive('log_error_records').with_args(
|
||||
'bar: Error running actions for repository', OSError
|
||||
).and_return(error_logs).ordered()
|
||||
config = {'location': {'repositories': ['foo', 'bar']}, 'storage': {'retries': 1}}
|
||||
config = {
|
||||
'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
|
||||
'storage': {'retries': 1},
|
||||
}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
assert results == error_logs
|
||||
|
@ -348,7 +354,10 @@ def test_run_configuration_retry_wait():
|
|||
flexmock(module).should_receive('log_error_records').with_args(
|
||||
'foo: Error running actions for repository', OSError
|
||||
).and_return(error_logs).ordered()
|
||||
config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 3, 'retry_wait': 10}}
|
||||
config = {
|
||||
'location': {'repositories': [{'path': 'foo'}]},
|
||||
'storage': {'retries': 3, 'retry_wait': 10},
|
||||
}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
results = list(module.run_configuration('test.yaml', config, arguments))
|
||||
assert results == error_logs
|
||||
|
@ -384,7 +393,7 @@ def test_run_configuration_retries_timeout_multiple_repos():
|
|||
'bar: Error running actions for repository', OSError
|
||||
).and_return(error_logs).ordered()
|
||||
config = {
|
||||
'location': {'repositories': ['foo', 'bar']},
|
||||
'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
|
||||
'storage': {'retries': 1, 'retry_wait': 10},
|
||||
}
|
||||
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
||||
|
@ -409,7 +418,7 @@ def test_run_actions_runs_rcreate():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -431,7 +440,7 @@ def test_run_actions_runs_transfer():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -454,7 +463,7 @@ def test_run_actions_runs_create():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
assert result == (expected,)
|
||||
|
@ -477,7 +486,7 @@ def test_run_actions_runs_prune():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -499,7 +508,7 @@ def test_run_actions_runs_compact():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -522,7 +531,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -545,7 +554,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -567,7 +576,7 @@ def test_run_actions_runs_extract():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -589,7 +598,7 @@ def test_run_actions_runs_export_tar():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -611,7 +620,7 @@ def test_run_actions_runs_mount():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -633,7 +642,7 @@ def test_run_actions_runs_restore():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -656,7 +665,7 @@ def test_run_actions_runs_rlist():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
assert result == (expected,)
|
||||
|
@ -680,7 +689,7 @@ def test_run_actions_runs_list():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
assert result == (expected,)
|
||||
|
@ -704,7 +713,7 @@ def test_run_actions_runs_rinfo():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
assert result == (expected,)
|
||||
|
@ -728,7 +737,7 @@ def test_run_actions_runs_info():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
assert result == (expected,)
|
||||
|
@ -751,7 +760,7 @@ def test_run_actions_runs_break_lock():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -773,7 +782,7 @@ def test_run_actions_runs_borg():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -800,7 +809,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
|
|||
local_path=flexmock(),
|
||||
remote_path=flexmock(),
|
||||
local_borg_version=flexmock(),
|
||||
repository_path='repo',
|
||||
repository={'path': 'repo'},
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -69,27 +69,42 @@ from borgmatic.config import normalize as module
|
|||
),
|
||||
(
|
||||
{'location': {'repositories': ['foo@bar:/repo']}},
|
||||
{'location': {'repositories': ['ssh://foo@bar/repo']}},
|
||||
{'location': {'repositories': [{'path': 'ssh://foo@bar/repo'}]}},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': ['foo@bar:repo']}},
|
||||
{'location': {'repositories': ['ssh://foo@bar/./repo']}},
|
||||
{'location': {'repositories': [{'path': 'ssh://foo@bar/./repo'}]}},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': ['foo@bar:~/repo']}},
|
||||
{'location': {'repositories': ['ssh://foo@bar/~/repo']}},
|
||||
{'location': {'repositories': [{'path': 'ssh://foo@bar/~/repo'}]}},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': ['ssh://foo@bar:1234/repo']}},
|
||||
{'location': {'repositories': ['ssh://foo@bar:1234/repo']}},
|
||||
{'location': {'repositories': [{'path': 'ssh://foo@bar:1234/repo'}]}},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': ['file:///repo']}},
|
||||
{'location': {'repositories': ['/repo']}},
|
||||
{'location': {'repositories': [{'path': '/repo'}]}},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}]}},
|
||||
{'location': {'repositories': [{'path': 'ssh://foo@bar/repo', 'label': 'foo'}]}},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': [{'path': 'file:///repo', 'label': 'foo'}]}},
|
||||
{'location': {'repositories': [{'path': '/repo', 'label': 'foo'}]}},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': [{'path': '/repo', 'label': 'foo'}]}},
|
||||
{'location': {'repositories': [{'path': '/repo', 'label': 'foo'}]}},
|
||||
False,
|
||||
),
|
||||
),
|
||||
|
@ -105,3 +120,15 @@ def test_normalize_applies_hard_coded_normalization_to_config(
|
|||
assert logs
|
||||
else:
|
||||
assert logs == []
|
||||
|
||||
|
||||
def test_normalize_raises_error_if_repository_data_is_not_consistent():
|
||||
with pytest.raises(TypeError):
|
||||
module.normalize(
|
||||
'test.yaml',
|
||||
{
|
||||
'location': {
|
||||
'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}, 'file:///repo']
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -121,6 +121,16 @@ def test_guard_configuration_contains_repository_does_not_raise_when_repository_
|
|||
)
|
||||
|
||||
|
||||
def test_guard_configuration_contains_repository_does_not_raise_when_repository_label_in_config():
|
||||
|
||||
module.guard_configuration_contains_repository(
|
||||
repository='repo',
|
||||
configurations={
|
||||
'config.yaml': {'location': {'repositories': [{'path': 'foo/bar', 'label': 'repo'}]}}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_guard_configuration_contains_repository_does_not_raise_when_repository_not_given():
|
||||
module.guard_configuration_contains_repository(
|
||||
repository=None, configurations={'config.yaml': {'location': {'repositories': ['repo']}}}
|
||||
|
|
Loading…
Reference in a new issue