0
0
Fork 0
mirror of https://projects.torsion.org/witten/borgmatic.git synced 2025-04-07 22:25:38 +00:00

Rename repository actions for compatibility with recent Borg 2 changes ().

This commit is contained in:
Dan Helfman 2024-09-09 10:05:32 -07:00
parent 1fe6ae83a8
commit fd4f69f6c3
62 changed files with 666 additions and 579 deletions

2
NEWS
View file

@ -1,5 +1,7 @@
1.8.15.dev0
* #911: Add a "key change-passphrase" action to change the passphrase protecting a repository key.
* #915: Rename repository actions like "rcreate" to more explicit names like "repo-create" for
compatibility with recent Borg 2 changes.
1.8.14
* #896: Fix an error in borgmatic rcreate/init on an empty repository directory with Borg 1.4.

View file

@ -1,7 +1,7 @@
import logging
import borgmatic.borg.borg
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
logger = logging.getLogger(__name__)
@ -25,7 +25,7 @@ def run_borg(
logger.info(
f'{repository.get("label", repository["path"])}: Running arbitrary Borg command'
)
archive_name = borgmatic.borg.rlist.resolve_archive_name(
archive_name = borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
borg_arguments.archive,
config,

View file

@ -12,7 +12,7 @@ import borgmatic.borg.create
import borgmatic.borg.environment
import borgmatic.borg.extract
import borgmatic.borg.list
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.borg.state
import borgmatic.config.validate
import borgmatic.execute
@ -559,7 +559,7 @@ def spot_check(
)
logger.debug(f'{log_label}: {len(source_paths)} total source paths for spot check')
archive = borgmatic.borg.rlist.resolve_archive_name(
archive = borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
'latest',
config,

View file

@ -3,7 +3,7 @@ import logging
import os
import borgmatic.borg.extract
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
import borgmatic.hooks.command
from borgmatic.borg.state import DEFAULT_BORGMATIC_SOURCE_DIRECTORY
@ -33,7 +33,7 @@ def get_config_paths(bootstrap_arguments, global_arguments, local_borg_version):
extract_process = borgmatic.borg.extract.extract_archive(
global_arguments.dry_run,
bootstrap_arguments.repository,
borgmatic.borg.rlist.resolve_archive_name(
borgmatic.borg.repo_list.resolve_archive_name(
bootstrap_arguments.repository,
bootstrap_arguments.archive,
config,
@ -85,7 +85,7 @@ def run_bootstrap(bootstrap_arguments, global_arguments, local_borg_version):
borgmatic.borg.extract.extract_archive(
global_arguments.dry_run,
bootstrap_arguments.repository,
borgmatic.borg.rlist.resolve_archive_name(
borgmatic.borg.repo_list.resolve_archive_name(
bootstrap_arguments.repository,
bootstrap_arguments.archive,
config,

View file

@ -2,8 +2,8 @@ import logging
import borgmatic.actions.arguments
import borgmatic.borg.delete
import borgmatic.borg.rdelete
import borgmatic.borg.rlist
import borgmatic.borg.repo_delete
import borgmatic.borg.repo_list
logger = logging.getLogger(__name__)
@ -26,7 +26,7 @@ def run_delete(
logger.answer(f'{repository.get("label", repository["path"])}: Deleting archives')
archive_name = (
borgmatic.borg.rlist.resolve_archive_name(
borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
delete_arguments.archive,
config,

View file

@ -1,7 +1,7 @@
import logging
import borgmatic.borg.export_tar
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
logger = logging.getLogger(__name__)
@ -28,7 +28,7 @@ def run_export_tar(
borgmatic.borg.export_tar.export_tar_archive(
global_arguments.dry_run,
repository['path'],
borgmatic.borg.rlist.resolve_archive_name(
borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
export_tar_arguments.archive,
config,

View file

@ -1,7 +1,7 @@
import logging
import borgmatic.borg.extract
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
import borgmatic.hooks.command
@ -39,7 +39,7 @@ def run_extract(
borgmatic.borg.extract.extract_archive(
global_arguments.dry_run,
repository['path'],
borgmatic.borg.rlist.resolve_archive_name(
borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
extract_arguments.archive,
config,

View file

@ -3,7 +3,7 @@ import logging
import borgmatic.actions.arguments
import borgmatic.actions.json
import borgmatic.borg.info
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
logger = logging.getLogger(__name__)
@ -30,7 +30,7 @@ def run_info(
logger.answer(
f'{repository.get("label", repository["path"])}: Displaying archive summary information'
)
archive_name = borgmatic.borg.rlist.resolve_archive_name(
archive_name = borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
info_arguments.archive,
config,

View file

@ -31,7 +31,7 @@ def run_list(
elif not list_arguments.archive: # pragma: no cover
logger.answer(f'{repository.get("label", repository["path"])}: Listing archives')
archive_name = borgmatic.borg.rlist.resolve_archive_name(
archive_name = borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
list_arguments.archive,
config,

View file

@ -1,7 +1,7 @@
import logging
import borgmatic.borg.mount
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
logger = logging.getLogger(__name__)
@ -31,7 +31,7 @@ def run_mount(
borgmatic.borg.mount.mount_archive(
repository['path'],
borgmatic.borg.rlist.resolve_archive_name(
borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
mount_arguments.archive,
config,

View file

@ -1,41 +0,0 @@
import logging
import borgmatic.borg.rcreate
import borgmatic.config.validate
logger = logging.getLogger(__name__)
def run_rcreate(
repository,
config,
local_borg_version,
rcreate_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Run the "rcreate" action for the given repository.
'''
if rcreate_arguments.repository and not borgmatic.config.validate.repositories_match(
repository, rcreate_arguments.repository
):
return
logger.info(f'{repository.get("label", repository["path"])}: Creating repository')
borgmatic.borg.rcreate.create_repository(
global_arguments.dry_run,
repository['path'],
config,
local_borg_version,
global_arguments,
rcreate_arguments.encryption_mode,
rcreate_arguments.source_repository,
rcreate_arguments.copy_crypt_key,
rcreate_arguments.append_only,
rcreate_arguments.storage_quota,
rcreate_arguments.make_parent_dirs,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -0,0 +1,41 @@
import logging
import borgmatic.borg.repo_create
import borgmatic.config.validate
logger = logging.getLogger(__name__)
def run_repo_create(
repository,
config,
local_borg_version,
repo_create_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Run the "repo-create" action for the given repository.
'''
if repo_create_arguments.repository and not borgmatic.config.validate.repositories_match(
repository, repo_create_arguments.repository
):
return
logger.info(f'{repository.get("label", repository["path"])}: Creating repository')
borgmatic.borg.repo_create.create_repository(
global_arguments.dry_run,
repository['path'],
config,
local_borg_version,
global_arguments,
repo_create_arguments.encryption_mode,
repo_create_arguments.source_repository,
repo_create_arguments.copy_crypt_key,
repo_create_arguments.append_only,
repo_create_arguments.storage_quota,
repo_create_arguments.make_parent_dirs,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -1,35 +1,35 @@
import logging
import borgmatic.borg.rdelete
import borgmatic.borg.repo_delete
logger = logging.getLogger(__name__)
def run_rdelete(
def run_repo_delete(
repository,
config,
local_borg_version,
rdelete_arguments,
repo_delete_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Run the "rdelete" action for the given repository.
Run the "repo-delete" action for the given repository.
'''
if rdelete_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, rdelete_arguments.repository
if repo_delete_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, repo_delete_arguments.repository
):
logger.answer(
f'{repository.get("label", repository["path"])}: Deleting repository'
+ (' cache' if rdelete_arguments.cache_only else '')
+ (' cache' if repo_delete_arguments.cache_only else '')
)
borgmatic.borg.rdelete.delete_repository(
borgmatic.borg.repo_delete.delete_repository(
repository,
config,
local_borg_version,
rdelete_arguments,
repo_delete_arguments,
global_arguments,
local_path,
remote_path,

View file

@ -1,39 +1,39 @@
import logging
import borgmatic.actions.json
import borgmatic.borg.rinfo
import borgmatic.borg.repo_info
import borgmatic.config.validate
logger = logging.getLogger(__name__)
def run_rinfo(
def run_repo_info(
repository,
config,
local_borg_version,
rinfo_arguments,
repo_info_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Run the "rinfo" action for the given repository.
Run the "repo-info" action for the given repository.
If rinfo_arguments.json is True, yield the JSON output from the info for the repository.
If repo_info_arguments.json is True, yield the JSON output from the info for the repository.
'''
if rinfo_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, rinfo_arguments.repository
if repo_info_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, repo_info_arguments.repository
):
if not rinfo_arguments.json:
if not repo_info_arguments.json:
logger.answer(
f'{repository.get("label", repository["path"])}: Displaying repository summary information'
)
json_output = borgmatic.borg.rinfo.display_repository_info(
json_output = borgmatic.borg.repo_info.display_repository_info(
repository['path'],
config,
local_borg_version,
rinfo_arguments=rinfo_arguments,
repo_info_arguments=repo_info_arguments,
global_arguments=global_arguments,
local_path=local_path,
remote_path=remote_path,

View file

@ -1,37 +1,37 @@
import logging
import borgmatic.actions.json
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.config.validate
logger = logging.getLogger(__name__)
def run_rlist(
def run_repo_list(
repository,
config,
local_borg_version,
rlist_arguments,
repo_list_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Run the "rlist" action for the given repository.
Run the "repo-list" action for the given repository.
If rlist_arguments.json is True, yield the JSON output from listing the repository.
If repo_list_arguments.json is True, yield the JSON output from listing the repository.
'''
if rlist_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, rlist_arguments.repository
if repo_list_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, repo_list_arguments.repository
):
if not rlist_arguments.json:
if not repo_list_arguments.json:
logger.answer(f'{repository.get("label", repository["path"])}: Listing repository')
json_output = borgmatic.borg.rlist.list_repository(
json_output = borgmatic.borg.repo_list.list_repository(
repository['path'],
config,
local_borg_version,
rlist_arguments=rlist_arguments,
repo_list_arguments=repo_list_arguments,
global_arguments=global_arguments,
local_path=local_path,
remote_path=remote_path,

View file

@ -5,7 +5,7 @@ import os
import borgmatic.borg.extract
import borgmatic.borg.list
import borgmatic.borg.mount
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.borg.state
import borgmatic.config.validate
import borgmatic.hooks.dispatch
@ -285,7 +285,7 @@ def run_restore(
global_arguments.dry_run,
)
archive_name = borgmatic.borg.rlist.resolve_archive_name(
archive_name = borgmatic.borg.repo_list.resolve_archive_name(
repository['path'],
restore_arguments.archive,
config,

View file

@ -2,7 +2,7 @@ import argparse
import json
import logging
from borgmatic.borg import environment, feature, flags, rinfo
from borgmatic.borg import environment, feature, flags, repo_info
from borgmatic.execute import DO_NOT_CAPTURE, execute_command
logger = logging.getLogger(__name__)
@ -94,7 +94,7 @@ def get_repository_id(
'''
try:
return json.loads(
rinfo.display_repository_info(
repo_info.display_repository_info(
repository_path,
config,
local_borg_version,

View file

@ -4,7 +4,7 @@ import logging
import borgmatic.borg.environment
import borgmatic.borg.feature
import borgmatic.borg.flags
import borgmatic.borg.rdelete
import borgmatic.borg.repo_delete
import borgmatic.execute
logger = logging.getLogger(__name__)
@ -88,24 +88,24 @@ def delete_archives(
for argument_name in ARCHIVE_RELATED_ARGUMENT_NAMES
):
if borgmatic.borg.feature.available(
borgmatic.borg.feature.Feature.RDELETE, local_borg_version
borgmatic.borg.feature.Feature.REPO_DELETE, local_borg_version
):
logger.warning(
'Deleting an entire repository with the delete action is deprecated when using Borg 2.x+. Use the rdelete action instead.'
'Deleting an entire repository with the delete action is deprecated when using Borg 2.x+. Use the repo-delete action instead.'
)
rdelete_arguments = argparse.Namespace(
repo_delete_arguments = argparse.Namespace(
repository=repository['path'],
list_archives=delete_arguments.list_archives,
force=delete_arguments.force,
cache_only=delete_arguments.cache_only,
keep_security_info=delete_arguments.keep_security_info,
)
borgmatic.borg.rdelete.delete_repository(
borgmatic.borg.repo_delete.delete_repository(
repository,
config,
local_borg_version,
rdelete_arguments,
repo_delete_arguments,
global_arguments,
local_path,
remote_path,

View file

@ -3,7 +3,7 @@ import os
import subprocess
import borgmatic.config.validate
from borgmatic.borg import environment, feature, flags, rlist
from borgmatic.borg import environment, feature, flags, repo_list
from borgmatic.execute import DO_NOT_CAPTURE, execute_command
logger = logging.getLogger(__name__)
@ -29,7 +29,7 @@ def extract_last_archive_dry_run(
verbosity_flags = ('--info',)
try:
last_archive_name = rlist.resolve_archive_name(
last_archive_name = repo_list.resolve_archive_name(
repository_path,
'latest',
config,

View file

@ -10,10 +10,10 @@ class Feature(Enum):
NUMERIC_IDS = 4
UPLOAD_RATELIMIT = 5
SEPARATE_REPOSITORY_ARCHIVE = 6
RCREATE = 7
RLIST = 8
RINFO = 9
RDELETE = 10
REPO_CREATE = 7
REPO_LIST = 8
REPO_INFO = 9
REPO_DELETE = 10
MATCH_ARCHIVES = 11
EXCLUDED_FILES_MINUS = 12
@ -25,10 +25,10 @@ FEATURE_TO_MINIMUM_BORG_VERSION = {
Feature.NUMERIC_IDS: parse('1.2.0b3'), # borg create/extract/mount --numeric-ids
Feature.UPLOAD_RATELIMIT: parse('1.2.0b3'), # borg create --upload-ratelimit
Feature.SEPARATE_REPOSITORY_ARCHIVE: parse('2.0.0a2'), # --repo with separate archive
Feature.RCREATE: parse('2.0.0a2'), # borg rcreate
Feature.RLIST: parse('2.0.0a2'), # borg rlist
Feature.RINFO: parse('2.0.0a2'), # borg rinfo
Feature.RDELETE: parse('2.0.0a2'), # borg rdelete
Feature.REPO_CREATE: parse('2.0.0a2'), # borg repo-create
Feature.REPO_LIST: parse('2.0.0a2'), # borg repo-list
Feature.REPO_INFO: parse('2.0.0a2'), # borg repo-info
Feature.REPO_DELETE: parse('2.0.0a2'), # borg repo-delete
Feature.MATCH_ARCHIVES: parse('2.0.0b3'), # borg --match-archives
Feature.EXCLUDED_FILES_MINUS: parse('2.0.0b5'), # --list --filter uses "-" for excludes
}

View file

@ -4,19 +4,19 @@ import logging
import re
import borgmatic.logger
from borgmatic.borg import environment, feature, flags, rlist
from borgmatic.borg import environment, feature, flags, repo_list
from borgmatic.execute import execute_command, execute_command_and_capture_output
logger = logging.getLogger(__name__)
ARCHIVE_FILTER_FLAGS_MOVED_TO_RLIST = ('prefix', 'match_archives', 'sort_by', 'first', 'last')
ARCHIVE_FILTER_FLAGS_MOVED_TO_REPO_LIST = ('prefix', 'match_archives', 'sort_by', 'first', 'last')
MAKE_FLAGS_EXCLUDES = (
'repository',
'archive',
'paths',
'find_paths',
) + ARCHIVE_FILTER_FLAGS_MOVED_TO_RLIST
) + ARCHIVE_FILTER_FLAGS_MOVED_TO_REPO_LIST
def make_list_command(
@ -155,12 +155,12 @@ def list_archive(
borgmatic.logger.add_custom_log_levels()
if not list_arguments.archive and not list_arguments.find_paths:
if feature.available(feature.Feature.RLIST, local_borg_version):
if feature.available(feature.Feature.REPO_LIST, local_borg_version):
logger.warning(
'Omitting the --archive flag on the list action is deprecated when using Borg 2.x+. Use the rlist action instead.'
'Omitting the --archive flag on the list action is deprecated when using Borg 2.x+. Use the repo-list action instead.'
)
rlist_arguments = argparse.Namespace(
repo_list_arguments = argparse.Namespace(
repository=repository_path,
short=list_arguments.short,
format=list_arguments.format,
@ -171,18 +171,18 @@ def list_archive(
first=list_arguments.first,
last=list_arguments.last,
)
return rlist.list_repository(
return repo_list.list_repository(
repository_path,
config,
local_borg_version,
rlist_arguments,
repo_list_arguments,
global_arguments,
local_path,
remote_path,
)
if list_arguments.archive:
for name in ARCHIVE_FILTER_FLAGS_MOVED_TO_RLIST:
for name in ARCHIVE_FILTER_FLAGS_MOVED_TO_REPO_LIST:
if getattr(list_arguments, name, None):
logger.warning(
f"The --{name.replace('_', '-')} flag on the list action is ignored when using the --archive flag."
@ -199,7 +199,7 @@ def list_archive(
# If there are any paths to find (and there's not a single archive already selected), start by
# getting a list of archives to search.
if list_arguments.find_paths and not list_arguments.archive:
rlist_arguments = argparse.Namespace(
repo_list_arguments = argparse.Namespace(
repository=repository_path,
short=True,
format=None,
@ -214,11 +214,11 @@ def list_archive(
# Ask Borg to list archives. Capture its output for use below.
archive_lines = tuple(
execute_command_and_capture_output(
rlist.make_rlist_command(
repo_list.make_repo_list_command(
repository_path,
config,
local_borg_version,
rlist_arguments,
repo_list_arguments,
global_arguments,
local_path,
remote_path,
@ -242,7 +242,7 @@ def list_archive(
# This list call is to show the files in a single archive, not list multiple archives. So
# blank out any archive filtering flags. They'll break anyway in Borg 2.
for name in ARCHIVE_FILTER_FLAGS_MOVED_TO_RLIST:
for name in ARCHIVE_FILTER_FLAGS_MOVED_TO_REPO_LIST:
setattr(archive_arguments, name, None)
main_command = make_list_command(

View file

@ -3,13 +3,13 @@ import json
import logging
import subprocess
from borgmatic.borg import environment, feature, flags, rinfo
from borgmatic.borg import environment, feature, flags, repo_info
from borgmatic.execute import DO_NOT_CAPTURE, execute_command
logger = logging.getLogger(__name__)
RINFO_REPOSITORY_NOT_FOUND_EXIT_CODES = {2, 13, 15}
REPO_INFO_REPOSITORY_NOT_FOUND_EXIT_CODES = {2, 13, 15}
def create_repository(
@ -39,7 +39,7 @@ def create_repository(
'''
try:
info_data = json.loads(
rinfo.display_repository_info(
repo_info.display_repository_info(
repository_path,
config,
local_borg_version,
@ -59,17 +59,17 @@ def create_repository(
logger.info(f'{repository_path}: Repository already exists. Skipping creation.')
return
except subprocess.CalledProcessError as error:
if error.returncode not in RINFO_REPOSITORY_NOT_FOUND_EXIT_CODES:
if error.returncode not in REPO_INFO_REPOSITORY_NOT_FOUND_EXIT_CODES:
raise
lock_wait = config.get('lock_wait')
extra_borg_options = config.get('extra_borg_options', {}).get('rcreate', '')
extra_borg_options = config.get('extra_borg_options', {}).get('repo-create', '')
rcreate_command = (
repo_create_command = (
(local_path,)
+ (
('rcreate',)
if feature.available(feature.Feature.RCREATE, local_borg_version)
('repo-create',)
if feature.available(feature.Feature.REPO_CREATE, local_borg_version)
else ('init',)
)
+ (('--encryption', encryption_mode) if encryption_mode else ())
@ -93,7 +93,7 @@ def create_repository(
# Do not capture output here, so as to support interactive prompts.
execute_command(
rcreate_command,
repo_create_command,
output_file=DO_NOT_CAPTURE,
extra_environment=environment.make_environment(config),
borg_local_path=local_path,

View file

@ -8,26 +8,26 @@ import borgmatic.execute
logger = logging.getLogger(__name__)
def make_rdelete_command(
def make_repo_delete_command(
repository,
config,
local_borg_version,
rdelete_arguments,
repo_delete_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Given a local or remote repository dict, a configuration dict, the local Borg version, the
arguments to the rdelete action as an argparse.Namespace, and global arguments, return a command
as a tuple to rdelete the entire repository.
arguments to the repo_delete action as an argparse.Namespace, and global arguments, return a command
as a tuple to repo_delete the entire repository.
'''
return (
(local_path,)
+ (
('rdelete',)
('repo-delete',)
if borgmatic.borg.feature.available(
borgmatic.borg.feature.Feature.RDELETE, local_borg_version
borgmatic.borg.feature.Feature.REPO_DELETE, local_borg_version
)
else ('delete',)
)
@ -37,14 +37,14 @@ def make_rdelete_command(
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
+ borgmatic.borg.flags.make_flags('log-json', global_arguments.log_json)
+ borgmatic.borg.flags.make_flags('lock-wait', config.get('lock_wait'))
+ borgmatic.borg.flags.make_flags('list', rdelete_arguments.list_archives)
+ borgmatic.borg.flags.make_flags('list', repo_delete_arguments.list_archives)
+ (
(('--force',) + (('--force',) if rdelete_arguments.force >= 2 else ()))
if rdelete_arguments.force
(('--force',) + (('--force',) if repo_delete_arguments.force >= 2 else ()))
if repo_delete_arguments.force
else ()
)
+ borgmatic.borg.flags.make_flags_from_arguments(
rdelete_arguments, excludes=('list_archives', 'force', 'repository')
repo_delete_arguments, excludes=('list_archives', 'force', 'repository')
)
+ borgmatic.borg.flags.make_repository_flags(repository['path'], local_borg_version)
)
@ -54,23 +54,23 @@ def delete_repository(
repository,
config,
local_borg_version,
rdelete_arguments,
repo_delete_arguments,
global_arguments,
local_path='borg',
remote_path=None,
):
'''
Given a local or remote repository dict, a configuration dict, the local Borg version, the
arguments to the rdelete action as an argparse.Namespace, global arguments as an
argparse.Namespace, and local and remote Borg paths, rdelete the entire repository.
arguments to the repo_delete action as an argparse.Namespace, global arguments as an
argparse.Namespace, and local and remote Borg paths, repo_delete the entire repository.
'''
borgmatic.logger.add_custom_log_levels()
command = make_rdelete_command(
command = make_repo_delete_command(
repository,
config,
local_borg_version,
rdelete_arguments,
repo_delete_arguments,
global_arguments,
local_path,
remote_path,
@ -83,7 +83,7 @@ def delete_repository(
# prompt won't work.
output_file=(
None
if rdelete_arguments.force or rdelete_arguments.cache_only
if repo_delete_arguments.force or repo_delete_arguments.cache_only
else borgmatic.execute.DO_NOT_CAPTURE
),
extra_environment=borgmatic.borg.environment.make_environment(config),

View file

@ -11,14 +11,14 @@ def display_repository_info(
repository_path,
config,
local_borg_version,
rinfo_arguments,
repo_info_arguments,
global_arguments,
local_path='borg',
remote_path=None,
):
'''
Given a local or remote repository path, a configuration dict, the local Borg version, the
arguments to the rinfo action, and global arguments as an argparse.Namespace, display summary
arguments to the repo_info action, and global arguments as an argparse.Namespace, display summary
information for the Borg repository or return JSON summary information.
'''
borgmatic.logger.add_custom_log_levels()
@ -27,31 +27,31 @@ def display_repository_info(
full_command = (
(local_path,)
+ (
('rinfo',)
if feature.available(feature.Feature.RINFO, local_borg_version)
('repo-info',)
if feature.available(feature.Feature.REPO_INFO, local_borg_version)
else ('info',)
)
+ (
('--info',)
if logger.getEffectiveLevel() == logging.INFO and not rinfo_arguments.json
if logger.getEffectiveLevel() == logging.INFO and not repo_info_arguments.json
else ()
)
+ (
('--debug', '--show-rc')
if logger.isEnabledFor(logging.DEBUG) and not rinfo_arguments.json
if logger.isEnabledFor(logging.DEBUG) and not repo_info_arguments.json
else ()
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('log-json', global_arguments.log_json)
+ flags.make_flags('lock-wait', lock_wait)
+ (('--json',) if rinfo_arguments.json else ())
+ (('--json',) if repo_info_arguments.json else ())
+ flags.make_repository_flags(repository_path, local_borg_version)
)
extra_environment = environment.make_environment(config)
borg_exit_codes = config.get('borg_exit_codes')
if rinfo_arguments.json:
if repo_info_arguments.json:
return execute_command_and_capture_output(
full_command,
extra_environment=extra_environment,

View file

@ -31,7 +31,11 @@ def resolve_archive_name(
full_command = (
(
local_path,
'rlist' if feature.available(feature.Feature.RLIST, local_borg_version) else 'list',
(
'repo-list'
if feature.available(feature.Feature.REPO_LIST, local_borg_version)
else 'list'
),
)
+ flags.make_flags('remote-path', remote_path)
+ flags.make_flags('log-json', global_arguments.log_json)
@ -60,33 +64,37 @@ def resolve_archive_name(
MAKE_FLAGS_EXCLUDES = ('repository', 'prefix', 'match_archives')
def make_rlist_command(
def make_repo_list_command(
repository_path,
config,
local_borg_version,
rlist_arguments,
repo_list_arguments,
global_arguments,
local_path='borg',
remote_path=None,
):
'''
Given a local or remote repository path, a configuration dict, the local Borg version, the
arguments to the rlist action, global arguments as an argparse.Namespace instance, and local and
arguments to the repo_list action, global arguments as an argparse.Namespace instance, and local and
remote Borg paths, return a command as a tuple to list archives with a repository.
'''
return (
(
local_path,
'rlist' if feature.available(feature.Feature.RLIST, local_borg_version) else 'list',
(
'repo-list'
if feature.available(feature.Feature.REPO_LIST, local_borg_version)
else 'list'
),
)
+ (
('--info',)
if logger.getEffectiveLevel() == logging.INFO and not rlist_arguments.json
if logger.getEffectiveLevel() == logging.INFO and not repo_list_arguments.json
else ()
)
+ (
('--debug', '--show-rc')
if logger.isEnabledFor(logging.DEBUG) and not rlist_arguments.json
if logger.isEnabledFor(logging.DEBUG) and not repo_list_arguments.json
else ()
)
+ flags.make_flags('remote-path', remote_path)
@ -94,20 +102,20 @@ def make_rlist_command(
+ flags.make_flags('lock-wait', config.get('lock_wait'))
+ (
(
flags.make_flags('match-archives', f'sh:{rlist_arguments.prefix}*')
flags.make_flags('match-archives', f'sh:{repo_list_arguments.prefix}*')
if feature.available(feature.Feature.MATCH_ARCHIVES, local_borg_version)
else flags.make_flags('glob-archives', f'{rlist_arguments.prefix}*')
else flags.make_flags('glob-archives', f'{repo_list_arguments.prefix}*')
)
if rlist_arguments.prefix
if repo_list_arguments.prefix
else (
flags.make_match_archives_flags(
rlist_arguments.match_archives or config.get('match_archives'),
repo_list_arguments.match_archives or config.get('match_archives'),
config.get('archive_name_format'),
local_borg_version,
)
)
)
+ flags.make_flags_from_arguments(rlist_arguments, excludes=MAKE_FLAGS_EXCLUDES)
+ flags.make_flags_from_arguments(repo_list_arguments, excludes=MAKE_FLAGS_EXCLUDES)
+ flags.make_repository_flags(repository_path, local_borg_version)
)
@ -116,7 +124,7 @@ def list_repository(
repository_path,
config,
local_borg_version,
rlist_arguments,
repo_list_arguments,
global_arguments,
local_path='borg',
remote_path=None,
@ -130,20 +138,20 @@ def list_repository(
borgmatic.logger.add_custom_log_levels()
borg_environment = environment.make_environment(config)
main_command = make_rlist_command(
main_command = make_repo_list_command(
repository_path,
config,
local_borg_version,
rlist_arguments,
repo_list_arguments,
global_arguments,
local_path,
remote_path,
)
json_command = make_rlist_command(
json_command = make_repo_list_command(
repository_path,
config,
local_borg_version,
argparse.Namespace(**dict(rlist_arguments.__dict__, json=True)),
argparse.Namespace(**dict(repo_list_arguments.__dict__, json=True)),
global_arguments,
local_path,
remote_path,
@ -157,7 +165,7 @@ def list_repository(
borg_exit_codes=borg_exit_codes,
)
if rlist_arguments.json:
if repo_list_arguments.json:
return json_listing
flags.warn_for_aggressive_archive_flags(json_command, json_listing)

View file

@ -6,7 +6,7 @@ from argparse import ArgumentParser
from borgmatic.config import collect
ACTION_ALIASES = {
'rcreate': ['init', '-I'],
'repo-create': ['rcreate', 'init', '-I'],
'prune': ['-p'],
'compact': [],
'create': ['-C'],
@ -18,10 +18,10 @@ ACTION_ALIASES = {
'mount': ['-m'],
'umount': ['-u'],
'restore': ['-r'],
'rdelete': [],
'rlist': [],
'repo-delete': ['rdelete'],
'repo-list': ['rlist'],
'list': ['-l'],
'rinfo': [],
'repo-info': ['rinfo'],
'info': ['-i'],
'transfer': [],
'break-lock': [],
@ -402,51 +402,51 @@ def make_parsers():
metavar='',
help='Specify zero or more actions. Defaults to create, prune, compact, and check. Use --help with action for details:',
)
rcreate_parser = action_parsers.add_parser(
'rcreate',
aliases=ACTION_ALIASES['rcreate'],
repo_create_parser = action_parsers.add_parser(
'repo-create',
aliases=ACTION_ALIASES['repo-create'],
help='Create a new, empty Borg repository',
description='Create a new, empty Borg repository',
add_help=False,
)
rcreate_group = rcreate_parser.add_argument_group('rcreate arguments')
rcreate_group.add_argument(
repo_create_group = repo_create_parser.add_argument_group('repo-create arguments')
repo_create_group.add_argument(
'-e',
'--encryption',
dest='encryption_mode',
help='Borg repository encryption mode',
required=True,
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'--source-repository',
'--other-repo',
metavar='KEY_REPOSITORY',
help='Path to an existing Borg repository whose key material should be reused [Borg 2.x+ only]',
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'--repository',
help='Path of the new repository to create (must be already specified in a borgmatic configuration file), defaults to the configured repository if there is only one, quoted globs supported',
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'--copy-crypt-key',
action='store_true',
help='Copy the crypt key used for authenticated encryption from the source repository, defaults to a new random key [Borg 2.x+ only]',
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'--append-only',
action='store_true',
help='Create an append-only repository',
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'--storage-quota',
help='Create a repository with a fixed storage quota',
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'--make-parent-dirs',
action='store_true',
help='Create any missing parent directories of the repository directory',
)
rcreate_group.add_argument(
repo_create_group.add_argument(
'-h', '--help', action='help', help='Show this help message and exit'
)
@ -1070,40 +1070,40 @@ def make_parsers():
)
umount_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
rdelete_parser = action_parsers.add_parser(
'rdelete',
aliases=ACTION_ALIASES['rdelete'],
repo_delete_parser = action_parsers.add_parser(
'repo-delete',
aliases=ACTION_ALIASES['repo-delete'],
help='Delete an entire repository (with Borg 1.2+, you must run compact afterwards to actually free space)',
description='Delete an entire repository (with Borg 1.2+, you must run compact afterwards to actually free space)',
add_help=False,
)
rdelete_group = rdelete_parser.add_argument_group('delete arguments')
rdelete_group.add_argument(
repo_delete_group = repo_delete_parser.add_argument_group('delete arguments')
repo_delete_group.add_argument(
'--repository',
help='Path of repository to delete, defaults to the configured repository if there is only one, quoted globs supported',
)
rdelete_group.add_argument(
repo_delete_group.add_argument(
'--list',
dest='list_archives',
action='store_true',
help='Show details for the archives in the given repository',
)
rdelete_group.add_argument(
repo_delete_group.add_argument(
'--force',
action='count',
help='Force deletion of corrupted archives, can be given twice if once does not work',
)
rdelete_group.add_argument(
repo_delete_group.add_argument(
'--cache-only',
action='store_true',
help='Delete only the local cache for the given repository',
)
rdelete_group.add_argument(
repo_delete_group.add_argument(
'--keep-security-info',
action='store_true',
help='Do not delete the local security info when deleting a repository',
)
rdelete_group.add_argument(
repo_delete_group.add_argument(
'-h', '--help', action='help', help='Show this help message and exit'
)
@ -1161,65 +1161,67 @@ def make_parsers():
'-h', '--help', action='help', help='Show this help message and exit'
)
rlist_parser = action_parsers.add_parser(
'rlist',
aliases=ACTION_ALIASES['rlist'],
repo_list_parser = action_parsers.add_parser(
'repo-list',
aliases=ACTION_ALIASES['repo-list'],
help='List repository',
description='List the archives in a repository',
add_help=False,
)
rlist_group = rlist_parser.add_argument_group('rlist arguments')
rlist_group.add_argument(
repo_list_group = repo_list_parser.add_argument_group('repo-list arguments')
repo_list_group.add_argument(
'--repository',
help='Path of repository to list, defaults to the configured repositories, quoted globs supported',
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--short', default=False, action='store_true', help='Output only archive names'
)
rlist_group.add_argument('--format', help='Format for archive listing')
rlist_group.add_argument(
repo_list_group.add_argument('--format', help='Format for archive listing')
repo_list_group.add_argument(
'--json', default=False, action='store_true', help='Output results as JSON'
)
rlist_group.add_argument(
repo_list_group.add_argument(
'-P', '--prefix', help='Deprecated. Only list archive names starting with this prefix'
)
rlist_group.add_argument(
repo_list_group.add_argument(
'-a',
'--match-archives',
'--glob-archives',
metavar='PATTERN',
help='Only list archive names matching this pattern',
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--sort-by', metavar='KEYS', help='Comma-separated list of sorting keys'
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--first', metavar='N', help='List first N archives after other filters are applied'
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--last', metavar='N', help='List last N archives after other filters are applied'
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--oldest',
metavar='TIMESPAN',
help='List archives within a specified time range starting from the timestamp of the oldest archive (e.g. 7d or 12m) [Borg 2.x+ only]',
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--newest',
metavar='TIMESPAN',
help='List archives within a time range that ends at timestamp of the newest archive and starts a specified time range ago (e.g. 7d or 12m) [Borg 2.x+ only]',
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--older',
metavar='TIMESPAN',
help='List archives that are older than the specified time range (e.g. 7d or 12m) from the current time [Borg 2.x+ only]',
)
rlist_group.add_argument(
repo_list_group.add_argument(
'--newer',
metavar='TIMESPAN',
help='List archives that are newer than the specified time range (e.g. 7d or 12m) from the current time [Borg 2.x+ only]',
)
rlist_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
repo_list_group.add_argument(
'-h', '--help', action='help', help='Show this help message and exit'
)
list_parser = action_parsers.add_parser(
'list',
@ -1288,22 +1290,24 @@ def make_parsers():
)
list_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
rinfo_parser = action_parsers.add_parser(
'rinfo',
aliases=ACTION_ALIASES['rinfo'],
repo_info_parser = action_parsers.add_parser(
'repo-info',
aliases=ACTION_ALIASES['repo-info'],
help='Show repository summary information such as disk space used',
description='Show repository summary information such as disk space used',
add_help=False,
)
rinfo_group = rinfo_parser.add_argument_group('rinfo arguments')
rinfo_group.add_argument(
repo_info_group = repo_info_parser.add_argument_group('repo-info arguments')
repo_info_group.add_argument(
'--repository',
help='Path of repository to show info for, defaults to the configured repository if there is only one, quoted globs supported',
)
rinfo_group.add_argument(
repo_info_group.add_argument(
'--json', dest='json', default=False, action='store_true', help='Output results as JSON'
)
rinfo_group.add_argument('-h', '--help', action='help', help='Show this help message and exit')
repo_info_group.add_argument(
'-h', '--help', action='help', help='Show this help message and exit'
)
info_parser = action_parsers.add_parser(
'info',
@ -1515,9 +1519,9 @@ def parse_arguments(*unparsed_arguments):
)
if (
('list' in arguments and 'rinfo' in arguments and arguments['list'].json)
('list' in arguments and 'repo-info' in arguments and arguments['list'].json)
or ('list' in arguments and 'info' in arguments and arguments['list'].json)
or ('rinfo' in arguments and 'info' in arguments and arguments['rinfo'].json)
or ('repo-info' in arguments and 'info' in arguments and arguments['repo-info'].json)
):
raise ValueError('With the --json flag, multiple actions cannot be used together.')
@ -1535,9 +1539,11 @@ def parse_arguments(*unparsed_arguments):
'With the list action, only one of --prefix or --match-archives flags can be used.'
)
if 'rlist' in arguments and (arguments['rlist'].prefix and arguments['rlist'].match_archives):
if 'repo-list' in arguments and (
arguments['repo-list'].prefix and arguments['repo-list'].match_archives
):
raise ValueError(
'With the rlist action, only one of --prefix or --match-archives flags can be used.'
'With the repo-list action, only one of --prefix or --match-archives flags can be used.'
)
if 'info' in arguments and (

View file

@ -27,11 +27,11 @@ import borgmatic.actions.info
import borgmatic.actions.list
import borgmatic.actions.mount
import borgmatic.actions.prune
import borgmatic.actions.rcreate
import borgmatic.actions.rdelete
import borgmatic.actions.repo_create
import borgmatic.actions.repo_delete
import borgmatic.actions.repo_info
import borgmatic.actions.repo_list
import borgmatic.actions.restore
import borgmatic.actions.rinfo
import borgmatic.actions.rlist
import borgmatic.actions.transfer
import borgmatic.commands.completion.bash
import borgmatic.commands.completion.fish
@ -307,8 +307,8 @@ def run_actions(
)
for action_name, action_arguments in arguments.items():
if action_name == 'rcreate' and action_name not in skip_actions:
borgmatic.actions.rcreate.run_rcreate(
if action_name == 'repo-create' and action_name not in skip_actions:
borgmatic.actions.repo_create.run_repo_create(
repository,
config,
local_borg_version,
@ -422,8 +422,8 @@ def run_actions(
local_path,
remote_path,
)
elif action_name == 'rlist' and action_name not in skip_actions:
yield from borgmatic.actions.rlist.run_rlist(
elif action_name == 'repo-list' and action_name not in skip_actions:
yield from borgmatic.actions.repo_list.run_repo_list(
repository,
config,
local_borg_version,
@ -442,8 +442,8 @@ def run_actions(
local_path,
remote_path,
)
elif action_name == 'rinfo' and action_name not in skip_actions:
yield from borgmatic.actions.rinfo.run_rinfo(
elif action_name == 'repo-info' and action_name not in skip_actions:
yield from borgmatic.actions.repo_info.run_repo_info(
repository,
config,
local_borg_version,
@ -502,8 +502,8 @@ def run_actions(
local_path,
remote_path,
)
elif action_name == 'rdelete' and action_name not in skip_actions:
borgmatic.actions.rdelete.run_rdelete(
elif action_name == 'repo-delete' and action_name not in skip_actions:
borgmatic.actions.repo_delete.run_repo_delete(
repository,
config,
local_borg_version,

View file

@ -396,8 +396,8 @@ properties:
Name of the archive. Borg placeholders can be used. See the output
of "borg help placeholders" for details. Defaults to
"{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}". When running actions like
rlist, info, or check, borgmatic automatically tries to match only
archives created with this name format.
repo-list, info, or check, borgmatic automatically tries to match
only archives created with this name format.
example: "{hostname}-documents-{now}"
match_archives:
type: string
@ -749,7 +749,7 @@ properties:
items:
type: string
enum:
- rcreate
- repo-create
- transfer
- prune
- compact
@ -761,11 +761,11 @@ properties:
- export-tar
- mount
- umount
- rdelete
- repo-delete
- restore
- rlist
- repo-list
- list
- rinfo
- repo-info
- info
- break-lock
- key

View file

@ -4,7 +4,7 @@ COPY . /app
RUN apk add --no-cache py3-pip py3-ruamel.yaml py3-ruamel.yaml.clib
RUN pip install --break-system-packages --no-cache /app && generate-borgmatic-config && chmod +r /etc/borgmatic/config.yaml
RUN borgmatic --help > /command-line.txt \
&& for action in rcreate transfer create prune compact check delete extract config "config bootstrap" "config generate" "config validate" export-tar mount umount rdelete restore rlist list rinfo info break-lock "key export" "key change-passphrase" borg; do \
&& for action in repo-create transfer create prune compact check delete extract config "config bootstrap" "config generate" "config validate" export-tar mount umount repo-delete restore repo-list list repo-info info break-lock "key export" "key change-passphrase" borg; do \
echo -e "\n--------------------------------------------------------------------------------\n" >> /command-line.txt \
&& borgmatic $action --help >> /command-line.txt; done
RUN /app/docs/fetch-contributors >> /contributors.html

View file

@ -311,13 +311,14 @@ borgmatic does not currently create a database upon restore.
To restore a database dump from an archive, use the `borgmatic restore`
action. But the first step is to figure out which archive to restore from. A
good way to do that is to use the `rlist` action:
good way to do that is to use the `repo-list` action:
```bash
borgmatic rlist
borgmatic repo-list
```
(No borgmatic `rlist` action? Try `list` instead or upgrade borgmatic!)
(No borgmatic `repo-list` action? Try `rlist` or `list` instead or upgrade
borgmatic!)
That should yield output looking something like:

View file

@ -9,13 +9,14 @@ eleventyNavigation:
When the worst happens—or you want to test your backups—the first step is
to figure out which archive to extract. A good way to do that is to use the
`rlist` action:
`repo-list` action:
```bash
borgmatic rlist
borgmatic repo-list
```
(No borgmatic `rlist` action? Try `list` instead or upgrade borgmatic!)
(No borgmatic `repo-list` action? Try `rlist` or `list` instead or upgrade
borgmatic!)
That should yield output looking something like:

View file

@ -62,13 +62,13 @@ for available values.
(No borgmatic `list` or `info` actions? Upgrade borgmatic!)
<span class="minilink minilink-addedin">New in borgmatic version 1.7.0</span>
There are also `rlist` and `rinfo` actions for displaying repository
<span class="minilink minilink-addedin">New in borgmatic version 1.8.15</span>
There are also `repo-list` and `repo-info` actions for displaying repository
information with Borg 2.x:
```bash
borgmatic rlist
borgmatic rinfo
borgmatic repo-list
borgmatic repo-info
```
See the [borgmatic command-line

View file

@ -92,10 +92,10 @@ timestamp in a particular format.
<span class="minilink minilink-addedin">New in version 1.7.11</span> borgmatic
uses the `archive_name_format` option to automatically limit which archives
get used for actions operating on multiple archives. This prevents, for
instance, duplicate archives from showing up in `rlist` or `info` results—even
if the same repository appears in multiple borgmatic configuration files. To
take advantage of this feature, use a different `archive_name_format` in each
configuration file.
instance, duplicate archives from showing up in `repo-list` or `info`
results—even if the same repository appears in multiple borgmatic
configuration files. To take advantage of this feature, use a different
`archive_name_format` in each configuration file.
Under the hood, borgmatic accomplishes this by substituting globs for certain
ephemeral data placeholders in your `archive_name_format`—and using the result
@ -113,7 +113,7 @@ this option in the `storage:` section of your configuration.
borgmatic considers `{now}` an emphemeral data placeholder that will probably
change per archive, while `{hostname}` won't. So it turns the example value
into `{hostname}-user-data-*` and applies it to filter down the set of
archives used for actions like `rlist`, `info`, `prune`, `check`, etc.
archives used for actions like `repo-list`, `info`, `prune`, `check`, etc.
The end result is that when borgmatic runs the actions for a particular
application-specific configuration file, it only operates on the archives

View file

@ -566,8 +566,8 @@ Resend Notification every X times = 1
## Scripting borgmatic
To consume the output of borgmatic in other software, you can include an
optional `--json` flag with `create`, `rlist`, `rinfo`, or `info` to get the
output formatted as JSON.
optional `--json` flag with `create`, `repo-list`, `repo-info`, or `info` to
get the output formatted as JSON.
Note that when you specify the `--json` flag, Borg's other non-JSON output is
suppressed so as not to interfere with the captured JSON. Also note that JSON
@ -578,7 +578,7 @@ output only shows up at the console and not in syslog.
All borgmatic actions that accept an `--archive` flag allow you to specify an
archive name of `latest`. This lets you get the latest archive without having
to first run `borgmatic rlist` manually, which can be handy in automated
to first run `borgmatic repo-list` manually, which can be handy in automated
scripts. Here's an example:
```bash

View file

@ -45,10 +45,14 @@ be preferred though for most uses.)
You can also specify Borg options for relevant commands. For instance:
```bash
borgmatic borg rlist --short
borgmatic borg repo-list --short
```
This runs Borg's `rlist` command once on each configured borgmatic repository.
(No borgmatic `repo-list` action? Try `rlist` or `list` instead or upgrade
borgmatic!)
This runs Borg's `repo-list` command once on each configured borgmatic
repository.
What if you only want to run Borg on a single configured borgmatic repository
when you've got several configured? Not a problem. The `--repository` argument

View file

@ -214,11 +214,11 @@ command like the following with Borg 1.x:
sudo borgmatic init --encryption repokey
```
<span class="minilink minilink-addedin">New in borgmatic version 1.7.0</span>
<span class="minilink minilink-addedin">New in borgmatic version 1.8.15</span>
Or, with Borg 2.x:
```bash
sudo borgmatic rcreate --encryption repokey-aes-ocb
sudo borgmatic repo-create --encryption repokey-aes-ocb
```
(Note that `repokey-chacha20-poly1305` may be faster than `repokey-aes-ocb` on

View file

@ -93,7 +93,7 @@ Borg releases require additional steps that borgmatic can help with.
### Borg 1.2 to 2.0
<span class="minilink minilink-addedin">New in borgmatic version 1.7.0</span>
<span class="minilink minilink-addedin">New in borgmatic version 1.8.15</span>
Upgrading Borg from 1.2 to 2.0 requires manually upgrading your existing Borg
1 repositories before use with Borg or borgmatic. Here's how you can
accomplish that.
@ -125,11 +125,11 @@ option was found in the `location:` section of your configuration.
<span class="minilink minilink-addedin">Prior to version 1.7.10</span> Omit
the `path:` portion of the `repositories` list.
Then, run the `rcreate` action (formerly `init`) to create that new Borg 2
Then, run the `repo-create` action (formerly `init`) to create that new Borg 2
repository:
```bash
borgmatic rcreate --verbosity 1 --encryption repokey-blake2-aes-ocb \
borgmatic repo-create --verbosity 1 --encryption repokey-blake2-aes-ocb \
--source-repository original.borg --repository upgraded.borg
```
@ -146,12 +146,12 @@ means the encryption value you specified doesn't correspond to your source
repository's chunk ID algorithm. In that case, try not using `blake2`:
```bash
borgmatic rcreate --verbosity 1 --encryption repokey-aes-ocb \
borgmatic repo-create --verbosity 1 --encryption repokey-aes-ocb \
--source-repository original.borg --repository upgraded.borg
```
Read about [Borg encryption
modes](https://borgbackup.readthedocs.io/en/2.0.0b8/usage/rcreate.html#encryption-mode-tldr)
modes](https://borgbackup.readthedocs.io/en/latest/usage/repo-create.html)
for more details.
To transfer data from your original Borg 1 repository to your newly created

View file

@ -44,7 +44,7 @@ def test_borgmatic_command():
generate_configuration(config_path, repository_path)
subprocess.check_call(
f'borgmatic -v 2 --config {config_path} rcreate --encryption repokey'.split(' ')
f'borgmatic -v 2 --config {config_path} repo-create --encryption repokey'.split(' ')
)
# Run borgmatic to generate a backup archive, and then list it to make sure it exists.

View file

@ -363,7 +363,16 @@ def test_database_dump_and_restore():
select_test_tables(config)
subprocess.check_call(
['borgmatic', '-v', '2', '--config', config_path, 'rcreate', '--encryption', 'repokey']
[
'borgmatic',
'-v',
'2',
'--config',
config_path,
'repo-create',
'--encryption',
'repokey',
]
)
# Run borgmatic to generate a backup archive including database dumps.
@ -410,7 +419,16 @@ def test_database_dump_and_restore_with_restore_cli_flags():
select_test_tables(config)
subprocess.check_call(
['borgmatic', '-v', '2', '--config', config_path, 'rcreate', '--encryption', 'repokey']
[
'borgmatic',
'-v',
'2',
'--config',
config_path,
'repo-create',
'--encryption',
'repokey',
]
)
# Run borgmatic to generate a backup archive including a database dump.
@ -480,7 +498,16 @@ def test_database_dump_and_restore_with_restore_configuration_options():
select_test_tables(config)
subprocess.check_call(
['borgmatic', '-v', '2', '--config', config_path, 'rcreate', '--encryption', 'repokey']
[
'borgmatic',
'-v',
'2',
'--config',
config_path,
'repo-create',
'--encryption',
'repokey',
]
)
# Run borgmatic to generate a backup archive including a database dump.
@ -533,7 +560,16 @@ def test_database_dump_and_restore_with_directory_format():
select_test_tables(config)
subprocess.check_call(
['borgmatic', '-v', '2', '--config', config_path, 'rcreate', '--encryption', 'repokey']
[
'borgmatic',
'-v',
'2',
'--config',
config_path,
'repo-create',
'--encryption',
'repokey',
]
)
# Run borgmatic to generate a backup archive including a database dump.
@ -568,7 +604,16 @@ def test_database_dump_with_error_causes_borgmatic_to_exit():
)
subprocess.check_call(
['borgmatic', '-v', '2', '--config', config_path, 'rcreate', '--encryption', 'repokey']
[
'borgmatic',
'-v',
'2',
'--config',
config_path,
'repo-create',
'--encryption',
'repokey',
]
)
# Run borgmatic with a config override such that the database dump fails.

View file

@ -39,7 +39,7 @@ def test_override_get_normalized():
generate_configuration(config_path, repository_path)
subprocess.check_call(
f'borgmatic -v 2 --config {config_path} rcreate --encryption repokey'.split(' ')
f'borgmatic -v 2 --config {config_path} repo-create --encryption repokey'.split(' ')
)
# Run borgmatic with an override structured for an outdated config file format. If

View file

@ -7,7 +7,7 @@ import borgmatic.borg.info
import borgmatic.borg.list
import borgmatic.borg.mount
import borgmatic.borg.prune
import borgmatic.borg.rlist
import borgmatic.borg.repo_list
import borgmatic.borg.transfer
import borgmatic.commands.arguments
@ -133,14 +133,14 @@ def test_make_list_command_does_not_duplicate_flags_or_raise():
assert_command_does_not_duplicate_flags(command)
def test_make_rlist_command_does_not_duplicate_flags_or_raise():
arguments = borgmatic.commands.arguments.parse_arguments('rlist')['rlist']
def test_make_repo_list_command_does_not_duplicate_flags_or_raise():
arguments = borgmatic.commands.arguments.parse_arguments('repo-list')['repo-list']
for argument_name in dir(arguments):
if argument_name.startswith('_'):
continue
command = borgmatic.borg.rlist.make_rlist_command(
command = borgmatic.borg.repo_list.make_repo_list_command(
'repo',
{},
'2.3.4',

View file

@ -49,8 +49,8 @@ def test_parse_arguments_with_action_after_config_path_omits_aliased_action():
global_arguments = arguments['global']
assert global_arguments.config_paths == ['myconfig']
assert 'rcreate' in arguments
assert arguments['rcreate'].encryption_mode == 'repokey'
assert 'repo-create' in arguments
assert arguments['repo-create'].encryption_mode == 'repokey'
def test_parse_arguments_with_action_and_positional_arguments_after_config_path_omits_action_and_arguments():
@ -438,7 +438,7 @@ def test_parse_arguments_with_list_flag_but_no_relevant_action_raises_value_erro
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
with pytest.raises(SystemExit):
module.parse_arguments('--list', 'rcreate')
module.parse_arguments('--list', 'repo-create')
def test_parse_arguments_disallows_list_with_progress_for_create_action():
@ -469,18 +469,18 @@ def test_parse_arguments_disallows_json_with_both_list_and_info():
module.parse_arguments('list', 'info', '--json')
def test_parse_arguments_disallows_json_with_both_list_and_rinfo():
def test_parse_arguments_disallows_json_with_both_list_and_repo_info():
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
with pytest.raises(ValueError):
module.parse_arguments('list', 'rinfo', '--json')
module.parse_arguments('list', 'repo-info', '--json')
def test_parse_arguments_disallows_json_with_both_rinfo_and_info():
def test_parse_arguments_disallows_json_with_both_repo_info_and_info():
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
with pytest.raises(ValueError):
module.parse_arguments('rinfo', 'info', '--json')
module.parse_arguments('repo-info', 'info', '--json')
def test_parse_arguments_disallows_transfer_with_both_archive_and_match_archives():
@ -505,11 +505,11 @@ def test_parse_arguments_disallows_list_with_both_prefix_and_match_archives():
module.parse_arguments('list', '--prefix', 'foo', '--match-archives', 'sh:*bar')
def test_parse_arguments_disallows_rlist_with_both_prefix_and_match_archives():
def test_parse_arguments_disallows_repo_list_with_both_prefix_and_match_archives():
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
with pytest.raises(ValueError):
module.parse_arguments('rlist', '--prefix', 'foo', '--match-archives', 'sh:*bar')
module.parse_arguments('repo-list', '--prefix', 'foo', '--match-archives', 'sh:*bar')
def test_parse_arguments_disallows_info_with_both_archive_and_match_archives():

View file

@ -23,7 +23,7 @@ def test_get_config_paths_returns_list_of_config_paths():
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
extract_process
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
assert module.get_config_paths(bootstrap_arguments, global_arguments, local_borg_version) == [
@ -57,7 +57,7 @@ def test_get_config_paths_translates_ssh_command_argument_to_config():
object,
extract_to_stdout=True,
).and_return(extract_process)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').with_args(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').with_args(
'repo', 'archive', {'ssh_command': 'ssh -i key'}, object, object
).and_return('archive')
assert module.get_config_paths(bootstrap_arguments, global_arguments, local_borg_version) == [
@ -80,7 +80,7 @@ def test_get_config_paths_with_missing_manifest_raises_value_error():
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
extract_process
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
@ -105,7 +105,7 @@ def test_get_config_paths_with_broken_json_raises_value_error():
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
extract_process
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
@ -130,7 +130,7 @@ def test_get_config_paths_with_json_missing_key_raises_value_error():
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
extract_process
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
@ -161,7 +161,7 @@ def test_run_bootstrap_does_not_raise():
flexmock(module.borgmatic.borg.extract).should_receive('extract_archive').and_return(
extract_process
).once()
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
@ -201,7 +201,7 @@ def test_run_bootstrap_translates_ssh_command_argument_to_config():
strip_components=1,
progress=False,
).and_return(extract_process).once()
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').with_args(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').with_args(
'repo', 'archive', {'ssh_command': 'ssh -i key'}, object, object
).and_return('archive')

View file

@ -6,7 +6,7 @@ from borgmatic.actions import borg as module
def test_run_borg_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module.borgmatic.borg.borg).should_receive('run_arbitrary_borg')

View file

@ -932,7 +932,7 @@ def test_spot_check_with_count_delta_greater_than_count_tolerance_percentage_err
flexmock(module).should_receive('collect_spot_check_source_paths').and_return(
('/foo', '/bar', '/baz', '/quux')
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
flexmock(module).should_receive('collect_spot_check_archive_paths').and_return(
@ -963,7 +963,7 @@ def test_spot_check_with_failing_percentage_greater_than_data_tolerance_percenta
flexmock(module).should_receive('collect_spot_check_source_paths').and_return(
('/foo', '/bar', '/baz', '/quux')
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
flexmock(module).should_receive('collect_spot_check_archive_paths').and_return(('/foo', '/bar'))
@ -995,7 +995,7 @@ def test_spot_check_with_high_enough_tolerances_does_not_raise():
flexmock(module).should_receive('collect_spot_check_source_paths').and_return(
('/foo', '/bar', '/baz', '/quux')
)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
'archive'
)
flexmock(module).should_receive('collect_spot_check_archive_paths').and_return(('/foo', '/bar'))

View file

@ -6,7 +6,7 @@ from borgmatic.actions import delete as module
def test_run_delete_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name')
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name')
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
flexmock()
)
@ -26,7 +26,7 @@ def test_run_delete_does_not_raise():
def test_run_delete_without_archive_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name')
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name')
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
flexmock()
)

View file

@ -6,7 +6,7 @@ from borgmatic.actions import info as module
def test_run_info_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
@ -31,7 +31,7 @@ def test_run_info_does_not_raise():
def test_run_info_produces_json():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(

View file

@ -6,7 +6,7 @@ from borgmatic.actions import list as module
def test_run_list_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
@ -33,7 +33,7 @@ def test_run_list_does_not_raise():
def test_run_list_produces_json():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(

View file

@ -1,12 +1,12 @@
from flexmock import flexmock
from borgmatic.actions import rcreate as module
from borgmatic.actions import repo_create as module
def test_run_rcreate_does_not_raise():
def test_run_repo_create_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rcreate).should_receive('create_repository')
flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository')
arguments = flexmock(
encryption_mode=flexmock(),
source_repository=flexmock(),
@ -17,23 +17,23 @@ def test_run_rcreate_does_not_raise():
make_parent_dirs=flexmock(),
)
module.run_rcreate(
module.run_repo_create(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rcreate_arguments=arguments,
repo_create_arguments=arguments,
global_arguments=flexmock(dry_run=False),
local_path=None,
remote_path=None,
)
def test_run_rcreate_bails_if_repository_does_not_match():
def test_run_repo_create_bails_if_repository_does_not_match():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(
False
)
flexmock(module.borgmatic.borg.rcreate).should_receive('create_repository').never()
flexmock(module.borgmatic.borg.repo_create).should_receive('create_repository').never()
arguments = flexmock(
encryption_mode=flexmock(),
source_repository=flexmock(),
@ -44,11 +44,11 @@ def test_run_rcreate_bails_if_repository_does_not_match():
make_parent_dirs=flexmock(),
)
module.run_rcreate(
module.run_repo_create(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rcreate_arguments=arguments,
repo_create_arguments=arguments,
global_arguments=flexmock(dry_run=False),
local_path=None,
remote_path=None,

View file

@ -1,40 +1,40 @@
from flexmock import flexmock
from borgmatic.actions import rdelete as module
from borgmatic.actions import repo_delete as module
def test_run_rdelete_does_not_raise():
def test_run_repo_delete_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
flexmock()
)
flexmock(module.borgmatic.borg.rdelete).should_receive('delete_repository')
flexmock(module.borgmatic.borg.repo_delete).should_receive('delete_repository')
module.run_rdelete(
module.run_repo_delete(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rdelete_arguments=flexmock(repository=flexmock(), cache_only=False),
repo_delete_arguments=flexmock(repository=flexmock(), cache_only=False),
global_arguments=flexmock(),
local_path=None,
remote_path=None,
)
def test_run_rdelete_with_cache_only_does_not_raise():
def test_run_repo_delete_with_cache_only_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
flexmock()
)
flexmock(module.borgmatic.borg.rdelete).should_receive('delete_repository')
flexmock(module.borgmatic.borg.repo_delete).should_receive('delete_repository')
module.run_rdelete(
module.run_repo_delete(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rdelete_arguments=flexmock(repository=flexmock(), cache_only=True),
repo_delete_arguments=flexmock(repository=flexmock(), cache_only=True),
global_arguments=flexmock(),
local_path=None,
remote_path=None,

View file

@ -1,20 +1,20 @@
from flexmock import flexmock
from borgmatic.actions import rinfo as module
from borgmatic.actions import repo_info as module
def test_run_rinfo_does_not_raise():
def test_run_repo_info_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rinfo).should_receive('display_repository_info')
rinfo_arguments = flexmock(repository=flexmock(), json=False)
flexmock(module.borgmatic.borg.repo_info).should_receive('display_repository_info')
repo_info_arguments = flexmock(repository=flexmock(), json=False)
list(
module.run_rinfo(
module.run_repo_info(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rinfo_arguments=rinfo_arguments,
repo_info_arguments=repo_info_arguments,
global_arguments=flexmock(log_json=False),
local_path=None,
remote_path=None,
@ -22,22 +22,22 @@ def test_run_rinfo_does_not_raise():
)
def test_run_rinfo_parses_json():
def test_run_repo_info_parses_json():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rinfo).should_receive('display_repository_info').and_return(
flexmock(module.borgmatic.borg.repo_info).should_receive('display_repository_info').and_return(
flexmock()
)
parsed_json = flexmock()
flexmock(module.borgmatic.actions.json).should_receive('parse_json').and_return(parsed_json)
rinfo_arguments = flexmock(repository=flexmock(), json=True)
repo_info_arguments = flexmock(repository=flexmock(), json=True)
list(
module.run_rinfo(
module.run_repo_info(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rinfo_arguments=rinfo_arguments,
repo_info_arguments=repo_info_arguments,
global_arguments=flexmock(log_json=False),
local_path=None,
remote_path=None,

View file

@ -1,20 +1,20 @@
from flexmock import flexmock
from borgmatic.actions import rlist as module
from borgmatic.actions import repo_list as module
def test_run_rlist_does_not_raise():
def test_run_repo_list_does_not_raise():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('list_repository')
rlist_arguments = flexmock(repository=flexmock(), json=False)
flexmock(module.borgmatic.borg.repo_list).should_receive('list_repository')
repo_list_arguments = flexmock(repository=flexmock(), json=False)
list(
module.run_rlist(
module.run_repo_list(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rlist_arguments=rlist_arguments,
repo_list_arguments=repo_list_arguments,
global_arguments=flexmock(),
local_path=None,
remote_path=None,
@ -22,20 +22,22 @@ def test_run_rlist_does_not_raise():
)
def test_run_rlist_produces_json():
def test_run_repo_list_produces_json():
flexmock(module.logger).answer = lambda message: None
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.borg.rlist).should_receive('list_repository').and_return(flexmock())
flexmock(module.borgmatic.borg.repo_list).should_receive('list_repository').and_return(
flexmock()
)
parsed_json = flexmock()
flexmock(module.borgmatic.actions.json).should_receive('parse_json').and_return(parsed_json)
rlist_arguments = flexmock(repository=flexmock(), json=True)
repo_list_arguments = flexmock(repository=flexmock(), json=True)
assert list(
module.run_rlist(
module.run_repo_list(
repository={'path': 'repo'},
config={},
local_borg_version=None,
rlist_arguments=rlist_arguments,
repo_list_arguments=repo_list_arguments,
global_arguments=flexmock(),
local_path=None,
remote_path=None,

View file

@ -233,7 +233,7 @@ def test_run_restore_restores_each_data_source():
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks_even_if_unconfigured')
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
@ -315,7 +315,7 @@ def test_run_restore_restores_data_source_configured_with_all_name():
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks_even_if_unconfigured')
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
@ -393,7 +393,7 @@ def test_run_restore_skips_missing_data_source():
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks_even_if_unconfigured')
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
@ -472,7 +472,7 @@ def test_run_restore_restores_data_sources_from_different_hooks():
flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks_even_if_unconfigured')
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
flexmock(module.borgmatic.borg.repo_list).should_receive('resolve_archive_name').and_return(
flexmock()
)
flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())

View file

@ -284,7 +284,7 @@ def test_make_check_name_flags_with_repository_and_data_checks_does_not_return_r
def test_get_repository_id_with_valid_json_does_not_raise():
config = {}
flexmock(module.rinfo).should_receive('display_repository_info').and_return(
flexmock(module.repo_info).should_receive('display_repository_info').and_return(
'{"repository": {"id": "repo"}}'
)
@ -300,7 +300,7 @@ def test_get_repository_id_with_valid_json_does_not_raise():
def test_get_repository_id_with_json_error_raises():
config = {}
flexmock(module.rinfo).should_receive('display_repository_info').and_return(
flexmock(module.repo_info).should_receive('display_repository_info').and_return(
'{"unexpected": {"id": "repo"}}'
)
@ -317,7 +317,7 @@ def test_get_repository_id_with_json_error_raises():
def test_get_repository_id_with_missing_json_keys_raises():
config = {}
flexmock(module.rinfo).should_receive('display_repository_info').and_return('{invalid JSON')
flexmock(module.repo_info).should_receive('display_repository_info').and_return('{invalid JSON')
with pytest.raises(ValueError):
module.get_repository_id(

View file

@ -266,7 +266,7 @@ def test_make_delete_command_includes_match_archives():
def test_delete_archives_with_archive_calls_borg_delete():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.borgmatic.borg.rdelete).should_receive('delete_repository').never()
flexmock(module.borgmatic.borg.repo_delete).should_receive('delete_repository').never()
flexmock(module).should_receive('make_delete_command').and_return(flexmock())
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
flexmock()
@ -284,7 +284,7 @@ def test_delete_archives_with_archive_calls_borg_delete():
def test_delete_archives_with_match_archives_calls_borg_delete():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.borgmatic.borg.rdelete).should_receive('delete_repository').never()
flexmock(module.borgmatic.borg.repo_delete).should_receive('delete_repository').never()
flexmock(module).should_receive('make_delete_command').and_return(flexmock())
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
flexmock()
@ -303,7 +303,7 @@ def test_delete_archives_with_match_archives_calls_borg_delete():
@pytest.mark.parametrize('argument_name', module.ARCHIVE_RELATED_ARGUMENT_NAMES[2:])
def test_delete_archives_with_archive_related_argument_calls_borg_delete(argument_name):
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.borgmatic.borg.rdelete).should_receive('delete_repository').never()
flexmock(module.borgmatic.borg.repo_delete).should_receive('delete_repository').never()
flexmock(module).should_receive('make_delete_command').and_return(flexmock())
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
flexmock()
@ -319,10 +319,10 @@ def test_delete_archives_with_archive_related_argument_calls_borg_delete(argumen
)
def test_delete_archives_without_archive_related_argument_calls_borg_rdelete():
def test_delete_archives_without_archive_related_argument_calls_borg_repo_delete():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.rdelete).should_receive('delete_repository').once()
flexmock(module.borgmatic.borg.repo_delete).should_receive('delete_repository').once()
flexmock(module).should_receive('make_delete_command').never()
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').never()
flexmock(module.borgmatic.execute).should_receive('execute_command').never()

View file

@ -20,7 +20,7 @@ def insert_execute_command_mock(command, working_directory=None, borg_exit_codes
def test_extract_last_archive_dry_run_calls_borg_with_last_archive():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(('borg', 'extract', '--dry-run', 'repo::archive'))
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
('repo::archive',)
@ -36,7 +36,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_last_archive():
def test_extract_last_archive_dry_run_without_any_archives_should_not_raise():
flexmock(module.rlist).should_receive('resolve_archive_name').and_raise(ValueError)
flexmock(module.repo_list).should_receive('resolve_archive_name').and_raise(ValueError)
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(('repo',))
module.extract_last_archive_dry_run(
@ -49,7 +49,7 @@ def test_extract_last_archive_dry_run_without_any_archives_should_not_raise():
def test_extract_last_archive_dry_run_with_log_info_calls_borg_with_info_parameter():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(('borg', 'extract', '--dry-run', '--info', 'repo::archive'))
insert_logging_mock(logging.INFO)
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
@ -66,7 +66,7 @@ def test_extract_last_archive_dry_run_with_log_info_calls_borg_with_info_paramet
def test_extract_last_archive_dry_run_with_log_debug_calls_borg_with_debug_parameter():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(
('borg', 'extract', '--dry-run', '--debug', '--show-rc', '--list', 'repo::archive')
)
@ -85,7 +85,7 @@ def test_extract_last_archive_dry_run_with_log_debug_calls_borg_with_debug_param
def test_extract_last_archive_dry_run_calls_borg_via_local_path():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(('borg1', 'extract', '--dry-run', 'repo::archive'))
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
('repo::archive',)
@ -102,7 +102,7 @@ def test_extract_last_archive_dry_run_calls_borg_via_local_path():
def test_extract_last_archive_dry_run_calls_borg_using_exit_codes():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
borg_exit_codes = flexmock()
insert_execute_command_mock(
('borg', 'extract', '--dry-run', 'repo::archive'), borg_exit_codes=borg_exit_codes
@ -121,7 +121,7 @@ def test_extract_last_archive_dry_run_calls_borg_using_exit_codes():
def test_extract_last_archive_dry_run_calls_borg_with_remote_path_flags():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(
('borg', 'extract', '--dry-run', '--remote-path', 'borg1', 'repo::archive')
)
@ -140,7 +140,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_remote_path_flags():
def test_extract_last_archive_dry_run_calls_borg_with_log_json_flag():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(('borg', 'extract', '--dry-run', '--log-json', 'repo::archive'))
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
('repo::archive',)
@ -156,7 +156,7 @@ def test_extract_last_archive_dry_run_calls_borg_with_log_json_flag():
def test_extract_last_archive_dry_run_calls_borg_with_lock_wait_flags():
flexmock(module.rlist).should_receive('resolve_archive_name').and_return('archive')
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
insert_execute_command_mock(
('borg', 'extract', '--dry-run', '--lock-wait', '5', 'repo::archive')
)

View file

@ -474,7 +474,9 @@ def test_list_archive_calls_borg_multiple_times_with_find_paths():
)
flexmock(module.feature).should_receive('available').and_return(False)
flexmock(module.rlist).should_receive('make_rlist_command').and_return(('borg', 'list', 'repo'))
flexmock(module.repo_list).should_receive('make_repo_list_command').and_return(
('borg', 'list', 'repo')
)
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'list', 'repo'),
extra_environment=None,
@ -574,7 +576,7 @@ def test_list_archive_without_archive_delegates_to_list_repository():
)
flexmock(module.feature).should_receive('available').and_return(False)
flexmock(module.rlist).should_receive('list_repository')
flexmock(module.repo_list).should_receive('list_repository')
flexmock(module.environment).should_receive('make_environment').never()
flexmock(module).should_receive('execute_command').never()
@ -605,7 +607,7 @@ def test_list_archive_with_borg_features_without_archive_delegates_to_list_repos
)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.rlist).should_receive('list_repository')
flexmock(module.repo_list).should_receive('list_repository')
flexmock(module.environment).should_receive('make_environment').never()
flexmock(module).should_receive('execute_command').never()
@ -645,7 +647,7 @@ def test_list_archive_with_archive_ignores_archive_filter_flag(
altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
flexmock(module.feature).should_receive('available').with_args(
module.feature.Feature.RLIST, '1.2.3'
module.feature.Feature.REPO_LIST, '1.2.3'
).and_return(False)
flexmock(module).should_receive('make_list_command').with_args(
repository_path='repo',
@ -689,7 +691,7 @@ def test_list_archive_with_archive_ignores_archive_filter_flag(
'last',
),
)
def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes_it_to_rlist(
def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes_it_to_repo_list(
archive_filter_flag,
):
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
@ -707,20 +709,20 @@ def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes
global_arguments = flexmock(log_json=False)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.rlist).should_receive('make_rlist_command').with_args(
flexmock(module.repo_list).should_receive('make_repo_list_command').with_args(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=argparse.Namespace(
repo_list_arguments=argparse.Namespace(
repository='repo', short=True, format=None, json=None, **altered_filter_flags
),
global_arguments=global_arguments,
local_path='borg',
remote_path=None,
).and_return(('borg', 'rlist', '--repo', 'repo'))
).and_return(('borg', 'repo-list', '--repo', 'repo'))
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rlist', '--repo', 'repo'),
('borg', 'repo-list', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,

View file

@ -4,40 +4,42 @@ import subprocess
import pytest
from flexmock import flexmock
from borgmatic.borg import rcreate as module
from borgmatic.borg import repo_create as module
from ..test_verbosity import insert_logging_mock
RINFO_SOME_UNKNOWN_EXIT_CODE = -999
RCREATE_COMMAND = ('borg', 'rcreate', '--encryption', 'repokey')
REPO_INFO_SOME_UNKNOWN_EXIT_CODE = -999
REPO_CREATE_COMMAND = ('borg', 'repo-create', '--encryption', 'repokey')
def insert_rinfo_command_found_mock():
flexmock(module.rinfo).should_receive('display_repository_info').and_return(
def insert_repo_info_command_found_mock():
flexmock(module.repo_info).should_receive('display_repository_info').and_return(
'{"encryption": {"mode": "repokey"}}'
)
def insert_rinfo_command_not_found_mock():
flexmock(module.rinfo).should_receive('display_repository_info').and_raise(
subprocess.CalledProcessError(sorted(module.RINFO_REPOSITORY_NOT_FOUND_EXIT_CODES)[0], [])
def insert_repo_info_command_not_found_mock():
flexmock(module.repo_info).should_receive('display_repository_info').and_raise(
subprocess.CalledProcessError(
sorted(module.REPO_INFO_REPOSITORY_NOT_FOUND_EXIT_CODES)[0], []
)
)
def insert_rcreate_command_mock(rcreate_command, borg_exit_codes=None, **kwargs):
def insert_repo_create_command_mock(repo_create_command, borg_exit_codes=None, **kwargs):
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command').with_args(
rcreate_command,
repo_create_command,
output_file=module.DO_NOT_CAPTURE,
borg_local_path=rcreate_command[0],
borg_local_path=repo_create_command[0],
borg_exit_codes=borg_exit_codes,
extra_environment=None,
).once()
def test_create_repository_calls_borg_with_flags():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -57,7 +59,7 @@ def test_create_repository_calls_borg_with_flags():
def test_create_repository_with_dry_run_skips_borg_call():
insert_rinfo_command_not_found_mock()
insert_repo_info_command_not_found_mock()
flexmock(module).should_receive('execute_command').never()
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
@ -77,8 +79,8 @@ def test_create_repository_with_dry_run_skips_borg_call():
)
def test_create_repository_raises_for_borg_rcreate_error():
insert_rinfo_command_not_found_mock()
def test_create_repository_raises_for_borg_repo_create_error():
insert_repo_info_command_not_found_mock()
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -88,7 +90,7 @@ def test_create_repository_raises_for_borg_rcreate_error():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command').and_raise(
module.subprocess.CalledProcessError(2, 'borg rcreate')
module.subprocess.CalledProcessError(2, 'borg repo_create')
)
with pytest.raises(subprocess.CalledProcessError):
@ -103,7 +105,7 @@ def test_create_repository_raises_for_borg_rcreate_error():
def test_create_repository_skips_creation_when_repository_already_exists():
insert_rinfo_command_found_mock()
insert_repo_info_command_found_mock()
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -123,7 +125,7 @@ def test_create_repository_skips_creation_when_repository_already_exists():
def test_create_repository_errors_when_repository_with_differing_encryption_mode_already_exists():
insert_rinfo_command_found_mock()
insert_repo_info_command_found_mock()
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -143,9 +145,9 @@ def test_create_repository_errors_when_repository_with_differing_encryption_mode
)
def test_create_repository_raises_for_unknown_rinfo_command_error():
flexmock(module.rinfo).should_receive('display_repository_info').and_raise(
subprocess.CalledProcessError(RINFO_SOME_UNKNOWN_EXIT_CODE, [])
def test_create_repository_raises_for_unknown_repo_info_command_error():
flexmock(module.repo_info).should_receive('display_repository_info').and_raise(
subprocess.CalledProcessError(REPO_INFO_SOME_UNKNOWN_EXIT_CODE, [])
)
with pytest.raises(subprocess.CalledProcessError):
@ -160,8 +162,10 @@ def test_create_repository_raises_for_unknown_rinfo_command_error():
def test_create_repository_with_source_repository_calls_borg_with_other_repo_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--other-repo', 'other.borg', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(
REPO_CREATE_COMMAND + ('--other-repo', 'other.borg', '--repo', 'repo')
)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -182,8 +186,8 @@ def test_create_repository_with_source_repository_calls_borg_with_other_repo_fla
def test_create_repository_with_copy_crypt_key_calls_borg_with_copy_crypt_key_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--copy-crypt-key', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--copy-crypt-key', '--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -204,8 +208,8 @@ def test_create_repository_with_copy_crypt_key_calls_borg_with_copy_crypt_key_fl
def test_create_repository_with_append_only_calls_borg_with_append_only_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--append-only', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--append-only', '--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -226,8 +230,10 @@ def test_create_repository_with_append_only_calls_borg_with_append_only_flag():
def test_create_repository_with_storage_quota_calls_borg_with_storage_quota_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--storage-quota', '5G', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(
REPO_CREATE_COMMAND + ('--storage-quota', '5G', '--repo', 'repo')
)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -248,8 +254,8 @@ def test_create_repository_with_storage_quota_calls_borg_with_storage_quota_flag
def test_create_repository_with_make_parent_dirs_calls_borg_with_make_parent_dirs_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--make-parent-dirs', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--make-parent-dirs', '--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -270,8 +276,8 @@ def test_create_repository_with_make_parent_dirs_calls_borg_with_make_parent_dir
def test_create_repository_with_log_info_calls_borg_with_info_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--info', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--info', '--repo', 'repo'))
insert_logging_mock(logging.INFO)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
@ -292,8 +298,8 @@ def test_create_repository_with_log_info_calls_borg_with_info_flag():
def test_create_repository_with_log_debug_calls_borg_with_debug_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--debug', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--debug', '--repo', 'repo'))
insert_logging_mock(logging.DEBUG)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
@ -314,8 +320,8 @@ def test_create_repository_with_log_debug_calls_borg_with_debug_flag():
def test_create_repository_with_log_json_calls_borg_with_log_json_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--log-json', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--log-json', '--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -335,8 +341,8 @@ def test_create_repository_with_log_json_calls_borg_with_log_json_flag():
def test_create_repository_with_lock_wait_calls_borg_with_lock_wait_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--lock-wait', '5', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(REPO_CREATE_COMMAND + ('--lock-wait', '5', '--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -356,8 +362,8 @@ def test_create_repository_with_lock_wait_calls_borg_with_lock_wait_flag():
def test_create_repository_with_local_path_calls_borg_via_local_path():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(('borg1',) + RCREATE_COMMAND[1:] + ('--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(('borg1',) + REPO_CREATE_COMMAND[1:] + ('--repo', 'repo'))
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -379,9 +385,9 @@ def test_create_repository_with_local_path_calls_borg_via_local_path():
def test_create_repository_with_exit_codes_calls_borg_using_them():
borg_exit_codes = flexmock()
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(
('borg',) + RCREATE_COMMAND[1:] + ('--repo', 'repo'), borg_exit_codes=borg_exit_codes
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(
('borg',) + REPO_CREATE_COMMAND[1:] + ('--repo', 'repo'), borg_exit_codes=borg_exit_codes
)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
@ -402,8 +408,10 @@ def test_create_repository_with_exit_codes_calls_borg_using_them():
def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--remote-path', 'borg1', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(
REPO_CREATE_COMMAND + ('--remote-path', 'borg1', '--repo', 'repo')
)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -424,8 +432,10 @@ def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
def test_create_repository_with_extra_borg_options_calls_borg_with_extra_options():
insert_rinfo_command_not_found_mock()
insert_rcreate_command_mock(RCREATE_COMMAND + ('--extra', '--options', '--repo', 'repo'))
insert_repo_info_command_not_found_mock()
insert_repo_create_command_mock(
REPO_CREATE_COMMAND + ('--extra', '--options', '--repo', 'repo')
)
flexmock(module.feature).should_receive('available').and_return(True)
flexmock(module.flags).should_receive('make_repository_flags').and_return(
(
@ -437,7 +447,7 @@ def test_create_repository_with_extra_borg_options_calls_borg_with_extra_options
module.create_repository(
dry_run=False,
repository_path='repo',
config={'extra_borg_options': {'rcreate': '--extra --options'}},
config={'extra_borg_options': {'repo-create': '--extra --options'}},
local_borg_version='2.3.4',
global_arguments=flexmock(log_json=False),
encryption_mode='repokey',

View file

@ -2,12 +2,12 @@ import logging
from flexmock import flexmock
from borgmatic.borg import rdelete as module
from borgmatic.borg import repo_delete as module
from ..test_verbosity import insert_logging_mock
def test_make_rdelete_command_with_feature_available_runs_borg_rdelete():
def test_make_repo_delete_command_with_feature_available_runs_borg_repo_delete():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
@ -15,20 +15,20 @@ def test_make_rdelete_command_with_feature_available_runs_borg_rdelete():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', 'repo')
assert command == ('borg', 'repo-delete', 'repo')
def test_make_rdelete_command_without_feature_available_runs_borg_delete():
def test_make_repo_delete_command_without_feature_available_runs_borg_delete():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(False)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
@ -36,11 +36,11 @@ def test_make_rdelete_command_without_feature_available_runs_borg_delete():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
@ -49,7 +49,7 @@ def test_make_rdelete_command_without_feature_available_runs_borg_delete():
assert command == ('borg', 'delete', 'repo')
def test_make_rdelete_command_includes_log_info():
def test_make_repo_delete_command_includes_log_info():
insert_logging_mock(logging.INFO)
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
@ -58,20 +58,20 @@ def test_make_rdelete_command_includes_log_info():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--info', 'repo')
assert command == ('borg', 'repo-delete', '--info', 'repo')
def test_make_rdelete_command_includes_log_debug():
def test_make_repo_delete_command_includes_log_debug():
insert_logging_mock(logging.DEBUG)
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
@ -80,20 +80,20 @@ def test_make_rdelete_command_includes_log_debug():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--debug', '--show-rc', 'repo')
assert command == ('borg', 'repo-delete', '--debug', '--show-rc', 'repo')
def test_make_rdelete_command_includes_dry_run():
def test_make_repo_delete_command_includes_dry_run():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
@ -104,20 +104,20 @@ def test_make_rdelete_command_includes_dry_run():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=True, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--dry-run', 'repo')
assert command == ('borg', 'repo-delete', '--dry-run', 'repo')
def test_make_rdelete_command_includes_remote_path():
def test_make_repo_delete_command_includes_remote_path():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
@ -128,20 +128,20 @@ def test_make_rdelete_command_includes_remote_path():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path='borg1',
)
assert command == ('borg', 'rdelete', '--remote-path', 'borg1', 'repo')
assert command == ('borg', 'repo-delete', '--remote-path', 'borg1', 'repo')
def test_make_rdelete_command_includes_log_json():
def test_make_repo_delete_command_includes_log_json():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
@ -152,20 +152,20 @@ def test_make_rdelete_command_includes_log_json():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=True),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--log-json', 'repo')
assert command == ('borg', 'repo-delete', '--log-json', 'repo')
def test_make_rdelete_command_includes_lock_wait():
def test_make_repo_delete_command_includes_lock_wait():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
@ -176,20 +176,20 @@ def test_make_rdelete_command_includes_lock_wait():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={'lock_wait': 5},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=0),
repo_delete_arguments=flexmock(list_archives=False, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--lock-wait', '5', 'repo')
assert command == ('borg', 'repo-delete', '--lock-wait', '5', 'repo')
def test_make_rdelete_command_includes_list():
def test_make_repo_delete_command_includes_list():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
@ -200,20 +200,20 @@ def test_make_rdelete_command_includes_list():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=True, force=0),
repo_delete_arguments=flexmock(list_archives=True, force=0),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--list', 'repo')
assert command == ('borg', 'repo-delete', '--list', 'repo')
def test_make_rdelete_command_includes_force():
def test_make_repo_delete_command_includes_force():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
@ -221,20 +221,20 @@ def test_make_rdelete_command_includes_force():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=1),
repo_delete_arguments=flexmock(list_archives=False, force=1),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--force', 'repo')
assert command == ('borg', 'repo-delete', '--force', 'repo')
def test_make_rdelete_command_includes_force_twice():
def test_make_repo_delete_command_includes_force_twice():
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
@ -242,23 +242,23 @@ def test_make_rdelete_command_includes_force_twice():
('repo',)
)
command = module.make_rdelete_command(
command = module.make_repo_delete_command(
repository={'path': 'repo'},
config={},
local_borg_version='1.2.3',
rdelete_arguments=flexmock(list_archives=False, force=2),
repo_delete_arguments=flexmock(list_archives=False, force=2),
global_arguments=flexmock(dry_run=False, log_json=False),
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rdelete', '--force', '--force', 'repo')
assert command == ('borg', 'repo-delete', '--force', '--force', 'repo')
def test_delete_repository_with_defaults_does_not_capture_output():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
command = flexmock()
flexmock(module).should_receive('make_rdelete_command').and_return(command)
flexmock(module).should_receive('make_repo_delete_command').and_return(command)
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
flexmock()
)
@ -275,7 +275,7 @@ def test_delete_repository_with_defaults_does_not_capture_output():
repository={'path': 'repo'},
config={},
local_borg_version=flexmock(),
rdelete_arguments=flexmock(force=False, cache_only=False),
repo_delete_arguments=flexmock(force=False, cache_only=False),
global_arguments=flexmock(),
local_path='borg',
remote_path=None,
@ -285,7 +285,7 @@ def test_delete_repository_with_defaults_does_not_capture_output():
def test_delete_repository_with_force_captures_output():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
command = flexmock()
flexmock(module).should_receive('make_rdelete_command').and_return(command)
flexmock(module).should_receive('make_repo_delete_command').and_return(command)
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
flexmock()
)
@ -302,7 +302,7 @@ def test_delete_repository_with_force_captures_output():
repository={'path': 'repo'},
config={},
local_borg_version=flexmock(),
rdelete_arguments=flexmock(force=True, cache_only=False),
repo_delete_arguments=flexmock(force=True, cache_only=False),
global_arguments=flexmock(),
local_path='borg',
remote_path=None,
@ -312,7 +312,7 @@ def test_delete_repository_with_force_captures_output():
def test_delete_repository_with_cache_only_captures_output():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
command = flexmock()
flexmock(module).should_receive('make_rdelete_command').and_return(command)
flexmock(module).should_receive('make_repo_delete_command').and_return(command)
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
flexmock()
)
@ -329,7 +329,7 @@ def test_delete_repository_with_cache_only_captures_output():
repository={'path': 'repo'},
config={},
local_borg_version=flexmock(),
rdelete_arguments=flexmock(force=False, cache_only=True),
repo_delete_arguments=flexmock(force=False, cache_only=True),
global_arguments=flexmock(),
local_path='borg',
remote_path=None,

View file

@ -2,7 +2,7 @@ import logging
from flexmock import flexmock
from borgmatic.borg import rinfo as module
from borgmatic.borg import repo_info as module
from ..test_verbosity import insert_logging_mock
@ -19,14 +19,14 @@ def test_display_repository_info_calls_borg_with_flags():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--json', '--repo', 'repo'),
borg_local_path='borg',
borg_exit_codes=None,
extra_environment=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--repo', 'repo'),
('borg', 'repo-info', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=None,
@ -37,7 +37,7 @@ def test_display_repository_info_calls_borg_with_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
)
@ -49,7 +49,7 @@ def test_display_repository_info_without_borg_features_calls_borg_with_info_sub_
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--json', 'repo'),
('borg', 'repo-info', '--json', 'repo'),
borg_local_path='borg',
borg_exit_codes=None,
extra_environment=None,
@ -67,7 +67,7 @@ def test_display_repository_info_without_borg_features_calls_borg_with_info_sub_
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
)
@ -84,14 +84,14 @@ def test_display_repository_info_with_log_info_calls_borg_with_info_flag():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--info', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--info', '--json', '--repo', 'repo'),
borg_local_path='borg',
borg_exit_codes=None,
extra_environment=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--info', '--repo', 'repo'),
('borg', 'repo-info', '--info', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=None,
@ -102,7 +102,7 @@ def test_display_repository_info_with_log_info_calls_borg_with_info_flag():
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
)
@ -119,7 +119,7 @@ def test_display_repository_info_with_log_info_and_json_suppresses_most_borg_out
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
@ -131,7 +131,7 @@ def test_display_repository_info_with_log_info_and_json_suppresses_most_borg_out
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=True),
repo_info_arguments=flexmock(json=True),
global_arguments=flexmock(log_json=False),
)
@ -150,14 +150,14 @@ def test_display_repository_info_with_log_debug_calls_borg_with_debug_flag():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--debug', '--show-rc', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--debug', '--show-rc', '--json', '--repo', 'repo'),
borg_local_path='borg',
borg_exit_codes=None,
extra_environment=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--debug', '--show-rc', '--repo', 'repo'),
('borg', 'repo-info', '--debug', '--show-rc', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=None,
@ -169,7 +169,7 @@ def test_display_repository_info_with_log_debug_calls_borg_with_debug_flag():
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
)
@ -186,7 +186,7 @@ def test_display_repository_info_with_log_debug_and_json_suppresses_most_borg_ou
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
@ -198,7 +198,7 @@ def test_display_repository_info_with_log_debug_and_json_suppresses_most_borg_ou
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=True),
repo_info_arguments=flexmock(json=True),
global_arguments=flexmock(log_json=False),
)
@ -217,7 +217,7 @@ def test_display_repository_info_with_json_calls_borg_with_json_flag():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
@ -228,7 +228,7 @@ def test_display_repository_info_with_json_calls_borg_with_json_flag():
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=True),
repo_info_arguments=flexmock(json=True),
global_arguments=flexmock(log_json=False),
)
@ -247,14 +247,14 @@ def test_display_repository_info_with_local_path_calls_borg_via_local_path():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg1', 'rinfo', '--json', '--repo', 'repo'),
('borg1', 'repo-info', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg1', 'rinfo', '--repo', 'repo'),
('borg1', 'repo-info', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg1',
borg_exit_codes=None,
@ -265,7 +265,7 @@ def test_display_repository_info_with_local_path_calls_borg_via_local_path():
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
local_path='borg1',
)
@ -284,14 +284,14 @@ def test_display_repository_info_with_exit_codes_calls_borg_using_them():
flexmock(module.environment).should_receive('make_environment')
borg_exit_codes = flexmock()
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=borg_exit_codes,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--repo', 'repo'),
('borg', 'repo-info', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=borg_exit_codes,
@ -302,7 +302,7 @@ def test_display_repository_info_with_exit_codes_calls_borg_using_them():
repository_path='repo',
config={'borg_exit_codes': borg_exit_codes},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
)
@ -319,14 +319,14 @@ def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_fl
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--remote-path', 'borg1', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--remote-path', 'borg1', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--remote-path', 'borg1', '--repo', 'repo'),
('borg', 'repo-info', '--remote-path', 'borg1', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=None,
@ -337,7 +337,7 @@ def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_fl
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
remote_path='borg1',
)
@ -355,14 +355,14 @@ def test_display_repository_info_with_log_json_calls_borg_with_log_json_flags():
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--log-json', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--log-json', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--log-json', '--repo', 'repo'),
('borg', 'repo-info', '--log-json', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=None,
@ -373,7 +373,7 @@ def test_display_repository_info_with_log_json_calls_borg_with_log_json_flags():
repository_path='repo',
config={},
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=True),
)
@ -391,14 +391,14 @@ def test_display_repository_info_with_lock_wait_calls_borg_with_lock_wait_flags(
)
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
('borg', 'rinfo', '--lock-wait', '5', '--json', '--repo', 'repo'),
('borg', 'repo-info', '--lock-wait', '5', '--json', '--repo', 'repo'),
extra_environment=None,
borg_local_path='borg',
borg_exit_codes=None,
).and_return('[]')
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
flexmock(module).should_receive('execute_command').with_args(
('borg', 'rinfo', '--lock-wait', '5', '--repo', 'repo'),
('borg', 'repo-info', '--lock-wait', '5', '--repo', 'repo'),
output_log_level=module.borgmatic.logger.ANSWER,
borg_local_path='borg',
borg_exit_codes=None,
@ -409,6 +409,6 @@ def test_display_repository_info_with_lock_wait_calls_borg_with_lock_wait_flags(
repository_path='repo',
config=config,
local_borg_version='2.3.4',
rinfo_arguments=flexmock(json=False),
repo_info_arguments=flexmock(json=False),
global_arguments=flexmock(log_json=False),
)

View file

@ -4,7 +4,7 @@ import logging
import pytest
from flexmock import flexmock
from borgmatic.borg import rlist as module
from borgmatic.borg import repo_list as module
from ..test_verbosity import insert_logging_mock
@ -233,7 +233,7 @@ def test_resolve_archive_name_with_lock_wait_calls_borg_with_lock_wait_flags():
)
def test_make_rlist_command_includes_log_info():
def test_make_repo_list_command_includes_log_info():
insert_logging_mock(logging.INFO)
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
@ -242,11 +242,11 @@ def test_make_rlist_command_includes_log_info():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -255,7 +255,7 @@ def test_make_rlist_command_includes_log_info():
assert command == ('borg', 'list', '--info', 'repo')
def test_make_rlist_command_includes_json_but_not_info():
def test_make_repo_list_command_includes_json_but_not_info():
insert_logging_mock(logging.INFO)
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
@ -264,11 +264,11 @@ def test_make_rlist_command_includes_json_but_not_info():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=True, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -277,7 +277,7 @@ def test_make_rlist_command_includes_json_but_not_info():
assert command == ('borg', 'list', '--json', 'repo')
def test_make_rlist_command_includes_log_debug():
def test_make_repo_list_command_includes_log_debug():
insert_logging_mock(logging.DEBUG)
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
@ -286,11 +286,11 @@ def test_make_rlist_command_includes_log_debug():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -299,7 +299,7 @@ def test_make_rlist_command_includes_log_debug():
assert command == ('borg', 'list', '--debug', '--show-rc', 'repo')
def test_make_rlist_command_includes_json_but_not_debug():
def test_make_repo_list_command_includes_json_but_not_debug():
insert_logging_mock(logging.DEBUG)
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
@ -308,11 +308,11 @@ def test_make_rlist_command_includes_json_but_not_debug():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=True, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -321,7 +321,7 @@ def test_make_rlist_command_includes_json_but_not_debug():
assert command == ('borg', 'list', '--json', 'repo')
def test_make_rlist_command_includes_json():
def test_make_repo_list_command_includes_json():
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, None, '1.2.3'
@ -329,11 +329,11 @@ def test_make_rlist_command_includes_json():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=True, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -342,7 +342,7 @@ def test_make_rlist_command_includes_json():
assert command == ('borg', 'list', '--json', 'repo')
def test_make_rlist_command_includes_log_json():
def test_make_repo_list_command_includes_log_json():
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(
('--log-json',)
).and_return(())
@ -352,11 +352,11 @@ def test_make_rlist_command_includes_log_json():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=True),
@ -365,7 +365,7 @@ def test_make_rlist_command_includes_log_json():
assert command == ('borg', 'list', '--log-json', 'repo')
def test_make_rlist_command_includes_lock_wait():
def test_make_repo_list_command_includes_lock_wait():
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(
('--lock-wait', '5')
).and_return(())
@ -375,11 +375,11 @@ def test_make_rlist_command_includes_lock_wait():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={'lock_wait': 5},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -388,7 +388,7 @@ def test_make_rlist_command_includes_lock_wait():
assert command == ('borg', 'list', '--lock-wait', '5', 'repo')
def test_make_rlist_command_includes_local_path():
def test_make_repo_list_command_includes_local_path():
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, None, '1.2.3'
@ -396,11 +396,11 @@ def test_make_rlist_command_includes_local_path():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -410,7 +410,7 @@ def test_make_rlist_command_includes_local_path():
assert command == ('borg2', 'list', 'repo')
def test_make_rlist_command_includes_remote_path():
def test_make_repo_list_command_includes_remote_path():
flexmock(module.flags).should_receive('make_flags').and_return(
('--remote-path', 'borg2')
).and_return(()).and_return(())
@ -420,11 +420,11 @@ def test_make_rlist_command_includes_remote_path():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -434,7 +434,7 @@ def test_make_rlist_command_includes_remote_path():
assert command == ('borg', 'list', '--remote-path', 'borg2', 'repo')
def test_make_rlist_command_transforms_prefix_into_match_archives():
def test_make_repo_list_command_transforms_prefix_into_match_archives():
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(()).and_return(
('--match-archives', 'sh:foo*')
)
@ -444,18 +444,18 @@ def test_make_rlist_command_transforms_prefix_into_match_archives():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
repo_list_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
global_arguments=flexmock(log_json=False),
)
assert command == ('borg', 'list', '--match-archives', 'sh:foo*', 'repo')
def test_make_rlist_command_prefers_prefix_over_archive_name_format():
def test_make_repo_list_command_prefers_prefix_over_archive_name_format():
flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(()).and_return(
('--match-archives', 'sh:foo*')
)
@ -463,18 +463,18 @@ def test_make_rlist_command_prefers_prefix_over_archive_name_format():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={'archive_name_format': 'bar-{now}'}, # noqa: FS003
local_borg_version='1.2.3',
rlist_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
repo_list_arguments=flexmock(archive=None, paths=None, json=False, prefix='foo'),
global_arguments=flexmock(log_json=False),
)
assert command == ('borg', 'list', '--match-archives', 'sh:foo*', 'repo')
def test_make_rlist_command_transforms_archive_name_format_into_match_archives():
def test_make_repo_list_command_transforms_archive_name_format_into_match_archives():
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, 'bar-{now}', '1.2.3' # noqa: FS003
@ -482,11 +482,11 @@ def test_make_rlist_command_transforms_archive_name_format_into_match_archives()
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={'archive_name_format': 'bar-{now}'}, # noqa: FS003
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None
),
global_arguments=flexmock(log_json=False),
@ -495,7 +495,7 @@ def test_make_rlist_command_transforms_archive_name_format_into_match_archives()
assert command == ('borg', 'list', '--match-archives', 'sh:bar-*', 'repo')
def test_make_rlist_command_includes_short():
def test_make_repo_list_command_includes_short():
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, None, '1.2.3'
@ -503,11 +503,11 @@ def test_make_rlist_command_includes_short():
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--short',))
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None, paths=None, json=False, prefix=None, match_archives=None, short=True
),
global_arguments=flexmock(log_json=False),
@ -528,7 +528,7 @@ def test_make_rlist_command_includes_short():
'patterns_from',
),
)
def test_make_rlist_command_includes_additional_flags(argument_name):
def test_make_repo_list_command_includes_additional_flags(argument_name):
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, None, '1.2.3'
@ -538,11 +538,11 @@ 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(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None,
paths=None,
json=False,
@ -558,7 +558,7 @@ def test_make_rlist_command_includes_additional_flags(argument_name):
assert command == ('borg', 'list', '--' + argument_name.replace('_', '-'), 'value', 'repo')
def test_make_rlist_command_with_match_archives_calls_borg_with_match_archives_flags():
def test_make_repo_list_command_with_match_archives_calls_borg_with_match_archives_flags():
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, None, '1.2.3'
@ -571,11 +571,11 @@ def test_make_rlist_command_with_match_archives_calls_borg_with_match_archives_f
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None,
paths=None,
json=False,
@ -592,7 +592,7 @@ def test_make_rlist_command_with_match_archives_calls_borg_with_match_archives_f
def test_list_repository_calls_two_commands():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module).should_receive('make_rlist_command')
flexmock(module).should_receive('make_repo_list_command')
flexmock(module.environment).should_receive('make_environment')
flexmock(module).should_receive('execute_command_and_capture_output').once()
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
@ -602,14 +602,14 @@ def test_list_repository_calls_two_commands():
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=argparse.Namespace(json=False),
repo_list_arguments=argparse.Namespace(json=False),
global_arguments=flexmock(),
)
def test_list_repository_with_json_calls_json_command_only():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module).should_receive('make_rlist_command')
flexmock(module).should_receive('make_repo_list_command')
flexmock(module.environment).should_receive('make_environment')
json_output = flexmock()
flexmock(module).should_receive('execute_command_and_capture_output').and_return(json_output)
@ -621,14 +621,14 @@ def test_list_repository_with_json_calls_json_command_only():
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=argparse.Namespace(json=True),
repo_list_arguments=argparse.Namespace(json=True),
global_arguments=flexmock(),
)
== json_output
)
def test_make_rlist_command_with_date_based_matching_calls_borg_with_date_based_flags():
def test_make_repo_list_command_with_date_based_matching_calls_borg_with_date_based_flags():
flexmock(module.flags).should_receive('make_flags').and_return(())
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
None, None, '1.2.3'
@ -638,11 +638,11 @@ def test_make_rlist_command_with_date_based_matching_calls_borg_with_date_based_
)
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
command = module.make_rlist_command(
command = module.make_repo_list_command(
repository_path='repo',
config={},
local_borg_version='1.2.3',
rlist_arguments=flexmock(
repo_list_arguments=flexmock(
archive=None,
paths=None,
json=False,

View file

@ -467,15 +467,18 @@ def test_run_configuration_retries_timeout_multiple_repos():
assert results == error_logs
def test_run_actions_runs_rcreate():
def test_run_actions_runs_repo_create():
flexmock(module).should_receive('add_custom_log_levels')
flexmock(module).should_receive('get_skip_actions').and_return([])
flexmock(module.command).should_receive('execute_hook')
flexmock(borgmatic.actions.rcreate).should_receive('run_rcreate').once()
flexmock(borgmatic.actions.repo_create).should_receive('run_repo_create').once()
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'rcreate': flexmock()},
arguments={
'global': flexmock(dry_run=False, log_file='foo'),
'repo-create': flexmock(),
},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@ -850,16 +853,16 @@ def test_run_actions_runs_restore():
)
def test_run_actions_runs_rlist():
def test_run_actions_runs_repo_list():
flexmock(module).should_receive('add_custom_log_levels')
flexmock(module).should_receive('get_skip_actions').and_return([])
flexmock(module.command).should_receive('execute_hook')
expected = flexmock()
flexmock(borgmatic.actions.rlist).should_receive('run_rlist').and_yield(expected).once()
flexmock(borgmatic.actions.repo_list).should_receive('run_repo_list').and_yield(expected).once()
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'rlist': flexmock()},
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'repo-list': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@ -894,16 +897,16 @@ def test_run_actions_runs_list():
assert result == (expected,)
def test_run_actions_runs_rinfo():
def test_run_actions_runs_repo_info():
flexmock(module).should_receive('add_custom_log_levels')
flexmock(module).should_receive('get_skip_actions').and_return([])
flexmock(module.command).should_receive('execute_hook')
expected = flexmock()
flexmock(borgmatic.actions.rinfo).should_receive('run_rinfo').and_yield(expected).once()
flexmock(borgmatic.actions.repo_info).should_receive('run_repo_info').and_yield(expected).once()
result = tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'rinfo': flexmock()},
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'repo-info': flexmock()},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],
@ -998,15 +1001,18 @@ def test_run_actions_runs_delete():
)
def test_run_actions_runs_rdelete():
def test_run_actions_runs_repo_delete():
flexmock(module).should_receive('add_custom_log_levels')
flexmock(module).should_receive('get_skip_actions').and_return([])
flexmock(module.command).should_receive('execute_hook')
flexmock(borgmatic.actions.rdelete).should_receive('run_rdelete').once()
flexmock(borgmatic.actions.repo_delete).should_receive('run_repo_delete').once()
tuple(
module.run_actions(
arguments={'global': flexmock(dry_run=False, log_file='foo'), 'rdelete': flexmock()},
arguments={
'global': flexmock(dry_run=False, log_file='foo'),
'repo-delete': flexmock(),
},
config_filename=flexmock(),
config={'repositories': []},
config_paths=[],