diff options
author | Thomas Waldmann <tw@waldmann-edv.de> | 2016-04-10 01:13:35 +0200 |
---|---|---|
committer | Thomas Waldmann <tw@waldmann-edv.de> | 2016-04-10 01:13:35 +0200 |
commit | cece7f9e6de77fc83a50737d97f1b445a7f60ba3 (patch) | |
tree | 7fe7a98fd16c76a0502218f92c69b60d03cd7d43 | |
parent | d8f2d19da8b73e6097a5ffa7a6612a186921b8a2 (diff) | |
parent | 6a3f2d78644567f6b105414916b449eaa4409540 (diff) |
merged 1.0-maint into master
29 files changed, 323 insertions, 207 deletions
diff --git a/borg/archive.py b/borg/archive.py index 80b4fd1af..a80c4db3d 100644 --- a/borg/archive.py +++ b/borg/archive.py @@ -917,7 +917,7 @@ class ArchiveChecker: for id_ in unused: self.repository.delete(id_) else: - logger.warning('Orphaned objects check skipped (needs all archives checked).') + logger.info('Orphaned objects check skipped (needs all archives checked).') def finish(self, save_space=False): if self.repair: diff --git a/borg/archiver.py b/borg/archiver.py index 38446e49a..c17447444 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -704,7 +704,6 @@ class Archiver: """List archive or repository contents""" if args.location.archive: matcher, _ = self.build_matcher(args.excludes, args.paths) - with Cache(repository, key, manifest, lock_wait=self.lock_wait) as cache: archive = Archive(repository, key, manifest, args.location.archive, cache=cache) @@ -1016,12 +1015,21 @@ class Archiver: def build_parser(self, args=None, prog=None): common_parser = argparse.ArgumentParser(add_help=False, prog=prog) - common_parser.add_argument('-v', '--verbose', '--info', dest='log_level', + common_parser.add_argument('--critical', dest='log_level', + action='store_const', const='critical', default='warning', + help='work on log level CRITICAL') + common_parser.add_argument('--error', dest='log_level', + action='store_const', const='error', default='warning', + help='work on log level ERROR') + common_parser.add_argument('--warning', dest='log_level', + action='store_const', const='warning', default='warning', + help='work on log level WARNING (default)') + common_parser.add_argument('--info', '-v', '--verbose', dest='log_level', action='store_const', const='info', default='warning', - help='enable informative (verbose) output, work on log level INFO') + help='work on log level INFO') common_parser.add_argument('--debug', dest='log_level', action='store_const', const='debug', default='warning', - help='enable debug output, work on log level DEBUG') + help='work on log level DEBUG') common_parser.add_argument('--lock-wait', dest='lock_wait', type=int, metavar='N', default=1, help='wait for the lock, but max. N seconds (default: %(default)d).') common_parser.add_argument('--show-version', dest='show_version', action='store_true', default=False, diff --git a/borg/key.py b/borg/key.py index eb452b77a..54cbfb451 100644 --- a/borg/key.py +++ b/borg/key.py @@ -18,6 +18,10 @@ import msgpack PREFIX = b'\0' * 8 +class PassphraseWrong(Error): + """passphrase supplied in BORG_PASSPHRASE is incorrect""" + + class PasswordRetriesExceeded(Error): """exceeded the maximum password retries""" @@ -285,13 +289,19 @@ class KeyfileKeyBase(AESKeyBase): key = cls(repository) target = key.find_key() prompt = 'Enter passphrase for key %s: ' % target - passphrase = Passphrase.env_passphrase(default='') - for retry in range(1, 4): - if key.load(target, passphrase): - break - passphrase = Passphrase.getpass(prompt) + passphrase = Passphrase.env_passphrase() + if passphrase is None: + passphrase = Passphrase() + if not key.load(target, passphrase): + for retry in range(0, 3): + passphrase = Passphrase.getpass(prompt) + if key.load(target, passphrase): + break + else: + raise PasswordRetriesExceeded else: - raise PasswordRetriesExceeded + if not key.load(target, passphrase): + raise PassphraseWrong num_blocks = num_aes_blocks(len(manifest_data) - 41) key.init_ciphers(PREFIX + long_to_bytes(key.extract_nonce(manifest_data) + num_blocks)) return key diff --git a/borg/remote.py b/borg/remote.py index 6c8aaacdf..051b9c0e8 100644 --- a/borg/remote.py +++ b/borg/remote.py @@ -82,6 +82,7 @@ class RepositoryServer: # pragma: no cover unpacker.feed(data) for unpacked in unpacker: if not (isinstance(unpacked, tuple) and len(unpacked) == 4): + self.repository.close() raise Exception("Unexpected RPC data format.") type, msgid, method, args = unpacked method = method.decode('ascii') @@ -94,8 +95,12 @@ class RepositoryServer: # pragma: no cover f = getattr(self.repository, method) res = f(*args) except BaseException as e: - logging.exception('Borg %s: exception in RPC call:', __version__) - logging.error(sysinfo()) + # These exceptions are reconstructed on the client end in RemoteRepository.call_many(), + # and will be handled just like locally raised exceptions. Suppress the remote traceback + # for these, except ErrorWithTraceback, which should always display a traceback. + if not isinstance(e, (Repository.DoesNotExist, Repository.AlreadyExists, PathNotAllowed)): + logging.exception('Borg %s: exception in RPC call:', __version__) + logging.error(sysinfo()) exc = "Remote Exception (see remote log for the traceback)" os.write(stdout_fd, msgpack.packb((1, msgid, e.__class__.__name__, exc))) else: @@ -164,7 +169,11 @@ class RemoteRepository: raise ConnectionClosedWithHint('Is borg working on the server?') from None if version != RPC_PROTOCOL_VERSION: raise Exception('Server insisted on using unsupported protocol version %d' % version) - self.id = self.call('open', location.path, create, lock_wait, lock) + try: + self.id = self.call('open', self.location.path, create, lock_wait, lock) + except Exception: + self.close() + raise def __del__(self): if self.p: @@ -195,6 +204,10 @@ class RemoteRepository: opts.append('--info') elif root_logger.isEnabledFor(logging.WARNING): pass # warning is default + elif root_logger.isEnabledFor(logging.ERROR): + opts.append('--error') + elif root_logger.isEnabledFor(logging.CRITICAL): + opts.append('--critical') else: raise ValueError('log level missing, fix this code') if testing: diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index d256cd2aa..2a2c95558 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -60,6 +60,7 @@ def exec_cmd(*args, archiver=None, fork=False, exe=None, **kw): sys.stdout = sys.stderr = output = StringIO() if archiver is None: archiver = Archiver() + archiver.exit_code = EXIT_SUCCESS args = archiver.parse_args(list(args)) ret = archiver.run(args) return ret, output.getvalue() @@ -790,7 +791,6 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.cmd('create', self.repository_location + '::test.2', 'input') os.environ['BORG_DELETE_I_KNOW_WHAT_I_AM_DOING'] = 'no' self.cmd('delete', self.repository_location, exit_code=2) - self.archiver.exit_code = 0 assert os.path.exists(self.repository_path) os.environ['BORG_DELETE_I_KNOW_WHAT_I_AM_DOING'] = 'YES' self.cmd('delete', self.repository_location) diff --git a/docs/api.rst b/docs/api.rst index bdef963a5..7f56c4f77 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -2,94 +2,94 @@ API Documentation ================= -.. automodule:: borg.xattr +.. automodule:: borg.platform :members: :undoc-members: -.. automodule:: borg.hash_sizes +.. automodule:: borg.shellpattern :members: :undoc-members: -.. automodule:: borg.archive +.. automodule:: borg.locking :members: :undoc-members: -.. automodule:: borg.repository +.. automodule:: borg.hash_sizes :members: :undoc-members: -.. automodule:: borg.platform +.. automodule:: borg.logger :members: :undoc-members: -.. automodule:: borg.cache +.. automodule:: borg.remote :members: :undoc-members: -.. automodule:: borg.helpers +.. automodule:: borg.fuse :members: :undoc-members: -.. automodule:: borg.lrucache +.. automodule:: borg.archive :members: :undoc-members: -.. automodule:: borg.key +.. automodule:: borg.helpers :members: :undoc-members: -.. automodule:: borg.upgrader +.. automodule:: borg.lrucache :members: :undoc-members: -.. automodule:: borg.shellpattern +.. automodule:: borg.xattr :members: :undoc-members: -.. automodule:: borg.locking +.. automodule:: borg.archiver :members: :undoc-members: -.. automodule:: borg.fuse +.. automodule:: borg.repository :members: :undoc-members: -.. automodule:: borg.logger +.. automodule:: borg.cache :members: :undoc-members: -.. automodule:: borg.archiver +.. automodule:: borg.key :members: :undoc-members: -.. automodule:: borg.remote +.. automodule:: borg.upgrader :members: :undoc-members: -.. automodule:: borg.chunker +.. automodule:: borg.platform_darwin :members: :undoc-members: -.. automodule:: borg.platform_freebsd +.. automodule:: borg.compress :members: :undoc-members: -.. automodule:: borg.hashindex +.. automodule:: borg.platform_linux :members: :undoc-members: -.. automodule:: borg.compress +.. automodule:: borg.crypto :members: :undoc-members: -.. automodule:: borg.platform_linux +.. automodule:: borg.chunker :members: :undoc-members: -.. automodule:: borg.crypto +.. automodule:: borg.platform_freebsd :members: :undoc-members: -.. automodule:: borg.platform_darwin +.. automodule:: borg.hashindex :members: :undoc-members: diff --git a/docs/changes.rst b/docs/changes.rst index e0e0d3386..5589ea41c 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -1,40 +1,55 @@ Changelog ========= -Version 1.0.1 (not released yet) --------------------------------- +Version 1.0.1 +------------- New features: -Usually there are no new features in a bugfix release, but these 2 were added -to get them out quickly - as both positively affect your safety/security: - -- append-only mode for repositories, #809, #36 - (please read the docs about how this can improve your security) -- implement password roundtrip, #695 (make sure the user can know/verify the - encryption key password/passphrase, to avoid double-typos, wrong keyboard - layout or locale/encoding issues) +Usually there are no new features in a bugfix release, but these were added +due to their high impact on security/safety/speed or because they are fixes +also: + +- append-only mode for repositories, #809, #36 (see docs) +- borg create: add --ignore-inode option to make borg detect unmodified files + even if your filesystem does not have stable inode numbers (like sshfs and + possibly CIFS). +- add options --warning, --error, --critical for missing log levels, #826. + it's not recommended to suppress warnings or errors, but the user may decide + this on his own. + note: --warning is not given to borg serve so a <= 1.0.0 borg will still + work as server (it is not needed as it is the default). + do not use --error or --critical when using a <= 1.0.0 borg server. Bug fixes: - fix silently skipping EIO, #748 -- do not sleep for >60s while waiting for lock, fixes #773 +- add context manager for Repository (avoid orphan repository locks), #285 +- do not sleep for >60s while waiting for lock, #773 - unpack file stats before passing to FUSE - fix build on illumos - don't try to backup doors or event ports (Solaris and derivates) -- fix capitalization, add ellipses, change log level to debug for 2 messages, fixes #798 -- remove useless/misleading libc version display, fixes #738 +- remove useless/misleading libc version display, #738 +- test suite: reset exit code of persistent archiver, #844 +- RemoteRepository: clean up pipe if remote open() fails +- Remote: don't print tracebacks for Error exceptions handled downstream, #792 +- if BORG_PASSPHRASE is present but wrong, don't prompt for password, but fail + instead, #791 +- ArchiveChecker: move "orphaned objects check skipped" to INFO log level, #826 +- fix capitalization, add ellipses, change log level to debug for 2 messages, + #798 Other changes: - update llfuse requirement, llfuse 1.0 works -- update OS / dist packages on build machines, fixes #717 +- update OS / dist packages on build machines, #717 +- prefer showing --info over -v in usage help, #859 - docs: - fix cygwin requirements (gcc-g++) - - document how to debug / file filesystem issues, fixes #664 + - document how to debug / file filesystem issues, #664 - fix reproducible build of api docs - - RTD theme: CSS !important overwrite. Fix borgbackup/borg#727 + - RTD theme: CSS !important overwrite, #727 - Document logo font. Recreate logo png. Remove GIMP logo file. diff --git a/docs/usage.rst b/docs/usage.rst index 255456477..6c5d35d3c 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -16,19 +16,31 @@ Type of log output The log level of the builtin logging configuration defaults to WARNING. This is because we want |project_name| to be mostly silent and only output -warnings (plus errors and critical messages). +warnings, errors and critical messages. -Use ``--verbose`` or ``--info`` to set INFO (you will get informative output then -additionally to warnings, errors, critical messages). -Use ``--debug`` to set DEBUG to get output made for debugging. +Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL -All log messages created with at least the set level will be output. +Use ``--debug`` to set DEBUG log level - +to get debug, info, warning, error and critical level output. -Log levels: DEBUG < INFO < WARNING < ERROR < CRITICAL +Use ``--info`` (or ``-v`` or ``--verbose``) to set INFO log level - +to get info, warning, error and critical level output. + +Use ``--warning`` (default) to set WARNING log level - +to get warning, error and critical level output. + +Use ``--error`` to set ERROR log level - +to get error and critical level output. + +Use ``--critical`` to set CRITICAL log level - +to get critical level output. While you can set misc. log levels, do not expect that every command will give different output on different log levels - it's just a possibility. +.. warning:: Options --critical and --error are provided for completeness, + their usage is not recommended as you might miss important information. + .. warning:: While some options (like ``--stats`` or ``--list``) will emit more informational messages, you have to use INFO (or lower) log level to make them show up in log output. Use ``-v`` or a logging configuration. diff --git a/docs/usage/break-lock.rst.inc b/docs/usage/break-lock.rst.inc index 34cb715ce..f0dd5636f 100644 --- a/docs/usage/break-lock.rst.inc +++ b/docs/usage/break-lock.rst.inc @@ -4,9 +4,9 @@ borg break-lock --------------- :: - usage: borg break-lock [-h] [-v] [--debug] [--lock-wait N] [--show-version] - [--show-rc] [--no-files-cache] [--umask M] - [--remote-path PATH] + usage: borg break-lock [-h] [--critical] [--error] [--warning] [--info] + [--debug] [--lock-wait N] [--show-version] [--show-rc] + [--no-files-cache] [--umask M] [--remote-path PATH] REPOSITORY Break the repository lock (e.g. in case it was left by a dead borg. @@ -16,10 +16,12 @@ borg break-lock optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/change-passphrase.rst.inc b/docs/usage/change-passphrase.rst.inc index a054bacd1..bbf32ddc9 100644 --- a/docs/usage/change-passphrase.rst.inc +++ b/docs/usage/change-passphrase.rst.inc @@ -4,9 +4,10 @@ borg change-passphrase ---------------------- :: - usage: borg change-passphrase [-h] [-v] [--debug] [--lock-wait N] - [--show-version] [--show-rc] [--no-files-cache] - [--umask M] [--remote-path PATH] + usage: borg change-passphrase [-h] [--critical] [--error] [--warning] [--info] + [--debug] [--lock-wait N] [--show-version] + [--show-rc] [--no-files-cache] [--umask M] + [--remote-path PATH] [REPOSITORY] Change repository key file passphrase @@ -16,10 +17,12 @@ borg change-passphrase optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/check.rst.inc b/docs/usage/check.rst.inc index ff4690f19..52355ab66 100644 --- a/docs/usage/check.rst.inc +++ b/docs/usage/check.rst.inc @@ -4,10 +4,11 @@ borg check ---------- :: - usage: borg check [-h] [-v] [--debug] [--lock-wait N] [--show-version] - [--show-rc] [--no-files-cache] [--umask M] - [--remote-path PATH] [--repository-only] [--archives-only] - [--repair] [--save-space] [--last N] [-P PREFIX] + usage: borg check [-h] [--critical] [--error] [--warning] [--info] [--debug] + [--lock-wait N] [--show-version] [--show-rc] + [--no-files-cache] [--umask M] [--remote-path PATH] + [--repository-only] [--archives-only] [--repair] + [--save-space] [--last N] [-P PREFIX] [REPOSITORY_OR_ARCHIVE] Check repository consistency @@ -18,10 +19,12 @@ borg check optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/comment.rst.inc b/docs/usage/comment.rst.inc index 47af3cf0d..b15edf378 100644 --- a/docs/usage/comment.rst.inc +++ b/docs/usage/comment.rst.inc @@ -4,23 +4,25 @@ borg comment ------------ :: - usage: borg comment [-h] [-v] [--debug] [--lock-wait N] [--show-version] - [--show-rc] [--no-files-cache] [--umask M] - [--remote-path PATH] + usage: borg comment [-h] [--critical] [--error] [--warning] [--info] [--debug] + [--lock-wait N] [--show-version] [--show-rc] + [--no-files-cache] [--umask M] [--remote-path PATH] ARCHIVE COMMENT Set the archive comment positional arguments: - ARCHIVE archive to rename + ARCHIVE archive to modify COMMENT the new archive comment optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/create.rst.inc b/docs/usage/create.rst.inc index 098c023bc..974770a99 100644 --- a/docs/usage/create.rst.inc +++ b/docs/usage/create.rst.inc @@ -4,9 +4,10 @@ borg create ----------- :: - usage: borg create [-h] [-v] [--debug] [--lock-wait N] [--show-version] - [--show-rc] [--no-files-cache] [--umask M] - [--remote-path PATH] [--comment COMMENT] [-s] [-p] [--list] + usage: borg create [-h] [--critical] [--error] [--warning] [--info] [--debug] + [--lock-wait N] [--show-version] [--show-rc] + [--no-files-cache] [--umask M] [--remote-path PATH] + [--comment COMMENT] [-s] [-p] [--list] [--filter STATUSCHARS] [-e PATTERN] [--exclude-from EXCLUDEFILE] [--exclude-caches] [--exclude-if-present FILENAME] [--keep-tag-files] @@ -25,10 +26,12 @@ borg create optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/debug-delete-obj.rst.inc b/docs/usage/debug-delete-obj.rst.inc index 228385d6f..fa4c677c3 100644 --- a/docs/usage/debug-delete-obj.rst.inc +++ b/docs/usage/debug-delete-obj.rst.inc @@ -4,9 +4,10 @@ borg debug-delete-obj --------------------- :: - usage: borg debug-delete-obj [-h] [-v] [--debug] [--lock-wait N] - [--show-version] [--show-rc] [--no-files-cache] - [--umask M] [--remote-path PATH] + usage: borg debug-delete-obj [-h] [--critical] [--error] [--warning] [--info] + [--debug] [--lock-wait N] [--show-version] + [--show-rc] [--no-files-cache] [--umask M] + [--remote-path PATH] [REPOSITORY] IDs [IDs ...] delete the objects with the given IDs from the repo @@ -17,10 +18,12 @@ borg debug-delete-obj optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/debug-dump-archive-items.rst.inc b/docs/usage/debug-dump-archive-items.rst.inc index 4d51dc549..10bb16f6f 100644 --- a/docs/usage/debug-dump-archive-items.rst.inc +++ b/docs/usage/debug-dump-archive-items.rst.inc @@ -4,7 +4,8 @@ borg debug-dump-archive-items ----------------------------- :: - usage: borg debug-dump-archive-items [-h] [-v] [--debug] [--lock-wait N] + usage: borg debug-dump-archive-items [-h] [--critical] [--error] [--warning] + [--info] [--debug] [--lock-wait N] [--show-version] [--show-rc] [--no-files-cache] [--umask M] [--remote-path PATH] @@ -17,10 +18,12 @@ borg debug-dump-archive-items optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) diff --git a/docs/usage/debug-get-obj.rst.inc b/docs/usage/debug-get-obj.rst.inc index f86726c19..aa2e94744 100644 --- a/docs/usage/debug-get-obj.rst.inc +++ b/docs/usage/debug-get-obj.rst.inc @@ -4,7 +4,8 @@ borg debug-get-obj ------------------ :: - usage: borg debug-get-obj [-h] [-v] [--debug] [--lock-wait N] [--show-version] + usage: borg debug-get-obj [-h] [--critical] [--error] [--warning] [--info] + [--debug] [--lock-wait N] [--show-version] [--show-rc] [--no-files-cache] [--umask M] [--remote-path PATH] [REPOSITORY] ID PATH @@ -18,10 +19,12 @@ borg debug-get-obj optional arguments: -h, --help show this help message and exit - -v, --verbose, --info - enable informative (verbose) output, work on log level - INFO - --debug enable debug output, work on log level DEBUG + --critical work on log level CRITICAL + --error work on log level ERROR + --warning work on log level WARNING (default) + --info, -v, --verbose + work on log level INFO + --debug work on log level DEBUG --lock-wait N wait for the lock, but max. N seconds (default: 1). --show-version show/log the borg version --show-rc show/log the return code (rc) |