Add support for logging each log line as a JSON object via global "--log-json" flag (#680).
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dan Helfman 2023-05-08 23:00:49 -07:00
commit 92a2230a07
56 changed files with 934 additions and 105 deletions

1
NEWS
View file

@ -7,6 +7,7 @@
commands with arguments.
* #678: Fix calls to psql in PostgreSQL hook to ignore "~/.psqlrc", whose settings can break
database dumping.
* #680: Add support for logging each log line as a JSON object via global "--log-json" flag.
* #682: Fix "source_directories_must_exist" option to expand globs and tildes in source directories.
* #684: Rename "master" development branch to "main" to use more inclusive language. You'll need to
update your development checkouts accordingly.

View file

@ -12,6 +12,7 @@ def run_borg(
storage,
local_borg_version,
borg_arguments,
global_arguments,
local_path,
remote_path,
):
@ -27,6 +28,7 @@ def run_borg(
borg_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
)

View file

@ -11,6 +11,7 @@ def run_break_lock(
storage,
local_borg_version,
break_lock_arguments,
global_arguments,
local_path,
remote_path,
):
@ -25,6 +26,7 @@ def run_break_lock(
repository['path'],
storage,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -44,6 +44,7 @@ def run_check(
storage,
consistency,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
progress=check_arguments.progress,

View file

@ -45,6 +45,7 @@ def run_compact(
repository['path'],
storage,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
progress=compact_arguments.progress,

View file

@ -67,6 +67,7 @@ def run_create(
location,
storage,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
progress=create_arguments.progress,

View file

@ -33,6 +33,7 @@ def run_export_tar(
export_tar_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
),
@ -40,6 +41,7 @@ def run_export_tar(
export_tar_arguments.destination,
storage,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
tar_filter=export_tar_arguments.tar_filter,

View file

@ -44,6 +44,7 @@ def run_extract(
extract_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
),
@ -51,6 +52,7 @@ def run_extract(
location,
storage,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
destination_path=extract_arguments.destination,

View file

@ -13,6 +13,7 @@ def run_info(
storage,
local_borg_version,
info_arguments,
global_arguments,
local_path,
remote_path,
):
@ -31,6 +32,7 @@ def run_info(
info_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
)
@ -38,9 +40,10 @@ def run_info(
repository['path'],
storage,
local_borg_version,
info_arguments=info_arguments,
local_path=local_path,
remote_path=remote_path,
info_arguments,
global_arguments,
local_path,
remote_path,
)
if json_output: # pragma: nocover
yield json.loads(json_output)

View file

@ -12,6 +12,7 @@ def run_list(
storage,
local_borg_version,
list_arguments,
global_arguments,
local_path,
remote_path,
):
@ -33,6 +34,7 @@ def run_list(
list_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
)
@ -40,9 +42,10 @@ def run_list(
repository['path'],
storage,
local_borg_version,
list_arguments=list_arguments,
local_path=local_path,
remote_path=remote_path,
list_arguments,
global_arguments,
local_path,
remote_path,
)
if json_output: # pragma: nocover
yield json.loads(json_output)

View file

@ -12,6 +12,7 @@ def run_mount(
storage,
local_borg_version,
mount_arguments,
global_arguments,
local_path,
remote_path,
):
@ -33,6 +34,7 @@ def run_mount(
mount_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
),
@ -42,6 +44,7 @@ def run_mount(
mount_arguments.options,
storage,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -44,6 +44,7 @@ def run_prune(
storage,
retention,
local_borg_version,
global_arguments,
local_path=local_path,
remote_path=remote_path,
stats=prune_arguments.stats,

View file

@ -29,6 +29,7 @@ def run_rcreate(
repository['path'],
storage,
local_borg_version,
global_arguments,
rcreate_arguments.encryption_mode,
rcreate_arguments.source_repository,
rcreate_arguments.copy_crypt_key,

View file

@ -93,6 +93,7 @@ def restore_single_database(
location_config=location,
storage_config=storage,
local_borg_version=local_borg_version,
global_arguments=global_arguments,
local_path=local_path,
remote_path=remote_path,
destination_path='/',
@ -119,14 +120,15 @@ def collect_archive_database_names(
location,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
):
'''
Given a local or remote repository path, a resolved archive name, a location configuration dict,
a storage configuration dict, the local Borg version, and local and remote Borg paths, query the
archive for the names of databases it contains and return them as a dict from hook name to a
sequence of database names.
a storage configuration dict, the local Borg version, global_arguments an argparse.Namespace,
and local and remote Borg paths, query the archive for the names of databases it contains and
return them as a dict from hook name to a sequence of database names.
'''
borgmatic_source_directory = os.path.expanduser(
location.get(
@ -141,6 +143,7 @@ def collect_archive_database_names(
archive,
storage,
local_borg_version,
global_arguments,
list_path=parent_dump_path,
local_path=local_path,
remote_path=remote_path,
@ -279,6 +282,7 @@ def run_restore(
restore_arguments.archive,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
)
@ -288,6 +292,7 @@ def run_restore(
location,
storage,
local_borg_version,
global_arguments,
local_path,
remote_path,
)

View file

@ -12,6 +12,7 @@ def run_rinfo(
storage,
local_borg_version,
rinfo_arguments,
global_arguments,
local_path,
remote_path,
):
@ -31,6 +32,7 @@ def run_rinfo(
storage,
local_borg_version,
rinfo_arguments=rinfo_arguments,
global_arguments=global_arguments,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -12,6 +12,7 @@ def run_rlist(
storage,
local_borg_version,
rlist_arguments,
global_arguments,
local_path,
remote_path,
):
@ -31,6 +32,7 @@ def run_rlist(
storage,
local_borg_version,
rlist_arguments=rlist_arguments,
global_arguments=global_arguments,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -24,6 +24,7 @@ def run_transfer(
storage,
local_borg_version,
transfer_arguments,
global_arguments,
local_path=local_path,
remote_path=remote_path,
)

View file

@ -10,13 +10,14 @@ def break_lock(
repository_path,
storage_config,
local_borg_version,
global_arguments,
local_path='borg',
remote_path=None,
):
'''
Given a local or remote repository path, a storage configuration dict, the local Borg version,
and optional local and remote Borg paths, break any repository and cache locks leftover from Borg
aborting.
an argparse.Namespace of global arguments, and optional local and remote Borg paths, break any
repository and cache locks leftover from Borg aborting.
'''
umask = storage_config.get('umask', None)
lock_wait = storage_config.get('lock_wait', None)
@ -25,6 +26,7 @@ def break_lock(
(local_path, 'break-lock')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())

View file

@ -259,6 +259,7 @@ def check_archives(
storage_config,
consistency_config,
local_borg_version,
global_arguments,
local_path='borg',
remote_path=None,
progress=None,
@ -283,6 +284,7 @@ def check_archives(
storage_config,
local_borg_version,
argparse.Namespace(json=True),
global_arguments,
local_path,
remote_path,
)
@ -317,6 +319,7 @@ def check_archives(
+ (('--repair',) if repair else ())
+ make_check_flags(local_borg_version, storage_config, checks, check_last, prefix)
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ verbosity_flags
+ (('--progress',) if progress else ())
@ -340,6 +343,12 @@ def check_archives(
if 'extract' in checks:
extract.extract_last_archive_dry_run(
storage_config, local_borg_version, repository_path, lock_wait, local_path, remote_path
storage_config,
local_borg_version,
global_arguments,
repository_path,
lock_wait,
local_path,
remote_path,
)
write_check_time(make_check_time_path(location_config, borg_repository_id, 'extract'))

View file

@ -11,6 +11,7 @@ def compact_segments(
repository_path,
storage_config,
local_borg_version,
global_arguments,
local_path='borg',
remote_path=None,
progress=False,
@ -29,6 +30,7 @@ def compact_segments(
(local_path, 'compact')
+ (('--remote-path', remote_path) if remote_path else ())
+ (('--umask', str(umask)) if umask else ())
+ (('--log-json',) if global_arguments.log_json else ())
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
+ (('--progress',) if progress else ())
+ (('--cleanup-commits',) if cleanup_commits else ())

Some files were not shown because too many files have changed in this diff Show more