Running 'borg key import' on a keyfile repository with the BORG_KEY_FILE
environment variable set works correctly if the BORG_KEY_FILE file
already exists. However, the command crashes if the BORG_KEY_FILE file
does not exist:
$ BORG_KEY_FILE=newborgkey borg key import /home/strager/borg-backups/straglum borgkey
Local Exception
Traceback (most recent call last):
[snip]
File "[snip]/borg/crypto/key.py", line 713, in sanity_check
with open(filename, 'rb') as fd:
FileNotFoundError: [Errno 2] No such file or directory: '[snip]/newborgkey'
Platform: Linux straglum 5.0.0-25-generic #26~18.04.1-Ubuntu SMP Thu Aug 1 13:51:02 UTC 2019 x86_64
Linux: debian buster/sid
Borg: 1.1.11 Python: CPython 3.7.7 msgpack: 0.5.6
PID: 15306 CWD: /home/strager/Projects/borg
sys.argv: ['[snip]/borg', 'key', 'import', '/home/strager/borg-backups/straglum', 'borgkey']
SSH_ORIGINAL_COMMAND: None
Make 'borg key import' not require the BORG_KEY_FILE file to already
exist.
This commit does not change the behavior of 'borg key import' without
BORG_KEY_FILE. This commit also does not change the behavior of 'borg
key import' on a repokey repository.
I want to change the key lookup logic for the 'borg key import' command.
Extract methods out of the KeyfileKey.find_key and
KeyfileKey.get_new_target to make this future change possible without
duplicating code.
This commit should not change behavior.
allow creating archives using stdout of given command
In addition to allowing:
some-command --param value | borg create REPO::ARCH -
also allow:
borg create --content-from-command create REPO::ARCH -- some-command --param value
The difference is that the latter approach deals with errors properly.
In the former example, an archive is created no matter what. Even, if
`some-command` aborts and the output is truncated, Borg won't realize.
In the latter example, the status code is checked and archive creation
is aborted properly when appropriate.
The locally defined preload() function overwrites the preload boolean keyword
argument, always evaluating to true, so preloading is done, even when not
requested by the caller, causing a memory leak.
Also move its definition outside of the loop.
This issue was found by Antonio Larrosa in borg issue #5202.
the old test stumbled over files with an empty chunks list,
so I guess just having some empty file in src/borg could make
that test fail.
fixed this by deleting a chunk of some specific file (we use
this file / this construction at misc. other places in the
archiver tests).
- add DecidingCompressor class providing generic decide(),
decide_compress() and compress() suited to work using a typical
private _decide() implementation that eventually generates compressed
data as a side-effect of the actual decision process
- the new decide_compress() method returns both the actually used
compressor (which may be NONE) and the compressed data to allow
the auto compressor to use that information instead of having to
figure out whether the LZ4 compressor decided to use NONE or LZ4
compression
- derive LZ4, LZMA and ZSTD classes from DecidingCompressor and
have them fall back to NONE if the compressed data turns out bigger
than the original data
- leave ZLIB as is, as it does not use an ID header and compatibility
being the only reason to use it instead of above algorithms anyway
- adapt testsuite to cope with incompressible test data not being
compressed
- add tests to verify that incompressible data is not compressed to
larger size compressed data