From 4e0422cdf0de134b11ebb67b80bb5bb242c4a31e Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Sat, 4 Feb 2017 15:01:23 +0100 Subject: [PATCH] Move change-passphrase to the "key" group (but leave old name, too) --- docs/changes.rst | 1 + docs/usage.rst | 7 ++++--- src/borg/archiver.py | 45 +++++++++++++++++++++++++++++--------------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index b5dc76f71..084a42d6b 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -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: diff --git a/docs/usage.rst b/docs/usage.rst index 1e3ffebf1..db1acc83c 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -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. diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 0c8cf2011..680ff1e91 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -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.