1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-24 00:37:56 +00:00

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

This commit is contained in:
enkore 2017-05-12 20:34:45 +02:00 committed by GitHub
parent 6cd7d415ca
commit 9e6b8f67b9
3 changed files with 15 additions and 5 deletions

View file

@ -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)
---------------------------- ----------------------------

View file

@ -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`` Running ``borg init`` via a ``borg serve --append-only`` server will *not* create
server, the repository config will be created with a ``append_only=1`` entry. an append-only repository. Running ``borg init --append-only`` creates an append-only
This behaviour is subject to change in a later borg version. So, be aware of repository regardless of server settings.
it for now, but do not rely on it.
Example Example
+++++++ +++++++

View file

@ -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 @@ def open(self, path, create=False, lock_wait=None, lock=True, exclusive=None, ap
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