浏览代码

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

Marian Beermann 8 年之前
父节点
当前提交
4e0422cdf0
共有 3 个文件被更改,包括 35 次插入18 次删除
  1. 1 0
      docs/changes.rst
  2. 4 3
      docs/usage.rst
  3. 30 15
      src/borg/archiver.py

+ 1 - 0
docs/changes.rst

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

+ 4 - 3
docs/usage.rst

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

+ 30 - 15
src/borg/archiver.py

@@ -251,6 +251,11 @@ class Archiver:
             logger.info('Key location: %s', key.find_key())
             logger.info('Key location: %s', key.find_key())
         return EXIT_SUCCESS
         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)
     @with_repository(lock=False, exclusive=False, manifest=False, cache=False)
     def do_key_export(self, args, repository):
     def do_key_export(self, args, repository):
         """Export the repository key for backup"""
         """Export the repository key for backup"""
@@ -1809,19 +1814,6 @@ class Archiver:
                                help="""show progress display while checking""")
                                help="""show progress display while checking""")
         self.add_archives_filters_args(subparser)
         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,
         subparser = subparsers.add_parser('key', parents=[common_parser], add_help=False,
                                           description="Manage a keyfile or repokey of a repository",
                                           description="Manage a keyfile or repokey of a repository",
                                           epilog="",
                                           epilog="",
@@ -1886,9 +1878,32 @@ class Archiver:
                                default=False,
                                default=False,
                                help='interactively import from a backup done with --paper')
                                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("""
         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
         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.
         mode). This is the same passphrase as you used to use for this repo before 1.0.