mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 02:03:01 +02:00
Fix the (unreleased) "archive_hostname" option / "--archive-hostname" flag to pass an environment variable to Borg instead of a flag. Also add an "archive_username" option and corresponding "--archive-username" flag to override the "{user}" plaecholder (#1317).
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
2.1.7.dev0
|
2.1.7.dev0
|
||||||
* #1309: Add support for the "--quick-stats" flag and the "quick_statistics" option to the "prune"
|
* #1309: Add support for the "--quick-stats" flag and the "quick_statistics" option to the "prune"
|
||||||
action. Borg >= 1.4.5 and < 2 only.
|
action. Borg >= 1.4.5 and < 2 only.
|
||||||
* #1317: Add an "--archive-hostname" flag and corresponding "archive_hostname" option for
|
* #1317: Add an "archive_hostname" option and a corresponding "--archive-hostname" flag for
|
||||||
overriding the hostname used for the "{hostname}" placeholder in the "archive_name_format"
|
overriding the hostname used for the "{hostname}" placeholder in the "archive_name_format"
|
||||||
option. Borg 1.4.5+ only.
|
option. Also add an "archive_username" option and corresponding "--archive-username" flag to
|
||||||
|
override the "{user}" plaecholder. Both options/flags are Borg 1.4.5+ only.
|
||||||
* #1319: Fix the ZFS hook's overzealous unmounting of snapshot paths when a source dataset is at
|
* #1319: Fix the ZFS hook's overzealous unmounting of snapshot paths when a source dataset is at
|
||||||
"/".
|
"/".
|
||||||
* #1322: Fix for the "restore" action sometimes failing to find a database dump that was dumped
|
* #1322: Fix for the "restore" action sometimes failing to find a database dump that was dumped
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ def run_arbitrary_borg(
|
|||||||
+ borg_command
|
+ borg_command
|
||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ flags.make_flags('remote-path', remote_path)
|
+ flags.make_flags('remote-path', remote_path)
|
||||||
+ flags.make_flags('lock-wait', config.get('lock_wait'))
|
+ flags.make_flags('lock-wait', config.get('lock_wait'))
|
||||||
+ command_options
|
+ command_options
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ def break_lock(
|
|||||||
argparse.Namespace of global arguments, and optional local and remote Borg paths, break any
|
argparse.Namespace of global arguments, and optional local and remote Borg paths, break any
|
||||||
repository and cache locks leftover from Borg aborting.
|
repository and cache locks leftover from Borg aborting.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('break_lock', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('break_lock', '')
|
||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'break-lock')
|
(local_path, 'break-lock')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -24,14 +24,12 @@ def change_passphrase(
|
|||||||
based on an interactive prompt.
|
based on an interactive prompt.
|
||||||
'''
|
'''
|
||||||
borgmatic.logger.add_custom_log_levels()
|
borgmatic.logger.add_custom_log_levels()
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('key_change_passphrase', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('key_change_passphrase', '')
|
||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'key', 'change-passphrase')
|
(local_path, 'key', 'change-passphrase')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ def check_archives(
|
|||||||
# If not configured, elevate Borg's exit code 1 (an ostensible warning) to error, because Borg
|
# If not configured, elevate Borg's exit code 1 (an ostensible warning) to error, because Borg
|
||||||
# returns exit code 1 for repository check errors!
|
# returns exit code 1 for repository check errors!
|
||||||
borg_exit_codes = [*config.get('borg_exit_codes', []), *[{'code': 1, 'treat_as': 'error'}]]
|
borg_exit_codes = [*config.get('borg_exit_codes', []), *[{'code': 1, 'treat_as': 'error'}]]
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
working_directory = borgmatic.config.paths.get_working_directory(config)
|
working_directory = borgmatic.config.paths.get_working_directory(config)
|
||||||
|
|
||||||
@@ -177,7 +176,6 @@ def check_archives(
|
|||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ make_check_name_flags(checks_subset, archive_filter_flags)
|
+ make_check_name_flags(checks_subset, archive_filter_flags)
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (
|
+ (
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ def compact_segments(
|
|||||||
Given dry-run flag, a local or remote repository path, a configuration dict, and the local Borg
|
Given dry-run flag, a local or remote repository path, a configuration dict, and the local Borg
|
||||||
version, compact the segments in a repository.
|
version, compact the segments in a repository.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('compact', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('compact', '')
|
||||||
@@ -30,7 +29,6 @@ def compact_segments(
|
|||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'compact')
|
(local_path, 'compact')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--log-json',) if (config.get('log_json') or not config.get('progress')) else ())
|
+ (('--log-json',) if (config.get('log_json') or not config.get('progress')) else ())
|
||||||
|
|||||||
@@ -199,7 +199,6 @@ def make_base_create_command( # noqa: PLR0912
|
|||||||
list_filter_flags = flags.make_list_filter_flags(local_borg_version, dry_run)
|
list_filter_flags = flags.make_list_filter_flags(local_borg_version, dry_run)
|
||||||
files_changed = config.get('files_changed')
|
files_changed = config.get('files_changed')
|
||||||
files_cache = config.get('files_cache')
|
files_cache = config.get('files_cache')
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
archive_name_format = (
|
archive_name_format = (
|
||||||
config.get('archive_name_format', flags.get_default_archive_name_format(local_borg_version))
|
config.get('archive_name_format', flags.get_default_archive_name_format(local_borg_version))
|
||||||
+ archive_suffix
|
+ archive_suffix
|
||||||
@@ -251,7 +250,6 @@ def make_base_create_command( # noqa: PLR0912
|
|||||||
+ noflags_flags
|
+ noflags_flags
|
||||||
+ (('--files-changed', files_changed) if files_changed else ())
|
+ (('--files-changed', files_changed) if files_changed else ())
|
||||||
+ (('--files-cache', files_cache) if files_cache else ())
|
+ (('--files-cache', files_cache) if files_cache else ())
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ def make_delete_command(
|
|||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ borgmatic.borg.flags.make_flags('dry-run', global_arguments.dry_run)
|
+ borgmatic.borg.flags.make_flags('dry-run', global_arguments.dry_run)
|
||||||
+ borgmatic.borg.flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
|
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
|
||||||
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
|
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ def diff(
|
|||||||
'''
|
'''
|
||||||
borgmatic.logger.add_custom_log_levels()
|
borgmatic.logger.add_custom_log_levels()
|
||||||
|
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('diff', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('diff', '')
|
||||||
|
|
||||||
@@ -53,7 +52,6 @@ def diff(
|
|||||||
|
|
||||||
diff_command = (
|
diff_command = (
|
||||||
(local_path, 'diff')
|
(local_path, 'diff')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait is not None else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait is not None else ())
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import borgmatic.borg.passcommand
|
|||||||
import borgmatic.hooks.credential.parse
|
import borgmatic.hooks.credential.parse
|
||||||
|
|
||||||
OPTION_TO_ENVIRONMENT_VARIABLE = {
|
OPTION_TO_ENVIRONMENT_VARIABLE = {
|
||||||
|
'archive_hostname': 'BORG_HOSTNAME',
|
||||||
|
'archive_username': 'BORG_USERNAME',
|
||||||
'borg_base_directory': 'BORG_BASE_DIR',
|
'borg_base_directory': 'BORG_BASE_DIR',
|
||||||
'borg_config_directory': 'BORG_CONFIG_DIR',
|
'borg_config_directory': 'BORG_CONFIG_DIR',
|
||||||
'borg_cache_directory': 'BORG_CACHE_DIR',
|
'borg_cache_directory': 'BORG_CACHE_DIR',
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ def export_key(
|
|||||||
Raise FileExistsError if a path is given but it already exists on disk.
|
Raise FileExistsError if a path is given but it already exists on disk.
|
||||||
'''
|
'''
|
||||||
borgmatic.logger.add_custom_log_levels()
|
borgmatic.logger.add_custom_log_levels()
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
working_directory = borgmatic.config.paths.get_working_directory(config)
|
working_directory = borgmatic.config.paths.get_working_directory(config)
|
||||||
@@ -47,7 +46,6 @@ def export_key(
|
|||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'key', 'export')
|
(local_path, 'key', 'export')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--log-json',) if output_file is None else ())
|
+ (('--log-json',) if output_file is None else ())
|
||||||
|
|||||||
@@ -33,14 +33,12 @@ def export_tar_archive(
|
|||||||
If the destination path is "-", then stream the output to stdout instead of to a file.
|
If the destination path is "-", then stream the output to stdout instead of to a file.
|
||||||
'''
|
'''
|
||||||
borgmatic.logger.add_custom_log_levels()
|
borgmatic.logger.add_custom_log_levels()
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('export_tar', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('export_tar', '')
|
||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'export-tar')
|
(local_path, 'export-tar')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--log-json',) if destination_path != '-' else ())
|
+ (('--log-json',) if destination_path != '-' else ())
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ def extract_last_archive_dry_run(
|
|||||||
Perform an extraction dry-run of the most recent archive. If there are no archives, skip the
|
Perform an extraction dry-run of the most recent archive. If there are no archives, skip the
|
||||||
dry-run.
|
dry-run.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('extract', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('extract', '')
|
||||||
verbosity_flags = ()
|
verbosity_flags = ()
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
@@ -49,7 +48,6 @@ def extract_last_archive_dry_run(
|
|||||||
list_flag = ('--list',) if logger.isEnabledFor(logging.DEBUG) else ()
|
list_flag = ('--list',) if logger.isEnabledFor(logging.DEBUG) else ()
|
||||||
full_extract_command = (
|
full_extract_command = (
|
||||||
(local_path, 'extract', '--dry-run')
|
(local_path, 'extract', '--dry-run')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--log-json',) if not config.get('progress') else ())
|
+ (('--log-json',) if not config.get('progress') else ())
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
@@ -106,7 +104,6 @@ def extract_archive(
|
|||||||
If extract to stdout is True, then start the extraction streaming to stdout, and return that
|
If extract to stdout is True, then start the extraction streaming to stdout, and return that
|
||||||
extract process as an instance of subprocess.Popen.
|
extract process as an instance of subprocess.Popen.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('extract', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('extract', '')
|
||||||
@@ -135,7 +132,6 @@ def extract_archive(
|
|||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'extract')
|
(local_path, 'extract')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ numeric_ids_flags
|
+ numeric_ids_flags
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ def import_key(
|
|||||||
|
|
||||||
Raise ValueError if the path is given and it does not exist.
|
Raise ValueError if the path is given and it does not exist.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
working_directory = borgmatic.config.paths.get_working_directory(config)
|
working_directory = borgmatic.config.paths.get_working_directory(config)
|
||||||
@@ -42,7 +41,6 @@ def import_key(
|
|||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'key', 'import')
|
(local_path, 'key', 'import')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ def make_info_command(
|
|||||||
if logger.isEnabledFor(logging.DEBUG) and not info_arguments.json
|
if logger.isEnabledFor(logging.DEBUG) and not info_arguments.json
|
||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ flags.make_flags('remote-path', remote_path)
|
+ flags.make_flags('remote-path', remote_path)
|
||||||
+ flags.make_flags('umask', config.get('umask'))
|
+ flags.make_flags('umask', config.get('umask'))
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ def make_list_command(
|
|||||||
if logger.isEnabledFor(logging.DEBUG) and not list_arguments.json
|
if logger.isEnabledFor(logging.DEBUG) and not list_arguments.json
|
||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ flags.make_flags('remote-path', remote_path)
|
+ flags.make_flags('remote-path', remote_path)
|
||||||
+ flags.make_flags('umask', config.get('umask'))
|
+ flags.make_flags('umask', config.get('umask'))
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -24,14 +24,12 @@ def mount_archive(
|
|||||||
dict, the local Borg version, global arguments as an argparse.Namespace instance, and optional
|
dict, the local Borg version, global arguments as an argparse.Namespace instance, and optional
|
||||||
local and remote Borg paths, mount the archive onto the mount point.
|
local and remote Borg paths, mount the archive onto the mount point.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('mount', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('mount', '')
|
||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
(local_path, 'mount')
|
(local_path, 'mount')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--log-json',) if not mount_arguments.foreground else ())
|
+ (('--log-json',) if not mount_arguments.foreground else ())
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ def prune_archives(
|
|||||||
archives according to the retention policy specified in that configuration.
|
archives according to the retention policy specified in that configuration.
|
||||||
'''
|
'''
|
||||||
borgmatic.logger.add_custom_log_levels()
|
borgmatic.logger.add_custom_log_levels()
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
extra_borg_options = config.get('extra_borg_options', {}).get('prune', '')
|
extra_borg_options = config.get('extra_borg_options', {}).get('prune', '')
|
||||||
@@ -74,7 +73,6 @@ def prune_archives(
|
|||||||
(local_path, 'prune')
|
(local_path, 'prune')
|
||||||
+ make_prune_flags(config, prune_arguments, local_borg_version)
|
+ make_prune_flags(config, prune_arguments, local_borg_version)
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ def recreate_archive(
|
|||||||
arguments, optional local and remote Borg paths, executes the recreate command with the given
|
arguments, optional local and remote Borg paths, executes the recreate command with the given
|
||||||
arguments.
|
arguments.
|
||||||
'''
|
'''
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
exclude_flags = flags.make_exclude_flags(config)
|
exclude_flags = flags.make_exclude_flags(config)
|
||||||
compression = config.get('compression')
|
compression = config.get('compression')
|
||||||
@@ -46,7 +45,6 @@ def recreate_archive(
|
|||||||
|
|
||||||
recreate_command = (
|
recreate_command = (
|
||||||
(local_path, 'recreate')
|
(local_path, 'recreate')
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait is not None else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait is not None else ())
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ def make_rename_command(
|
|||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ borgmatic.borg.flags.make_flags('dry-run', dry_run)
|
+ borgmatic.borg.flags.make_flags('dry-run', dry_run)
|
||||||
+ borgmatic.borg.flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
|
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
|
||||||
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
|
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ def create_repository(
|
|||||||
if error.returncode not in REPO_INFO_REPOSITORY_NOT_FOUND_EXIT_CODES:
|
if error.returncode not in REPO_INFO_REPOSITORY_NOT_FOUND_EXIT_CODES:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
archive_hostname = config.get('archive_hostname')
|
|
||||||
lock_wait = config.get('lock_wait')
|
lock_wait = config.get('lock_wait')
|
||||||
umask = config.get('umask')
|
umask = config.get('umask')
|
||||||
extra_borg_options_from_init = config.get('extra_borg_options', {}).get('init', '')
|
extra_borg_options_from_init = config.get('extra_borg_options', {}).get('init', '')
|
||||||
@@ -96,7 +95,6 @@ def create_repository(
|
|||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--debug',) if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug',) if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
+ (('--hostname', archive_hostname) if archive_hostname else ())
|
|
||||||
+ (('--remote-path', remote_path) if remote_path else ())
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
+ (('--umask', str(umask)) if umask else ())
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
+ (tuple(shlex.split(extra_borg_options)) if extra_borg_options else ())
|
+ (tuple(shlex.split(extra_borg_options)) if extra_borg_options else ())
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ def make_repo_delete_command(
|
|||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ borgmatic.borg.flags.make_flags('dry-run', global_arguments.dry_run)
|
+ borgmatic.borg.flags.make_flags('dry-run', global_arguments.dry_run)
|
||||||
+ borgmatic.borg.flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
|
+ borgmatic.borg.flags.make_flags('remote-path', remote_path)
|
||||||
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
|
+ borgmatic.borg.flags.make_flags('umask', config.get('umask'))
|
||||||
+ (('--log-json',) if output_file is None else ())
|
+ (('--log-json',) if output_file is None else ())
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ def display_repository_info(
|
|||||||
if logger.isEnabledFor(logging.DEBUG) and not repo_info_arguments.json
|
if logger.isEnabledFor(logging.DEBUG) and not repo_info_arguments.json
|
||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ flags.make_flags('remote-path', remote_path)
|
+ flags.make_flags('remote-path', remote_path)
|
||||||
+ flags.make_flags('umask', config.get('umask'))
|
+ flags.make_flags('umask', config.get('umask'))
|
||||||
+ flags.make_flags('lock-wait', lock_wait)
|
+ flags.make_flags('lock-wait', lock_wait)
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ def get_latest_archive(
|
|||||||
if feature.available(feature.Feature.REPO_LIST, local_borg_version)
|
if feature.available(feature.Feature.REPO_LIST, local_borg_version)
|
||||||
else 'list'
|
else 'list'
|
||||||
),
|
),
|
||||||
*flags.make_flags('hostname', config.get('archive_hostname')),
|
|
||||||
*flags.make_flags('remote-path', remote_path),
|
*flags.make_flags('remote-path', remote_path),
|
||||||
*flags.make_flags('umask', config.get('umask')),
|
*flags.make_flags('umask', config.get('umask')),
|
||||||
*('--log-json',),
|
*('--log-json',),
|
||||||
@@ -161,7 +160,6 @@ def make_repo_list_command(
|
|||||||
if logger.isEnabledFor(logging.DEBUG) and not repo_list_arguments.json
|
if logger.isEnabledFor(logging.DEBUG) and not repo_list_arguments.json
|
||||||
else ()
|
else ()
|
||||||
)
|
)
|
||||||
+ flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ flags.make_flags('remote-path', remote_path)
|
+ flags.make_flags('remote-path', remote_path)
|
||||||
+ flags.make_flags('umask', config.get('umask'))
|
+ flags.make_flags('umask', config.get('umask'))
|
||||||
+ ('--log-json',)
|
+ ('--log-json',)
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ def transfer_archives(
|
|||||||
(local_path, 'transfer')
|
(local_path, 'transfer')
|
||||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||||
+ flags.make_flags('hostname', config.get('archive_hostname'))
|
|
||||||
+ flags.make_flags('remote-path', remote_path)
|
+ flags.make_flags('remote-path', remote_path)
|
||||||
+ flags.make_flags('umask', config.get('umask'))
|
+ flags.make_flags('umask', config.get('umask'))
|
||||||
+ (('--log-json',) if (config.get('log_json') or not config.get('progress')) else ())
|
+ (('--log-json',) if (config.get('log_json') or not config.get('progress')) else ())
|
||||||
|
|||||||
@@ -528,6 +528,14 @@ properties:
|
|||||||
"archive_name_format", "match_archives", etc. Defaults to the system
|
"archive_name_format", "match_archives", etc. Defaults to the system
|
||||||
hostname. (This option is supported for Borg 1.4.5+ only.)
|
hostname. (This option is supported for Borg 1.4.5+ only.)
|
||||||
example: example.org
|
example: example.org
|
||||||
|
archive_username:
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
Username to use for the "{user}" placeholder in
|
||||||
|
"archive_name_format", "match_archives", etc. Defaults to the
|
||||||
|
username of the user running borgmatic. (This option is supported
|
||||||
|
for Borg 1.4.5+ only.)
|
||||||
|
example: example.org
|
||||||
file_list_format:
|
file_list_format:
|
||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
|
|||||||
@@ -188,36 +188,6 @@ def test_run_arbitrary_borg_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_run_arbitrary_borg_with_archive_hostname_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
|
||||||
'hostname', 'example.org'
|
|
||||||
).and_return(
|
|
||||||
('--hostname', 'example.org'),
|
|
||||||
)
|
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
|
||||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
|
||||||
('borg', 'break-lock', '--hostname', 'example.org', '::'),
|
|
||||||
output_file=module.borgmatic.execute.DO_NOT_CAPTURE,
|
|
||||||
shell=True,
|
|
||||||
environment={'BORG_REPO': 'repo', 'ARCHIVE': ''},
|
|
||||||
working_directory=None,
|
|
||||||
borg_local_path='borg',
|
|
||||||
borg_exit_codes=None,
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.run_arbitrary_borg(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
options=['break-lock', '::'],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_run_arbitrary_borg_with_remote_path_calls_borg_with_remote_path_flags():
|
def test_run_arbitrary_borg_with_remote_path_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
||||||
|
|||||||
@@ -62,21 +62,6 @@ def test_break_lock_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_break_lock_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'break-lock', '--hostname', 'example.org', '--log-json', 'repo')
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.break_lock(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_break_lock_calls_borg_with_remote_path_flags():
|
def test_break_lock_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||||
insert_execute_command_mock(
|
insert_execute_command_mock(
|
||||||
|
|||||||
@@ -81,24 +81,6 @@ def test_change_passphrase_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_change_passphrase_calls_borg_with_hostname_flags():
|
|
||||||
config = {'archive_hostname': 'example.org'}
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'key', 'change-passphrase', '--hostname', 'example.org', 'repo'),
|
|
||||||
config=config,
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.change_passphrase(
|
|
||||||
repository_path='repo',
|
|
||||||
config=config,
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
change_passphrase_arguments=flexmock(),
|
|
||||||
global_arguments=flexmock(dry_run=False),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_change_passphrase_calls_borg_with_remote_path_flags():
|
def test_change_passphrase_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||||
insert_execute_command_mock(
|
insert_execute_command_mock(
|
||||||
|
|||||||
@@ -895,33 +895,6 @@ def test_check_archives_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_check_archives_with_archive_hostname_passes_through_to_borg():
|
|
||||||
checks = {'repository'}
|
|
||||||
flexmock(module).should_receive('make_check_name_flags').with_args(checks, ()).and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'check', '--hostname', 'example.org', '--log-json', 'repo')
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.check_archives(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
check_arguments=flexmock(
|
|
||||||
progress=None,
|
|
||||||
repair=None,
|
|
||||||
only_checks=None,
|
|
||||||
force=None,
|
|
||||||
match_archives=None,
|
|
||||||
max_duration=None,
|
|
||||||
),
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
checks=checks,
|
|
||||||
archive_filter_flags=(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_check_archives_with_remote_path_passes_through_to_borg():
|
def test_check_archives_with_remote_path_passes_through_to_borg():
|
||||||
checks = {'repository'}
|
checks = {'repository'}
|
||||||
config = {}
|
config = {}
|
||||||
|
|||||||
@@ -151,39 +151,6 @@ def test_compact_segments_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_compact_segments_with_archive_hostname_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
insert_execute_command_mock(
|
|
||||||
(*COMPACT_COMMAND, '--hostname', 'example.org', '--log-json', 'repo'), logging.INFO
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.compact_segments(
|
|
||||||
dry_run=False,
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_compact_segments_with_remote_path_calls_borg_with_remote_path_flags():
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
insert_execute_command_mock(
|
|
||||||
(*COMPACT_COMMAND, '--remote-path', 'borg1', '--log-json', 'repo'), logging.INFO
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.compact_segments(
|
|
||||||
dry_run=False,
|
|
||||||
repository_path='repo',
|
|
||||||
config={},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
remote_path='borg1',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_compact_segments_with_progress_calls_borg_with_progress_flag():
|
def test_compact_segments_with_progress_calls_borg_with_progress_flag():
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||||
insert_execute_command_mock(
|
insert_execute_command_mock(
|
||||||
|
|||||||
@@ -518,7 +518,6 @@ def test_make_base_create_command_with_store_config_false_omits_config_files():
|
|||||||
('flags', False, False, ('--nobsdflags',)),
|
('flags', False, False, ('--nobsdflags',)),
|
||||||
('files_changed', 'mtime', True, ('--files-changed', 'mtime')),
|
('files_changed', 'mtime', True, ('--files-changed', 'mtime')),
|
||||||
('files_cache', 'ctime,size', True, ('--files-cache', 'ctime,size')),
|
('files_cache', 'ctime,size', True, ('--files-cache', 'ctime,size')),
|
||||||
('archive_hostname', 'example.org', True, ('--hostname', 'example.org')),
|
|
||||||
('umask', 740, True, ('--umask', '740')),
|
('umask', 740, True, ('--umask', '740')),
|
||||||
('lock_wait', 5, True, ('--lock-wait', '5')),
|
('lock_wait', 5, True, ('--lock-wait', '5')),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -78,32 +78,6 @@ def test_make_delete_command_includes_dry_run():
|
|||||||
assert command == ('borg', 'delete', '--dry-run', '--log-json', 'repo')
|
assert command == ('borg', 'delete', '--dry-run', '--log-json', 'repo')
|
||||||
|
|
||||||
|
|
||||||
def test_make_delete_command_includes_hostname():
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
|
||||||
'hostname',
|
|
||||||
'example.org',
|
|
||||||
).and_return(('--hostname', 'example.org'))
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
|
||||||
('repo',),
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
command = module.make_delete_command(
|
|
||||||
repository={'path': 'repo'},
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
delete_arguments=flexmock(list_details=False, force=0, match_archives=None, archive=None),
|
|
||||||
global_arguments=flexmock(dry_run=False),
|
|
||||||
local_path='borg',
|
|
||||||
remote_path='borg1',
|
|
||||||
)
|
|
||||||
|
|
||||||
assert command == ('borg', 'delete', '--hostname', 'example.org', '--log-json', 'repo')
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_delete_command_includes_remote_path():
|
def test_make_delete_command_includes_remote_path():
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').and_return(())
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
flexmock(module.borgmatic.borg.flags).should_receive('make_flags').with_args(
|
||||||
|
|||||||
@@ -117,61 +117,6 @@ def test_diff_with_local_path_calls_borg_with_it():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_diff_with_archive_hostname_calls_borg_with_it():
|
|
||||||
flexmock(module.logging).ANSWER = LOGGING_ANSWER
|
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
||||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
||||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
|
||||||
flexmock(name='test')
|
|
||||||
)
|
|
||||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
|
||||||
('--repo', 'repo')
|
|
||||||
)
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_archive_flags').never()
|
|
||||||
environment = flexmock()
|
|
||||||
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
|
|
||||||
environment
|
|
||||||
)
|
|
||||||
flexmock(module.borgmatic.execute).should_receive('execute_command').with_args(
|
|
||||||
full_command=(
|
|
||||||
'borg',
|
|
||||||
'diff',
|
|
||||||
'--hostname',
|
|
||||||
'example.org',
|
|
||||||
'--log-json',
|
|
||||||
'--repo',
|
|
||||||
'repo',
|
|
||||||
'archive',
|
|
||||||
'archive2',
|
|
||||||
),
|
|
||||||
output_log_level=LOGGING_ANSWER,
|
|
||||||
environment=environment,
|
|
||||||
working_directory=None,
|
|
||||||
borg_local_path='borg',
|
|
||||||
borg_exit_codes=None,
|
|
||||||
).once()
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.borgmatic.borg.diff.diff(
|
|
||||||
repository='repo',
|
|
||||||
archive='archive',
|
|
||||||
second_archive='archive2',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version=None,
|
|
||||||
diff_arguments=flexmock(
|
|
||||||
same_chunker_params=False,
|
|
||||||
sort_keys=[],
|
|
||||||
content_only=False,
|
|
||||||
second_archive='archive2',
|
|
||||||
only_patterns=False,
|
|
||||||
),
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
local_path='borg',
|
|
||||||
patterns=[],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_diff_with_remote_path_calls_borg_with_it():
|
def test_diff_with_remote_path_calls_borg_with_it():
|
||||||
flexmock(module.logging).ANSWER = LOGGING_ANSWER
|
flexmock(module.logging).ANSWER = LOGGING_ANSWER
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
||||||
|
|||||||
@@ -79,21 +79,6 @@ def test_export_key_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_export_key_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
flexmock(module.os.path).should_receive('exists').never()
|
|
||||||
insert_execute_command_mock(('borg', 'key', 'export', '--hostname', 'example.org', 'repo'))
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.export_key(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
export_arguments=flexmock(paper=False, qr_html=False, path=None),
|
|
||||||
global_arguments=flexmock(dry_run=False),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_export_key_calls_borg_with_remote_path_flags():
|
def test_export_key_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||||
flexmock(module.os.path).should_receive('exists').never()
|
flexmock(module.os.path).should_receive('exists').never()
|
||||||
|
|||||||
@@ -103,37 +103,6 @@ def test_export_tar_archive_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_export_tar_archive_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
||||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
||||||
('repo::archive',),
|
|
||||||
)
|
|
||||||
insert_execute_command_mock(
|
|
||||||
(
|
|
||||||
'borg',
|
|
||||||
'export-tar',
|
|
||||||
'--hostname',
|
|
||||||
'example.org',
|
|
||||||
'--log-json',
|
|
||||||
'repo::archive',
|
|
||||||
'test.tar',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.export_tar_archive(
|
|
||||||
dry_run=False,
|
|
||||||
repository_path='repo',
|
|
||||||
archive='archive',
|
|
||||||
paths=None,
|
|
||||||
destination_path='test.tar',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_export_tar_archive_calls_borg_with_remote_path_flags():
|
def test_export_tar_archive_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
||||||
|
|||||||
@@ -161,33 +161,6 @@ def test_extract_last_archive_dry_run_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_extract_last_archive_dry_run_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
|
|
||||||
insert_execute_command_mock(
|
|
||||||
(
|
|
||||||
'borg',
|
|
||||||
'extract',
|
|
||||||
'--dry-run',
|
|
||||||
'--hostname',
|
|
||||||
'example.org',
|
|
||||||
'--log-json',
|
|
||||||
'repo::archive',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
||||||
('repo::archive',),
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.extract_last_archive_dry_run(
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
repository_path='repo',
|
|
||||||
lock_wait=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_extract_last_archive_dry_run_calls_borg_with_remote_path_flags():
|
def test_extract_last_archive_dry_run_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
|
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
|
||||||
insert_execute_command_mock(
|
insert_execute_command_mock(
|
||||||
@@ -332,32 +305,6 @@ def test_extract_archive_calls_borg_with_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_extract_archive_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.os.path).should_receive('abspath').and_return('repo')
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'extract', '--hostname', 'example.org', '--log-json', 'repo::archive')
|
|
||||||
)
|
|
||||||
flexmock(module.feature).should_receive('available').and_return(True)
|
|
||||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
||||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
||||||
('repo::archive',),
|
|
||||||
)
|
|
||||||
flexmock(module.borgmatic.config.validate).should_receive(
|
|
||||||
'normalize_repository_path',
|
|
||||||
).and_return('repo')
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.extract_archive(
|
|
||||||
dry_run=False,
|
|
||||||
repository='repo',
|
|
||||||
archive='archive',
|
|
||||||
paths=None,
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_extract_archive_calls_borg_with_remote_path_flags():
|
def test_extract_archive_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.os.path).should_receive('abspath').and_return('repo')
|
flexmock(module.os.path).should_receive('abspath').and_return('repo')
|
||||||
insert_execute_command_mock(
|
insert_execute_command_mock(
|
||||||
|
|||||||
@@ -79,24 +79,6 @@ def test_import_key_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_import_key_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
flexmock(module.os.path).should_receive('exists').never()
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'key', 'import', '--hostname', 'example.org', '--log-json', 'repo', '-')
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.import_key(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
import_arguments=flexmock(paper=False, path=None),
|
|
||||||
global_arguments=flexmock(dry_run=False),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_import_key_calls_borg_with_remote_path_flags():
|
def test_import_key_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||||
|
|||||||
@@ -208,34 +208,6 @@ def test_make_info_command_with_local_path_passes_through_to_command():
|
|||||||
assert command == ('borg1', 'info', '--log-json', '--repo', 'repo')
|
assert command == ('borg1', 'info', '--log-json', '--repo', 'repo')
|
||||||
|
|
||||||
|
|
||||||
def test_make_info_command_with_archive_hostname_passes_through_to_command():
|
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
|
||||||
'hostname',
|
|
||||||
'example.org',
|
|
||||||
).and_return(('--hostname', 'example.org'))
|
|
||||||
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
'2.3.4',
|
|
||||||
).and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
command = module.make_info_command(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='2.3.4',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
info_arguments=flexmock(archive=None, json=False, prefix=None, match_archives=None),
|
|
||||||
local_path='borg',
|
|
||||||
remote_path=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert command == ('borg', 'info', '--hostname', 'example.org', '--log-json', '--repo', 'repo')
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_info_command_with_remote_path_passes_through_to_command():
|
def test_make_info_command_with_remote_path_passes_through_to_command():
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
flexmock(module.flags).should_receive('make_flags').with_args(
|
||||||
|
|||||||
@@ -206,30 +206,6 @@ def test_make_list_command_includes_local_path():
|
|||||||
assert command == ('borg2', 'list', '--log-json', 'repo')
|
assert command == ('borg2', 'list', '--log-json', 'repo')
|
||||||
|
|
||||||
|
|
||||||
def test_make_list_command_includes_hostname():
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
|
||||||
'hostname',
|
|
||||||
'example.org',
|
|
||||||
).and_return(('--hostname', 'example.org'))
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args('log-json', True).and_return(
|
|
||||||
('--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_list_command(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
list_arguments=flexmock(archive=None, paths=None, format=None, json=False),
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
assert command == ('borg', 'list', '--hostname', 'example.org', '--log-json', 'repo')
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_list_command_includes_remote_path():
|
def test_make_list_command_includes_remote_path():
|
||||||
insert_logging_mock(logging.WARNING)
|
insert_logging_mock(logging.WARNING)
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||||
|
|||||||
@@ -150,27 +150,6 @@ def test_mount_archive_calls_borg_using_exit_codes():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_mount_archive_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.feature).should_receive('available').and_return(False)
|
|
||||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
||||||
('repo::archive',),
|
|
||||||
)
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'mount', '--hostname', 'example.org', '--log-json', 'repo::archive', '/mnt'),
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
mount_arguments = flexmock(mount_point='/mnt', options=None, paths=None, foreground=False)
|
|
||||||
module.mount_archive(
|
|
||||||
repository_path='repo',
|
|
||||||
archive='archive',
|
|
||||||
mount_arguments=mount_arguments,
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_mount_archive_calls_borg_with_remote_path_flags():
|
def test_mount_archive_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.feature).should_receive('available').and_return(False)
|
flexmock(module.feature).should_receive('available').and_return(False)
|
||||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||||
|
|||||||
@@ -378,29 +378,6 @@ def test_prune_archives_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_prune_archives_with_archive_hostname_calls_borg_with_remote_hostname_flags():
|
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
||||||
flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
flexmock(module.feature).should_receive('available').with_args(
|
|
||||||
module.feature.Feature.NO_PRUNE_STATS,
|
|
||||||
'1.2.3',
|
|
||||||
).and_return(False)
|
|
||||||
insert_execute_command_mock((*PRUNE_COMMAND, '--hostname', 'example.org', 'repo'), logging.INFO)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
prune_arguments = flexmock(statistics=False, list_details=False)
|
|
||||||
module.prune_archives(
|
|
||||||
dry_run=False,
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
prune_arguments=prune_arguments,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_prune_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
def test_prune_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
||||||
|
|||||||
@@ -92,43 +92,6 @@ def test_recreate_with_dry_run_calls_borg_with_dry_run_flag():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_recreate_with_archive_hostname():
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(())
|
|
||||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(None)
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_list_filter_flags').and_return('')
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
||||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
||||||
'make_repository_archive_flags',
|
|
||||||
).and_return(
|
|
||||||
(
|
|
||||||
'--repo',
|
|
||||||
'repo',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
insert_execute_command_mock(
|
|
||||||
('borg', 'recreate', '--hostname', 'example.org', '--log-json', '--repo', 'repo')
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.recreate_archive(
|
|
||||||
repository='repo',
|
|
||||||
archive='archive',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
recreate_arguments=flexmock(
|
|
||||||
list=None,
|
|
||||||
target=None,
|
|
||||||
comment=None,
|
|
||||||
timestamp=None,
|
|
||||||
match_archives=None,
|
|
||||||
),
|
|
||||||
global_arguments=flexmock(dry_run=False),
|
|
||||||
local_path='borg',
|
|
||||||
patterns=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_recreate_with_remote_path():
|
def test_recreate_with_remote_path():
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(())
|
flexmock(module.borgmatic.borg.flags).should_receive('make_exclude_flags').and_return(())
|
||||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(None)
|
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(None)
|
||||||
|
|||||||
@@ -433,30 +433,6 @@ def test_create_repository_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_create_repository_with_archive_hostname_calls_borg_with_hostname_flag():
|
|
||||||
insert_repo_info_command_not_found_mock()
|
|
||||||
insert_repo_create_command_mock(
|
|
||||||
(*REPO_CREATE_COMMAND, '--hostname', 'example.org', '--repo', 'repo'),
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
flexmock(module.feature).should_receive('available').and_return(True)
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
||||||
(
|
|
||||||
'--repo',
|
|
||||||
'repo',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
module.create_repository(
|
|
||||||
dry_run=False,
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='2.3.4',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
encryption_mode='repokey',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
|
def test_create_repository_with_remote_path_calls_borg_with_remote_path_flag():
|
||||||
insert_repo_info_command_not_found_mock()
|
insert_repo_info_command_not_found_mock()
|
||||||
insert_repo_create_command_mock(
|
insert_repo_create_command_mock(
|
||||||
|
|||||||
@@ -126,33 +126,6 @@ def test_make_repo_delete_command_includes_dry_run():
|
|||||||
assert command == ('borg', 'repo-delete', '--dry-run', '--log-json', 'repo')
|
assert command == ('borg', 'repo-delete', '--dry-run', '--log-json', 'repo')
|
||||||
|
|
||||||
|
|
||||||
def test_make_repo_delete_command_includes_hostname():
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
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(
|
|
||||||
'hostname',
|
|
||||||
'example.org',
|
|
||||||
).and_return(('--hostname', 'example.org'))
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_flags_from_arguments').and_return(())
|
|
||||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
|
||||||
('repo',),
|
|
||||||
)
|
|
||||||
|
|
||||||
command = module.make_repo_delete_command(
|
|
||||||
repository={'path': 'repo'},
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
repo_delete_arguments=flexmock(list_details=False, force=0),
|
|
||||||
global_arguments=flexmock(dry_run=False),
|
|
||||||
local_path='borg',
|
|
||||||
remote_path=None,
|
|
||||||
output_file=None,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert command == ('borg', 'repo-delete', '--hostname', 'example.org', '--log-json', 'repo')
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_repo_delete_command_includes_remote_path():
|
def test_make_repo_delete_command_includes_remote_path():
|
||||||
insert_logging_mock(logging.WARNING)
|
insert_logging_mock(logging.WARNING)
|
||||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||||
|
|||||||
@@ -364,57 +364,6 @@ def test_display_repository_info_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_display_repository_info_with_archve_hostname_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
||||||
flexmock(module.feature).should_receive('available').and_return(True)
|
|
||||||
flexmock(module.flags).should_receive('make_flags').replace_with(
|
|
||||||
lambda name, value: (f'--{name}', value) if value else (),
|
|
||||||
)
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(
|
|
||||||
(
|
|
||||||
'--repo',
|
|
||||||
'repo',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
|
||||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
||||||
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
||||||
(
|
|
||||||
'borg',
|
|
||||||
'repo-info',
|
|
||||||
'--hostname',
|
|
||||||
'example.org',
|
|
||||||
'--log-json',
|
|
||||||
'--json',
|
|
||||||
'--repo',
|
|
||||||
'repo',
|
|
||||||
),
|
|
||||||
environment=None,
|
|
||||||
working_directory=None,
|
|
||||||
borg_local_path='borg',
|
|
||||||
borg_exit_codes=None,
|
|
||||||
).and_yield('[]')
|
|
||||||
flexmock(module.flags).should_receive('warn_for_aggressive_archive_flags')
|
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
|
||||||
('borg', 'repo-info', '--hostname', 'example.org', '--log-json', '--repo', 'repo'),
|
|
||||||
output_log_level=module.borgmatic.logger.ANSWER,
|
|
||||||
environment=None,
|
|
||||||
working_directory=None,
|
|
||||||
borg_local_path='borg',
|
|
||||||
borg_exit_codes=None,
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.display_repository_info(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='2.3.4',
|
|
||||||
repo_info_arguments=flexmock(json=False),
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_flags():
|
def test_display_repository_info_with_remote_path_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
||||||
|
|||||||
@@ -265,40 +265,6 @@ def test_get_latest_archive_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_latest_archive_with_archive_hostname_calls_borg_with_hostname_flags():
|
|
||||||
expected_archive = {'name': 'archive-name', 'id': 'd34db33f'}
|
|
||||||
flexmock(module.feature).should_receive('available').and_return(False)
|
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
|
||||||
'hostname', 'example.org'
|
|
||||||
).and_return(('--hostname', 'example.org'))
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args('last', 1).and_return(
|
|
||||||
('--last', '1')
|
|
||||||
)
|
|
||||||
flexmock(module.flags).should_receive('make_match_archives_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
|
||||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
||||||
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
||||||
('borg', 'list', '--hostname', 'example.org', '--log-json', *BORG_LIST_LATEST_ARGUMENTS),
|
|
||||||
environment=None,
|
|
||||||
working_directory=None,
|
|
||||||
borg_local_path='borg',
|
|
||||||
borg_exit_codes=None,
|
|
||||||
).and_yield(json.dumps({'archives': [expected_archive]}))
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
assert (
|
|
||||||
module.get_latest_archive(
|
|
||||||
'repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
== expected_archive
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_latest_archive_with_remote_path_calls_borg_with_remote_path_flags():
|
def test_get_latest_archive_with_remote_path_calls_borg_with_remote_path_flags():
|
||||||
expected_archive = {'name': 'archive-name', 'id': 'd34db33f'}
|
expected_archive = {'name': 'archive-name', 'id': 'd34db33f'}
|
||||||
flexmock(module.feature).should_receive('available').and_return(False)
|
flexmock(module.feature).should_receive('available').and_return(False)
|
||||||
@@ -916,38 +882,6 @@ def test_make_repo_list_command_includes_local_path():
|
|||||||
assert command == ('borg2', 'list', '--log-json', 'repo')
|
assert command == ('borg2', 'list', '--log-json', 'repo')
|
||||||
|
|
||||||
|
|
||||||
def test_make_repo_list_command_includes_hostname():
|
|
||||||
flexmock(module.feature).should_receive('available').and_return(False)
|
|
||||||
flexmock(module.flags).should_receive('make_flags').replace_with(
|
|
||||||
lambda name, value: (f'--{name}', value) if value else (),
|
|
||||||
)
|
|
||||||
flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
'1.2.3',
|
|
||||||
).and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
command = module.make_repo_list_command(
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='1.2.3',
|
|
||||||
repo_list_arguments=flexmock(
|
|
||||||
archive=None,
|
|
||||||
paths=None,
|
|
||||||
format=None,
|
|
||||||
json=False,
|
|
||||||
prefix=None,
|
|
||||||
match_archives=None,
|
|
||||||
),
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
assert command == ('borg', 'list', '--hostname', 'example.org', '--log-json', 'repo')
|
|
||||||
|
|
||||||
|
|
||||||
def test_make_repo_list_command_includes_remote_path():
|
def test_make_repo_list_command_includes_remote_path():
|
||||||
flexmock(module.feature).should_receive('available').and_return(False)
|
flexmock(module.feature).should_receive('available').and_return(False)
|
||||||
flexmock(module.flags).should_receive('make_flags').replace_with(
|
flexmock(module.flags).should_receive('make_flags').replace_with(
|
||||||
|
|||||||
@@ -340,45 +340,6 @@ def test_transfer_archives_with_exit_codes_calls_borg_using_them():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_transfer_archives_with_archive_hostname_calls_borg_with_hostname_flags():
|
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
||||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
|
||||||
'hostname',
|
|
||||||
'example.org',
|
|
||||||
).and_return(('--hostname', 'example.org'))
|
|
||||||
flexmock(module.flags).should_receive('make_match_archives_flags').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
|
||||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
|
||||||
flexmock(module.environment).should_receive('make_environment')
|
|
||||||
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
||||||
flexmock(module).should_receive('execute_command').with_args(
|
|
||||||
('borg', 'transfer', '--hostname', 'example.org', '--log-json', '--repo', 'repo'),
|
|
||||||
output_log_level=module.borgmatic.logger.ANSWER,
|
|
||||||
output_file=None,
|
|
||||||
environment=None,
|
|
||||||
working_directory=None,
|
|
||||||
borg_local_path='borg',
|
|
||||||
borg_exit_codes=None,
|
|
||||||
)
|
|
||||||
insert_logging_mock(logging.WARNING)
|
|
||||||
|
|
||||||
module.transfer_archives(
|
|
||||||
dry_run=False,
|
|
||||||
repository_path='repo',
|
|
||||||
config={'archive_hostname': 'example.org'},
|
|
||||||
local_borg_version='2.3.4',
|
|
||||||
transfer_arguments=flexmock(
|
|
||||||
archive=None,
|
|
||||||
progress=None,
|
|
||||||
match_archives=None,
|
|
||||||
source_repository=None,
|
|
||||||
),
|
|
||||||
global_arguments=flexmock(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_transfer_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
def test_transfer_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
||||||
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
||||||
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
||||||
|
|||||||
Reference in New Issue
Block a user