mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
Merge pull request #8291 from ThomasWaldmann/key-export-filename-master
key export fixes (master)
This commit is contained in:
commit
4fe94bf77e
2 changed files with 25 additions and 24 deletions
|
@ -45,4 +45,16 @@ Fully automated using environment variables:
|
|||
|
||||
.. include:: key_export.rst.inc
|
||||
|
||||
Examples
|
||||
~~~~~~~~
|
||||
::
|
||||
|
||||
borg key export > encrypted-key-backup
|
||||
borg key export --paper > encrypted-key-backup.txt
|
||||
borg key export --qr-html > encrypted-key-backup.html
|
||||
# Or pass the output file as an argument instead of redirecting stdout:
|
||||
borg key export encrypted-key-backup
|
||||
borg key export --paper encrypted-key-backup.txt
|
||||
borg key export --qr-html encrypted-key-backup.html
|
||||
|
||||
.. include:: key_import.rst.inc
|
||||
|
|
|
@ -93,18 +93,19 @@ def do_key_export(self, args, repository):
|
|||
"""Export the repository key for backup"""
|
||||
manager = KeyManager(repository)
|
||||
manager.load_keyblob()
|
||||
if args.paper:
|
||||
manager.export_paperkey(args.path)
|
||||
else:
|
||||
try:
|
||||
if os.path.isdir(args.path):
|
||||
raise IsADirectoryError
|
||||
if args.qr:
|
||||
manager.export_qr(args.path)
|
||||
else:
|
||||
manager.export(args.path)
|
||||
except IsADirectoryError:
|
||||
raise CommandError(f"'{args.path}' must be a file, not a directory")
|
||||
try:
|
||||
if args.path is not None and os.path.isdir(args.path):
|
||||
# on Windows, Python raises PermissionError instead of IsADirectoryError
|
||||
# (like on Unix) if the file to open is actually a directory.
|
||||
raise IsADirectoryError
|
||||
if args.paper:
|
||||
manager.export_paperkey(args.path)
|
||||
elif args.qr:
|
||||
manager.export_qr(args.path)
|
||||
else:
|
||||
manager.export(args.path)
|
||||
except IsADirectoryError:
|
||||
raise CommandError(f"'{args.path}' must be a file, not a directory")
|
||||
|
||||
@with_repository(lock=False, exclusive=False, manifest=False, cache=False)
|
||||
def do_key_import(self, args, repository):
|
||||
|
@ -160,18 +161,6 @@ def build_parser_keys(self, subparsers, common_parser, mid_common_parser):
|
|||
repository in the config file. A backup is thus not strictly needed,
|
||||
but guards against the repository becoming inaccessible if the file
|
||||
is damaged for some reason.
|
||||
|
||||
Examples::
|
||||
|
||||
borg key export /path/to/repo > encrypted-key-backup
|
||||
borg key export --paper /path/to/repo > encrypted-key-backup.txt
|
||||
borg key export --qr-html /path/to/repo > encrypted-key-backup.html
|
||||
# Or pass the output file as an argument instead of redirecting stdout:
|
||||
borg key export /path/to/repo encrypted-key-backup
|
||||
borg key export --paper /path/to/repo encrypted-key-backup.txt
|
||||
borg key export --qr-html /path/to/repo encrypted-key-backup.html
|
||||
|
||||
|
||||
"""
|
||||
)
|
||||
subparser = key_parsers.add_parser(
|
||||
|
|
Loading…
Reference in a new issue