From 27bc73c23e9c575c4bf89cf355844c2b123b558f Mon Sep 17 00:00:00 2001 From: enkore Date: Mon, 3 Oct 2016 14:53:16 +0200 Subject: [PATCH] borg info : print general repo information (#1680) --- src/borg/archiver.py | 14 ++++++++++++-- src/borg/key.py | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 31b1f59dd..e469fcc99 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -920,7 +920,7 @@ class Archiver: if any((args.location.archive, args.first, args.last, args.prefix)): return self._info_archives(args, repository, manifest, key, cache) else: - return self._info_repository(cache) + return self._info_repository(repository, key, cache) def _info_archives(self, args, repository, manifest, key, cache): def format_cmdline(cmdline): @@ -957,7 +957,17 @@ class Archiver: print() return self.exit_code - def _info_repository(self, cache): + def _info_repository(self, repository, key, cache): + print('Repository ID: %s' % bin_to_hex(repository.id)) + if key.NAME == 'plaintext': + encrypted = 'No' + else: + encrypted = 'Yes (%s)' % key.NAME + print('Encrypted: %s' % encrypted) + if key.NAME == 'key file': + print('Key file: %s' % key.find_key()) + print('Cache: %s' % cache.path) + print(DASHES) print(STATS_HEADER) print(str(cache)) return self.exit_code diff --git a/src/borg/key.py b/src/borg/key.py index a61992928..d2d43039a 100644 --- a/src/borg/key.py +++ b/src/borg/key.py @@ -118,6 +118,7 @@ class KeyBase: class PlaintextKey(KeyBase): TYPE = 0x02 + NAME = 'plaintext' chunk_seed = 0 @@ -281,6 +282,7 @@ class PassphraseKey(AESKeyBase): # - --encryption=passphrase is an invalid argument now # This class is kept for a while to support migration from passphrase to repokey mode. TYPE = 0x01 + NAME = 'passphrase' iterations = 100000 # must not be changed ever! @classmethod @@ -432,6 +434,7 @@ class KeyfileKeyBase(AESKeyBase): class KeyfileKey(KeyfileKeyBase): TYPE = 0x00 + NAME = 'key file' FILE_ID = 'BORG_KEY' def sanity_check(self, filename, id): @@ -491,6 +494,7 @@ class KeyfileKey(KeyfileKeyBase): class RepoKey(KeyfileKeyBase): TYPE = 0x03 + NAME = 'repokey' def find_key(self): loc = self.repository._location.canonical_path()