support more flags

This commit is contained in:
Divyansh Singh 2023-06-01 16:53:34 +05:30
parent 4c60bf84d7
commit 74aa28e027
2 changed files with 13 additions and 10 deletions

View File

@ -12,7 +12,7 @@ from borgmatic.borg.state import DEFAULT_BORGMATIC_SOURCE_DIRECTORY
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def get_config_paths(bootstrap_arguments, global_arguments, local_borg_version): def get_config_paths(bootstrap_arguments, global_arguments, local_borg_version):
borgmatic_source_directory = DEFAULT_BORGMATIC_SOURCE_DIRECTORY borgmatic_source_directory = bootstrap_arguments.borgmatic_source_directory or DEFAULT_BORGMATIC_SOURCE_DIRECTORY
borgmatic_manifest_path = os.path.expanduser( borgmatic_manifest_path = os.path.expanduser(
os.path.join(borgmatic_source_directory, 'bootstrap', 'configs-list.json') os.path.join(borgmatic_source_directory, 'bootstrap', 'configs-list.json')
) )
@ -34,7 +34,11 @@ def get_config_paths(bootstrap_arguments, global_arguments, local_borg_version):
extract_to_stdout=True, extract_to_stdout=True,
) )
manifest_data = json.loads(extract_process.stdout.read()) try:
manifest_data = json.loads(extract_process.stdout.read())
except json.decoder.JSONDecodeError as error:
logger.error('Error parsing manifest data: %s', error)
raise
return manifest_data['config_paths'] return manifest_data['config_paths']
@ -66,6 +70,9 @@ def run_bootstrap(bootstrap_arguments, global_arguments, local_borg_version):
local_borg_version, local_borg_version,
global_arguments, global_arguments,
extract_to_stdout=False, extract_to_stdout=False,
destination_path=bootstrap_arguments.destination,
strip_components=bootstrap_arguments.strip_components,
progress=bootstrap_arguments.progress,
) )

View File

@ -577,21 +577,17 @@ def make_parsers():
required=True, required=True,
) )
config_bootstrap_group.add_argument( config_bootstrap_group.add_argument(
'--archive', help='Name of archive to extract, defaults to "latest"' '--borgmatic-source-directory',
help='Path of the borgmatic source directory if other than the default',
) )
config_bootstrap_group.add_argument( config_bootstrap_group.add_argument(
'--path', '--archive', help='Name of archive to extract, defaults to "latest"'
'--restore-path',
metavar='PATH',
nargs='+',
dest='paths',
help='Paths to extract from archive, defaults to the entire archive',
) )
config_bootstrap_group.add_argument( config_bootstrap_group.add_argument(
'--destination', '--destination',
metavar='PATH', metavar='PATH',
dest='destination', dest='destination',
help='Directory to extract files into, defaults to the current directory', help='Directory to extract files into, defaults to /',
) )
config_bootstrap_group.add_argument( config_bootstrap_group.add_argument(
'--strip-components', '--strip-components',