Selaa lähdekoodia

serve: ignore --append-only when creating a repository (#2501)

enkore 8 vuotta sitten
vanhempi
sitoutus
9e6b8f67b9
3 muutettua tiedostoa jossa 15 lisäystä ja 5 poistoa
  1. 3 0
      docs/changes.rst
  2. 3 4
      docs/usage.rst
  3. 9 1
      src/borg/remote.py

+ 3 - 0
docs/changes.rst

@@ -136,6 +136,9 @@ Compatibility notes:
 - Repositories in a repokey mode with a blank passphrase are now treated
 - Repositories in a repokey mode with a blank passphrase are now treated
   as unencrypted repositories for security checks
   as unencrypted repositories for security checks
   (e.g. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK).
   (e.g. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK).
+- Running "borg init" via a "borg serve --append-only" server will *not* create
+  an append-only repository anymore. Use "borg init --append-only" to initialize
+  an append-only repository.
 
 
 Version 1.1.0b5 (2017-04-30)
 Version 1.1.0b5 (2017-04-30)
 ----------------------------
 ----------------------------

+ 3 - 4
docs/usage.rst

@@ -677,10 +677,9 @@ in ``.ssh/authorized_keys`` ::
     command="borg serve --append-only ..." ssh-rsa <key used for not-always-trustable backup clients>
     command="borg serve --append-only ..." ssh-rsa <key used for not-always-trustable backup clients>
     command="borg serve ..." ssh-rsa <key used for backup management>
     command="borg serve ..." ssh-rsa <key used for backup management>
 
 
-Please note that if you run ``borg init`` via a ``borg serve --append-only``
-server, the repository config will be created with a ``append_only=1`` entry.
-This behaviour is subject to change in a later borg version. So, be aware of
-it for now, but do not rely on it.
+Running ``borg init`` via a ``borg serve --append-only`` server will *not* create
+an append-only repository. Running ``borg init --append-only`` creates an append-only
+repository regardless of server settings.
 
 
 Example
 Example
 +++++++
 +++++++

+ 9 - 1
src/borg/remote.py

@@ -180,6 +180,10 @@ class RepositoryServer:  # pragma: no cover
     def __init__(self, restrict_to_paths, append_only):
     def __init__(self, restrict_to_paths, append_only):
         self.repository = None
         self.repository = None
         self.restrict_to_paths = restrict_to_paths
         self.restrict_to_paths = restrict_to_paths
+        # This flag is parsed from the serve command line via Archiver.do_serve,
+        # i.e. it reflects local system policy and generally ranks higher than
+        # whatever the client wants, except when initializing a new repository
+        # (see RepositoryServer.open below).
         self.append_only = append_only
         self.append_only = append_only
         self.client_version = parse_version('1.0.8')  # fallback version if client is too old to send version information
         self.client_version = parse_version('1.0.8')  # fallback version if client is too old to send version information
 
 
@@ -345,8 +349,12 @@ class RepositoryServer:  # pragma: no cover
                     break
                     break
             else:
             else:
                 raise PathNotAllowed(path)
                 raise PathNotAllowed(path)
+        # "borg init" on "borg serve --append-only" (=self.append_only) does not create an append only repo,
+        # while "borg init --append-only" (=append_only) does, regardless of the --append-only (self.append_only)
+        # flag for serve.
+        append_only = (not create and self.append_only) or append_only
         self.repository = Repository(path, create, lock_wait=lock_wait, lock=lock,
         self.repository = Repository(path, create, lock_wait=lock_wait, lock=lock,
-                                     append_only=self.append_only or append_only,
+                                     append_only=append_only,
                                      exclusive=exclusive)
                                      exclusive=exclusive)
         self.repository.__enter__()  # clean exit handled by serve() method
         self.repository.__enter__()  # clean exit handled by serve() method
         return self.repository.id
         return self.repository.id