|
@@ -42,11 +42,13 @@ def write_data_source_dumps_metadata(borgmatic_runtime_directory, hook_name, dum
|
|
|
borgmatic.actions.restore.Dump instances of dump metadata, write a metadata file describing all
|
|
|
of those dumps. This metadata is being dumped so that it's available upon restore, e.g. to
|
|
|
support the user selecting which data source(s) should be restored.
|
|
|
+
|
|
|
+ Raise ValueError if writing to the file results in an operating system error.
|
|
|
'''
|
|
|
dumps_metadata_path = os.path.join(borgmatic_runtime_directory, hook_name, 'dumps.json')
|
|
|
|
|
|
try:
|
|
|
- with open( dumps_metadata_path, 'w') as metadata_file:
|
|
|
+ with open(dumps_metadata_path, 'w') as metadata_file:
|
|
|
json.dump([dump._asdict() for dump in dumps_metadata], metadata_file, sort_keys=True)
|
|
|
except OSError as error:
|
|
|
raise ValueError(f'Error writing to dumps metadata at {dumps_metadata_path}: {error}')
|
|
@@ -56,6 +58,9 @@ def parse_data_source_dumps_metadata(dumps_json, dumps_metadata_path):
|
|
|
'''
|
|
|
Given a dumps metadata JSON string as extracted from an archive, parse it into a tuple of
|
|
|
borgmatic.actions.restore.Dump instances and return them.
|
|
|
+
|
|
|
+ Raise ValueError if parsing the JSON results in a JSON decode error or the data does not have
|
|
|
+ the expected keys.
|
|
|
'''
|
|
|
try:
|
|
|
return tuple(borgmatic.actions.restore.Dump(**dump) for dump in json.loads(dumps_json))
|