mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-09 21:57:24 +00:00
upgrade --check-archives-tam: check archives tam status
This is a read-only variation of --archives-tam: - it only checks / displays the current status - it does not add / fix the archive TAMs
This commit is contained in:
parent
b1053eefa5
commit
965c87bb0a
1 changed files with 22 additions and 14 deletions
|
@ -1609,10 +1609,11 @@ class Archiver:
|
||||||
str(cache),
|
str(cache),
|
||||||
DASHES, logger=logging.getLogger('borg.output.stats'))
|
DASHES, logger=logging.getLogger('borg.output.stats'))
|
||||||
|
|
||||||
@with_repository(fake=('tam', 'disable_tam', 'archives_tam'), invert_fake=True, manifest=False, exclusive=True)
|
@with_repository(fake=('tam', 'disable_tam', 'archives_tam', 'check_archives_tam'), invert_fake=True, manifest=False, exclusive=True)
|
||||||
def do_upgrade(self, args, repository, manifest=None, key=None):
|
def do_upgrade(self, args, repository, manifest=None, key=None):
|
||||||
"""upgrade a repository from a previous version"""
|
"""upgrade a repository from a previous version"""
|
||||||
if args.archives_tam:
|
if args.archives_tam or args.check_archives_tam:
|
||||||
|
read_only = args.check_archives_tam
|
||||||
manifest, key = Manifest.load(repository, (Manifest.Operation.CHECK,), force_tam_not_required=args.force)
|
manifest, key = Manifest.load(repository, (Manifest.Operation.CHECK,), force_tam_not_required=args.force)
|
||||||
with Cache(repository, key, manifest) as cache:
|
with Cache(repository, key, manifest) as cache:
|
||||||
stats = Statistics()
|
stats = Statistics()
|
||||||
|
@ -1622,20 +1623,25 @@ class Archiver:
|
||||||
cdata = repository.get(archive_id)
|
cdata = repository.get(archive_id)
|
||||||
data = key.decrypt(archive_id, cdata)
|
data = key.decrypt(archive_id, cdata)
|
||||||
archive, verified, _ = key.unpack_and_verify_archive(data, force_tam_not_required=True)
|
archive, verified, _ = key.unpack_and_verify_archive(data, force_tam_not_required=True)
|
||||||
if not verified: # we do not have an archive TAM yet -> add TAM now!
|
if not verified:
|
||||||
archive = ArchiveItem(internal_dict=archive)
|
if not read_only:
|
||||||
archive.cmdline = [safe_decode(arg) for arg in archive.cmdline]
|
# we do not have an archive TAM yet -> add TAM now!
|
||||||
data = key.pack_and_authenticate_metadata(archive.as_dict(), context=b'archive')
|
archive = ArchiveItem(internal_dict=archive)
|
||||||
new_archive_id = key.id_hash(data)
|
archive.cmdline = [safe_decode(arg) for arg in archive.cmdline]
|
||||||
cache.add_chunk(new_archive_id, data, stats)
|
data = key.pack_and_authenticate_metadata(archive.as_dict(), context=b'archive')
|
||||||
cache.chunk_decref(archive_id, stats)
|
new_archive_id = key.id_hash(data)
|
||||||
manifest.archives[info.name] = (new_archive_id, info.ts)
|
cache.add_chunk(new_archive_id, data, stats)
|
||||||
print(f"Added archive TAM: {archive_formatted} -> [{bin_to_hex(new_archive_id)}]")
|
cache.chunk_decref(archive_id, stats)
|
||||||
|
manifest.archives[info.name] = (new_archive_id, info.ts)
|
||||||
|
print(f"Added archive TAM: {archive_formatted} -> [{bin_to_hex(new_archive_id)}]")
|
||||||
|
else:
|
||||||
|
print(f"Archive TAM missing: {archive_formatted}")
|
||||||
else:
|
else:
|
||||||
print(f"Archive TAM present: {archive_formatted}")
|
print(f"Archive TAM present: {archive_formatted}")
|
||||||
manifest.write()
|
if not read_only:
|
||||||
repository.commit(compact=False)
|
manifest.write()
|
||||||
cache.commit()
|
repository.commit(compact=False)
|
||||||
|
cache.commit()
|
||||||
elif args.tam:
|
elif args.tam:
|
||||||
manifest, key = Manifest.load(repository, (Manifest.Operation.CHECK,), force_tam_not_required=args.force)
|
manifest, key = Manifest.load(repository, (Manifest.Operation.CHECK,), force_tam_not_required=args.force)
|
||||||
if not manifest.tam_verified or not manifest.config.get(b'tam_required', False):
|
if not manifest.tam_verified or not manifest.config.get(b'tam_required', False):
|
||||||
|
@ -4986,6 +4992,8 @@ class Archiver:
|
||||||
help='Enable manifest authentication (in key and cache) (Borg 1.0.9 and later).')
|
help='Enable manifest authentication (in key and cache) (Borg 1.0.9 and later).')
|
||||||
subparser.add_argument('--disable-tam', dest='disable_tam', action='store_true',
|
subparser.add_argument('--disable-tam', dest='disable_tam', action='store_true',
|
||||||
help='Disable manifest authentication (in key and cache).')
|
help='Disable manifest authentication (in key and cache).')
|
||||||
|
subparser.add_argument('--check-archives-tam', dest='check_archives_tam', action='store_true',
|
||||||
|
help='check TAM authentication for all archives.')
|
||||||
subparser.add_argument('--archives-tam', dest='archives_tam', action='store_true',
|
subparser.add_argument('--archives-tam', dest='archives_tam', action='store_true',
|
||||||
help='add TAM authentication for all archives.')
|
help='add TAM authentication for all archives.')
|
||||||
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
|
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
|
||||||
|
|
Loading…
Add table
Reference in a new issue