1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

check archives: improve error handling for corrupt archive metadata block

this is similar to #4777.

borg check must not crash if an archive metadata block does not decrypt.

Instead, report the archive_id, remove the archive from the manifest and skip to the next archive.
This commit is contained in:
Thomas Waldmann 2022-04-07 01:35:35 +02:00
parent ced3d8b9d5
commit b5f7f2376c

View file

@ -2007,13 +2007,19 @@ def valid_item(obj):
logger.info(f'Analyzing archive {info.name} ({i + 1}/{num_archives})') logger.info(f'Analyzing archive {info.name} ({i + 1}/{num_archives})')
archive_id = info.id archive_id = info.id
if archive_id not in self.chunks: if archive_id not in self.chunks:
logger.error('Archive metadata block is missing!') logger.error('Archive metadata block %s is missing!', bin_to_hex(archive_id))
self.error_found = True self.error_found = True
del self.manifest.archives[info.name] del self.manifest.archives[info.name]
continue continue
mark_as_possibly_superseded(archive_id) mark_as_possibly_superseded(archive_id)
cdata = self.repository.get(archive_id) cdata = self.repository.get(archive_id)
try:
data = self.key.decrypt(archive_id, cdata) data = self.key.decrypt(archive_id, cdata)
except IntegrityError as integrity_error:
logger.error('Archive metadata block %s is corrupted: %s', bin_to_hex(archive_id), integrity_error)
self.error_found = True
del self.manifest.archives[info.name]
continue
archive = ArchiveItem(internal_dict=msgpack.unpackb(data)) archive = ArchiveItem(internal_dict=msgpack.unpackb(data))
if archive.version != 1: if archive.version != 1:
raise Exception('Unknown archive metadata version') raise Exception('Unknown archive metadata version')