borgmatic/borgmatic/actions/export_key.py
Dan Helfman 6dca7c1c15
All checks were successful
continuous-integration/drone/push Build is passing
Add "key export" action to export a copy of the repository key (#345).
2023-08-07 12:28:39 -07:00

34 lines
863 B
Python

import logging
import borgmatic.borg.export_key
import borgmatic.config.validate
logger = logging.getLogger(__name__)
def run_export_key(
repository,
config,
local_borg_version,
export_arguments,
global_arguments,
local_path,
remote_path,
):
'''
Run the "key export" action for the given repository.
'''
if export_arguments.repository is None or borgmatic.config.validate.repositories_match(
repository, export_arguments.repository
):
logger.info(f'{repository.get("label", repository["path"])}: Exporting repository key')
borgmatic.borg.export_key.export_key(
repository['path'],
config,
local_borg_version,
export_arguments,
global_arguments,
local_path=local_path,
remote_path=remote_path,
)