Move change-passphrase to the "key" group (but leave old name, too)

This commit is contained in:
Marian Beermann 2017-02-04 15:01:23 +01:00
parent 5fe32866e6
commit 4e0422cdf0
3 changed files with 35 additions and 18 deletions

View File

@ -134,6 +134,7 @@ Version 1.1.0b4 (not released yet)
Compatibility notes:
- Moved "borg migrate-to-repokey" to "borg key migrate-to-repokey".
- "borg change-passphrase" is deprecated, use "borg key change-passphrase" instead.
New features:

View File

@ -687,8 +687,9 @@ borgfs
.. include:: usage/key_import.rst.inc
.. _borg-change-passphrase:
.. include:: usage/change-passphrase.rst.inc
.. include:: usage/key_change-passphrase.rst.inc
Examples
~~~~~~~~
@ -707,7 +708,7 @@ Examples
Done.
# Change key file passphrase
$ borg change-passphrase -v /path/to/repo
$ borg key change-passphrase -v /path/to/repo
Enter passphrase for key /root/.config/borg/keys/mnt_backup:
Enter new passphrase:
Enter same passphrase again:
@ -720,7 +721,7 @@ Fully automated using environment variables:
$ BORG_NEW_PASSPHRASE=old borg init repo
# now "old" is the current passphrase.
$ BORG_PASSPHRASE=old BORG_NEW_PASSPHRASE=new borg change-passphrase repo
$ BORG_PASSPHRASE=old BORG_NEW_PASSPHRASE=new borg key change-passphrase repo
# now "new" is the current passphrase.

View File

@ -251,6 +251,11 @@ class Archiver:
logger.info('Key location: %s', key.find_key())
return EXIT_SUCCESS
def do_change_passphrase_deprecated(self, args):
logger.warning('"borg change-passphrase" is deprecated and will be removed in Borg 1.2.\n'
'Use "borg key change-passphrase" instead.')
return self.do_change_passphrase(args)
@with_repository(lock=False, exclusive=False, manifest=False, cache=False)
def do_key_export(self, args, repository):
"""Export the repository key for backup"""
@ -1809,19 +1814,6 @@ class Archiver:
help="""show progress display while checking""")
self.add_archives_filters_args(subparser)
change_passphrase_epilog = textwrap.dedent("""
The key files used for repository encryption are optionally passphrase
protected. This command can be used to change this passphrase.
""")
subparser = subparsers.add_parser('change-passphrase', parents=[common_parser], add_help=False,
description=self.do_change_passphrase.__doc__,
epilog=change_passphrase_epilog,
formatter_class=argparse.RawDescriptionHelpFormatter,
help='change repository passphrase')
subparser.set_defaults(func=self.do_change_passphrase)
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
type=location_validator(archive=False))
subparser = subparsers.add_parser('key', parents=[common_parser], add_help=False,
description="Manage a keyfile or repokey of a repository",
epilog="",
@ -1886,9 +1878,32 @@ class Archiver:
default=False,
help='interactively import from a backup done with --paper')
change_passphrase_epilog = textwrap.dedent("""
The key files used for repository encryption are optionally passphrase
protected. This command can be used to change this passphrase.
""")
subparser = key_parsers.add_parser('change-passphrase', parents=[common_parser], add_help=False,
description=self.do_change_passphrase.__doc__,
epilog=change_passphrase_epilog,
formatter_class=argparse.RawDescriptionHelpFormatter,
help='change repository passphrase')
subparser.set_defaults(func=self.do_change_passphrase)
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
type=location_validator(archive=False))
# Borg 1.0 alias for change passphrase (without the "key" subcommand)
subparser = subparsers.add_parser('change-passphrase', parents=[common_parser], add_help=False,
description=self.do_change_passphrase.__doc__,
epilog=change_passphrase_epilog,
formatter_class=argparse.RawDescriptionHelpFormatter,
help='change repository passphrase')
subparser.set_defaults(func=self.do_change_passphrase_deprecated)
subparser.add_argument('location', metavar='REPOSITORY', nargs='?', default='',
type=location_validator(archive=False))
migrate_to_repokey_epilog = textwrap.dedent("""
This command migrates a repository from passphrase mode (not supported any
more) to repokey mode.
This command migrates a repository from passphrase mode (removed in Borg 1.0)
to repokey mode.
You will be first asked for the repository passphrase (to open it in passphrase
mode). This is the same passphrase as you used to use for this repo before 1.0.