Commit Graph

988 Commits

Author SHA1 Message Date
Dan Christensen cc78ef8939 testsuite/hashindex.py: add two more tests 2023-02-11 19:44:56 -05:00
Dan Christensen 6aa53a5627 hashindex_pytest.py: add test_hashindex_compact_stress 2023-02-11 19:13:20 -05:00
Dan Christensen 51b29ab426 hashindex.py: make .compact tests independent of order 2023-02-11 17:37:53 -05:00
Dan Christensen 133ffebc8d hashindex_pytest.py: factor out verify_hash_table 2023-02-11 17:37:20 -05:00
TW 098fca7861
Merge pull request #7343 from ThomasWaldmann/timestamp-comparisons-master
relaxed timestamp comparisons (master)
2023-02-11 18:15:02 +01:00
Thomas Waldmann aee17a87e2
tests: use same_ts_ns for all timestamp comparisons 2023-02-11 17:08:56 +01:00
TW d90ebc8bef
Merge pull request #7340 from ThomasWaldmann/fix-recreate-rechunkify-master
recreate: --chunker-params must default to None, fixes #7337
2023-02-11 14:11:03 +01:00
TW ce04521a9a
Merge pull request #7333 from ThomasWaldmann/excluded-included-status-chars
better included/excluded status chars, docs, fixes #7321
2023-02-11 13:48:43 +01:00
Thomas Waldmann 2ef09eaa77
same_ts_ns: add a timestamp comparison function
also: HAVE_UTIMES means 1us resolution (*)

(*) at least as far as the utimes() call is concerned.

Whether there are other limitations has to be seen.
2023-02-11 01:19:01 +01:00
Thomas Waldmann ce5f1589ea
recreate: --chunker-params must default to None, fixes #7336
also add a test: recreate without --chunker-params shall not rechunk

before the fix, it triggered rechunking if an archive
was created with non-default chunker params.

but it only should rechunk if borg recreate is invoked with explicitly giving --chunker-params=....
2023-02-11 01:08:01 +01:00
Thomas Waldmann fdc48fdd1b
more directory timestamp tests 2023-02-11 00:42:30 +01:00
Thomas Waldmann a42cd161de
add test for extracted directory mtime 2023-02-11 00:29:57 +01:00
Thomas Waldmann 303c474f21
better included/excluded status chars, docs, fixes #7321
more consistent now between dry-run and non-dry-run mode.

--filter=... users might need to update the status chars they filter for.
2023-02-10 01:13:21 +01:00
TW 366731ba00
Merge pull request #7300 from RayyanAnsari/borg-platformdirs
use platformdirs
2023-02-10 00:09:44 +01:00
Thomas Waldmann 3d57dc0590
hashindex: add tests, misc. minor fixes/changes
test hashtable expansion/rebuild.

hashindex_lookup:
- return -2 for a compact / completely full hashtable
- return -1 and (via start_idx pointer) the deleted/tombstone bucket index.

fix size assertion (we add 1 element to trigger rebuild)

fix upper_limit check - since we'll be adding 1 to num_entries below,
the condition should be >=:

hashindex_compact: set min_empty/upper_limit

Co-authored-by: Dan Christensen <jdc+github@uwo.ca>
2023-02-09 22:14:07 +01:00
Thomas Waldmann 1ed8ac0408
hashindex_pytest: move hashtable create into separate function 2023-02-09 21:58:40 +01:00
Thomas Waldmann e556233e30
hashindex_pytest: add a comment 2023-02-09 21:58:37 +01:00
Thomas Waldmann 4c2af9fb96
renamed hashindex_stress -> hashindex_pytest 2023-02-09 21:58:23 +01:00
Thomas Waldmann 3e33656238
add comment about how to provoke more collisions 2023-02-08 02:13:14 +01:00
Thomas Waldmann 9697f55534
add hashtable stress tests
Using NSIndex (repo index) HashIndex, but they all are very similar.
2023-02-08 01:53:30 +01:00
Thomas Waldmann 516c070c7c
fix tests for platformdirs 3.x.x 2023-02-07 21:14:16 +01:00
Thomas Waldmann d9875a4d7e
improve test_get_security_dir 2023-02-04 18:23:35 +01:00
Thomas Waldmann 078bb7ee02
improve test_get_keys_dir 2023-02-04 18:19:15 +01:00
Thomas Waldmann 6ab424598d
improve test_get_cache_dir 2023-02-04 18:17:43 +01:00
Thomas Waldmann 4bacd0b722
improve test_get_config_dir 2023-02-04 18:15:57 +01:00
Thomas Waldmann bb73e8682f
fix win2 typo 2023-02-04 18:11:28 +01:00
Thomas Waldmann 499e5133b5
test_config_dir_compat: don't test on win32
there is no old borg < 2.0 there anyway.
2023-02-04 01:18:16 +01:00
Thomas Waldmann bde0f11e1e
get_security_dir: legacy=False default 2023-02-04 00:35:04 +01:00
Thomas Waldmann 1d4810af23
get_keys_dir: legacy=False default 2023-02-04 00:35:03 +01:00
Thomas Waldmann b06dd1c66c
get_config_dir: legacy=False default 2023-02-04 00:35:01 +01:00
Thomas Waldmann ebcda6f0a5
get_cache_dir: legacy=False default 2023-02-04 00:34:57 +01:00
Thomas Waldmann 424be763b2
get_base_dir: legacy=False default 2023-02-04 00:34:54 +01:00
Thomas Waldmann 81595a9ca0
conftest.py: use BORG_BASE_DIR to redirect borg testing .config/.cache into a temp dir
XDG_*_HOME is not honoured on macOS and on Windows if we use platformdirs.
2023-02-04 00:34:52 +01:00
Thomas Waldmann 437b5fa859
do not fail on macOS due to different dirs from platformdirs 2023-02-04 00:34:42 +01:00
Thomas Waldmann 8379ecefaa
deal with BORG_BASE_DIR 2023-02-04 00:34:26 +01:00
Thomas Waldmann d3d909ad31
add compatibility test: legacy vs. non-legacy platformdirs 2023-02-03 18:22:51 +01:00
Rayyan Ansari f2452aef2a
helpers: use platformdirs on win32 2023-02-03 17:46:49 +01:00
TW c96c5652b0
Merge pull request #7317 from pgerber/hanging-test
Fix test hanging reading FIFO when `borg create` failed
2023-02-03 01:59:15 +01:00
Peter Gerber 8ce3d22358 Fix test hanging reading FIFO when `borg create` failed 2023-02-02 00:44:08 +01:00
Thomas Waldmann b92f4aa487
remove --consider-part-files, related stats code, update docs
we now just treat that one .borg_part file we might have inside
checkpoint archives as a normal file.

people can recognize via the file name it is a partial file.

nobody cares for statistics of checkpoint files and the final
archive now does not contain any partial files any more, thus
no needs to maintain statistics about count and size of part
files.
2023-02-01 13:04:18 +01:00
Thomas Waldmann 0fed44110a
remove part files from final archive
checkpoint archives might have a single, incomplete part file as last item.
part files are always a prefix of the full file, growing in size from
checkpoint to checkpoint.

we now manage the archive items metadata stream in a special way:
- checkpoint archive A(n) might end with a partial item PI(n)
- checkpoint archive A(n+1) does not contain PI(n)
- checkpoint archive A(n+1) contains a new partial item PI(n+1)
- the final archive does not contain any partial items
2023-02-01 13:04:12 +01:00
Thomas Waldmann a0330d578e
run black 23.1.0 on the code 2023-02-01 12:30:37 +01:00
Michael Deyaso 8af9eb47c2
Added date-matching support for list_considering (#7306)
added date-matching support for list_considering, fixes #7296

Co-authored-by: Michael Deyaso <mdeyaso@fusioniq.io>
2023-02-01 11:32:53 +01:00
Thomas Waldmann e019487166
tests: relax birthtime assertion, fixes #7308 2023-02-01 01:59:41 +01:00
Thomas Waldmann 15d1bc0c49
fix checkpointing: add item_ptrs chunks cleanup
not having this had created orphaned item_ptrs chunks for checkpoint archives.

also:
- borg check: show id of orphaned chunks
- borg check: archive list with explicit consider_checkpoints=True (this is the default, but better make sure).
2023-01-31 14:40:41 +01:00
Thomas Waldmann 56b6f1d2e0
create/recreate/import-tar: add --checkpoint-volume option
volume based checkpointing is easier to test than its time based cousin.

also added first checkpointing test.
2023-01-31 04:01:37 +01:00
Michael Deyaso b2654bc17d
Support for date-based matching during archive listing (#7272)
check --archives: add --newer/--older/--newest/--oldest, fixes #7062

Options accept a timespan, like Nd for N days or Nm for N months.

Use these to do date-based matching on archives and only check some of them,
like: borg check --archives --newer=1m --newest=7d

Author: Michael Deyaso <mdeyaso@fusioniq.io>
2023-01-23 15:00:05 +01:00
Thomas Waldmann bf667170a7
ArchiveItem.cmdline list-of-str -> .command_line str, fixes #7246
Same change for .recreate_cmdline -> .recreate_command_line .

JSON output key "command_line":
borg 1.x: sys.argv [list of str]
borg 2: shlex.join(sys.argv) [str]
2023-01-20 00:19:00 +01:00
Thomas Waldmann 7bd8e924eb
win32: omit some tests with non-existing user/group names
see comment in the code, they currently can't succeed.
2023-01-19 20:07:37 +01:00
Thomas Waldmann 9460da42d1
use local time / local timezone to output timestamps, fixes #7283
"ls" and also "tar" show timestamps as local time.
borg now does the same, but also shows the local tzoffset.

this also affects JSON output.
2023-01-19 03:36:46 +01:00
Thomas Waldmann 1843990172
use os.replace rather than os.rename
more consistent behaviour on all OSes, incl. windows.
2023-01-19 01:57:03 +01:00
TW 8e012be3fa
Merge pull request #7264 from ThomasWaldmann/fix-locking-win32-master
Fix locking (win32, master)
2023-01-19 01:56:20 +01:00
Thomas Waldmann 0e577452c2
tests: fix prune_split tests by giving the timestamps in local timezone
Guess this fixes issues like #5535.

I tested this with TZ=:
- UTC
- UTC+12
- UTC-12
- UTC+14
- UTC-14
2023-01-19 00:52:27 +01:00
Thomas Waldmann 1672aee031
Item: symlinks: rename .source to .target, fixes #7245
Also, in JSON:
- rename "linktarget" to "target" for symlinks
- remove "source" for symlinks
2023-01-16 20:28:25 +01:00
Thomas Waldmann ff545033e3
tests: do not look up uid 0 / gid 0, but current process uid/gid
some systems do not have uid/gid 0 (windows).
2023-01-16 18:17:15 +01:00
Thomas Waldmann 1f9c46f2b5
create: do not store user/group for stdin data by default, see #7249
if you want user/group stored, give --stdin-user=USER / --stdin-group=GROUP.
2023-01-16 18:17:12 +01:00
Thomas Waldmann 4f9cda1aab
get_item_uid_gid: do not require item.uid/gid, see #7249
if uid is not present, fall back to uid_default.
if gid is not present, fall back to gid_default.
2023-01-16 18:12:34 +01:00
Thomas Waldmann 32d430a1b0
implement text_to_json / binary_to_json, see #6151
binary bytes:
- json_key = <key>_b64
- json_value == base64(value)

text (potentially with surrogate escapes):
- json_key1 = <key>
- json_value1 = value_text (s-e replaced by ?)
- json_key2 = <key>_b64
- json_value2 = base64(value_binary)

json_key2/_value2 is only present if value_text required
replacement of surrogate escapes (and thus does not represent
the original value, but just an approximation).
value_binary then gives the original bytes value (e.g. a
non-utf8 bytes sequence).
2023-01-16 17:45:27 +01:00
Thomas Waldmann 0ce2b55031
fix host, pid, tid order
using "differenthost" (== not the current hostname) makes
the process_alive check always return True (to play safe,
because in can not check for processes on other hosts).
2023-01-13 22:48:19 +01:00
Thomas Waldmann 38152c8e5d
safe_unlink tests: use os.link to support win32 also
also:
- add note about mklinkto
- skip tests based on "not are_hardlinks_supported()" if needed
2023-01-13 20:59:30 +01:00
TW fb9717567e
Merge pull request #7251 from puetzk/test_size_on_disk_accurate-flush
Fix test_size_on_disk_accurate for large st_blksize, fixes #7250
2023-01-13 10:49:41 +01:00
Josh Soref c9848e9814 spelling: nonexistent
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-12 09:36:03 -05:00
Kevin Puetz 079d9256ee Fix test_size_on_disk_accurate for large st_blksize, fixes #7250
python's io.BufferedWriter sizes its buffer based on st_blksize.
If the write fits in this buffer, then it's possible the data from
idx.write() has not been flushed through to ,the underlying filesystem,
and getsize(fileno()) sees a too-short (or even empty) file.

Also, getsize is only documented as accepting path-like objects;
passing a fileno seems to work only because the implementation
blindly forwards everything through to os.stat without checking.

Passing unopened_tempfile avoids all three problems
- on windows, it doesn't rely on re-opening NamedTemporaryFile
  (the issue which led to cc0ad321dc)
- we're following the documented API of getsize(path-like)
- the file is closed (thus flushed) inside idx.write, before getsize()
2023-01-11 19:20:16 -06:00
Thomas Waldmann 6a27c6b763
macOS: test correct timestamp extraction if ResourceFork xattr is present, see #7234 2023-01-06 21:58:33 +01:00
Paul D 253d8e8d4e Docs grammar fixes
joined split infinitives, and relocated adverbs appropriately.
2022-12-29 22:26:54 +00:00
Paul D a85b643866 Docs grammar fixes.
One cannot "to not x", but one can "not to x".
Avoiding split infinitives gives the added bonus that machine
translation yields better results.

setup (n/adj) vs set(v) up. We don't "I setup it" but "I set it up".

Likewise for login(n/adj) and log(v) in, backup(n/adj) and back(v) up.
2022-12-29 00:01:48 +00:00
Franco Ayala ab465a75d4
Adding used storage quota to borg info (#7121) 2022-12-24 01:55:47 +01:00
Rayyan Ansari cf61e7d58a testsuite: archiver: skip block device in test_transfer_upgrade
On MINGW, the S_IFBLK macro is incorrectly set as 0x3000 instead of 0x6000.
https://github.com/mingw-w64/mingw-w64/blob/v10.0.0/mingw-w64-headers/crt/sys/stat.h#L133
2022-12-18 14:05:24 +00:00
Rayyan Ansari 66a407ff9f Use \n for the {NL} format specifier
\n is automatically converted on write to the platform-dependent os.linesep.
Using os.linesep instead of \n means that on Windows, the line ending becomes "\r\r\n".
Also switches mentions of {LF} to {NL} in code and docs.
2022-12-18 14:05:24 +00:00
Rayyan Ansari d32ae512a8 testsuite: archiver: change regex excludes in test_extract_include_exclude_regex_from_file
On Windows, the ":" character cannot be used in a filename.
Python does not error on this because the ":" character represents data streams.
See https://stackoverflow.com/a/54508979
2022-12-18 14:05:24 +00:00
Rayyan Ansari 2505118fff testsuite: archiver: check if symlinks supported before test_create_read_special_broken_symlink
On Windows, symlinks can only be created by administrator accounts.
Using are_symlinks_supported() skips the test if the symlink cannot be created.
See https://docs.python.org/3/library/os.html#os.symlink
2022-12-18 14:05:24 +00:00
Rayyan Ansari e97a966b46 testsuite: archiver: fix test_create_paths_from_command on Windows
On Windows, `echo` is a shell builtin and can only output one line at a time.
A batch file that outputs the filenames is instead used as the command.
2022-12-18 14:05:24 +00:00
Rayyan Ansari 9e9b94615e archiver: key_cmds: check if key path is a directory before opening
On Windows, Python raises PermissionError instead of IsADirectoryError (like on Unix) if the file to open is actually a directory.
See https://github.com/python/cpython/issues/87261
2022-12-18 14:05:24 +00:00
Rayyan Ansari fff2c21e65 testsuite: archiver: skip test_file_status_cs_cache_mode on Windows
On Windows, the ctime attribute of stat represents the time of creation, unlike Unix.
See https://docs.python.org/3/library/os.html#os.stat_result.st_ctime
2022-12-18 14:05:24 +00:00
Rayyan Ansari 12245761c0 testsuite: archiver: diff_cmd: ignore modes
Windows does not have file modes.
2022-12-18 14:05:24 +00:00
Rayyan Ansari d8e8247c6d testsuite: archiver: increase hashing test bytes
A lower value results in the hash running too fast and the time being rounded down to 0.0, resulting in the test failing.
2022-12-18 14:05:24 +00:00
Rayyan Ansari 061397740c testsuite: archiver: skip test_umask on Windows
Windows does not have file modes, so os.stat always returns 777.
2022-12-18 14:05:24 +00:00
Rayyan Ansari 208add518f testsuite: archiver: skip test_unix_socket on Windows
Python on Windows does not support the AF_UNIX socket type yet.
https://github.com/python/cpython/issues/77589
2022-12-18 14:05:23 +00:00
Rayyan Ansari 2f9c7d98e5 testsuite: archiver: use os.linesep instead of hardcoded newline string
On Windows, a newline is \r\n instead of \n.
2022-12-18 14:05:15 +00:00
Rayyan Ansari 1deeb0b17d testsuite: archiver: do not try to create special devices on Windows
Windows does not support these file types in userspace programs.
2022-12-18 14:00:35 +00:00
Thomas Waldmann 8747644540
remove --save-space
this option did not change behaviour since longer,
we only had kept it for API compatibility.

as a borg2 repo server won't have old clients talking to it,
we can safely remove this everywhere now.
2022-12-17 16:48:54 +01:00
Thomas Waldmann a475227e18
use archivename_validator everywhere
also: simplify, reuse code from text_validator.
2022-12-15 22:54:46 +01:00
Thomas Waldmann 1e2741ad3d
remove support for barchive placeholder
not needed any more as the archive name is now validated pure text.
2022-12-12 19:10:58 +01:00
Thomas Waldmann 99c6afbc61
add generic text and comment validator 2022-12-12 18:01:07 +01:00
Thomas Waldmann fe2b2bc007
archive names: validate more strictly, fixes #2290
we want to be able to use an archive name as a directory name,
e.g. for the FUSE fs built by borg mount.

thus we can not allow "/" in an archive name on linux.

on windows, the rules are more restrictive, disallowing
quite some more characters (':<>"|*?' plus some more).
we do not have FUSE fs / borg mount on windows yet, but
we better avoid any issues.
we can not avoid ":" though, as our {now} placeholder
generates ISO-8601 timestamps, including ":" chars.

also, we do not want to have leading/trailing blanks in
archive names, neither surrogate-escapes.

control chars are disallowed also, including chr(0).
we have python str here, thus chr(0) is not expected in there
(is not used to terminate a string, like it is in C).
2022-12-12 17:05:01 +01:00
Thomas Waldmann 6a82d01b35
tests for borg transfer --upgrader=From12To20 2022-12-04 09:07:48 +01:00
Thomas Waldmann ae0017d174
skip test_create_read_special_symlink on cygwin
test is broken on cygwin and hangs infinitely.
2022-11-22 18:16:18 +01:00
Thomas Waldmann 15c51ee3c6
fix test_recreate_basic on cygwin
looks like that chmod should only get done IF we are root (and on linux?).

taking away write permissions on windows/cygwin (and when running as normal
user) makes create_regular_file fail when it tries to create dir2/file3.
2022-11-22 18:16:15 +01:00
Thomas Waldmann f088682bc9
ignore testsuite test for slow msgpack on cygwin
we don't want to have a failing test just because a
not compiled msgpack was used to run the tests.
2022-11-22 18:16:12 +01:00
Rayyan Ansari 4445fe3bdb testsuite: repository: skip some tests for RemoteRepository 2022-11-15 19:14:33 +00:00
Rayyan Ansari f3f6e3f448 testsuite: repository: close fd before deleting segment
See last commit.
2022-11-15 17:55:18 +00:00
Thomas Waldmann 85b0dc873a
fix failing hashing_time test
fast CPUs failed the test due to rounding down to 0.00s.
2022-11-07 10:51:04 +01:00
TW 5713908ce1
Merge pull request #7129 from ThomasWaldmann/fix-6070-master
improve/clarify strange test code, fixes #6070
2022-11-05 02:15:39 +01:00
Thomas Waldmann 5a4f07629c improve/clarify strange test code, fixes #6070 2022-11-05 00:46:40 +01:00
Thomas Waldmann 05997e2867 Fix test_size_on_disk_accurate on Windows
Pass the python file object / fd instead of the file path.

On Windows, a tempfile cannot be opened again, unlike on Unix systems.
See https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
2022-11-04 20:32:53 +01:00
Rayyan Ansari cc0ad321dc Fix test_size_on_disk_accurate on Windows
Pass the file descriptor instead of the file path.
On Windows, a tempfile cannot be opened again, unlike on Unix systems.
See https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
2022-11-04 18:28:51 +00:00
Franco Ayala eaccd9d578
Fix test_chunking_time (#7101)
test_chunking_time: use a bigger file to avoid test fail due to rounding to 0.0
2022-10-26 22:17:05 +02:00
Franco Ayala 2ed7f317d3
Adding performance statistics to borg create (#6991)
- file status A/M/E counters
- chunking time
- hashing time
- rx_bytes / tx_bytes

Note: the sleep() in the test is needed due to timestamp granularity on linux being much more coarse than expected (uses the system timer, 100Hz or 250Hz).
2022-10-19 21:40:02 +02:00
TW c29d4a096b
Hashindex header work, fixes #6960 (#7064)
support reading new, improved hashindex header format, fixes #6960

Bit of a pain to work with that code:
- C code
- needs to still be able to read the old hashindex file format,
- while also supporting the new file format.
- the hash computed while reading the file causes additional problems because
  it expects all places in the file get read exactly once and in sequential order.
  I solved this by separately opening the file in the python part of the code and
  checking for the magic.
  BORG_IDX means the legacy file format and legacy layout of the hashtable,
  BORG2IDX means the new file format and the new layout of the hashtable.

Done:
- added a version int32 directly after the magic and set it to 2 (like borg 2).
  the old header had no version info, but could be denoted as version 1 in case
  we ever need it (currently it decides based on the magic).
- added num_empty as indicated by a TODO in count_empty, so it does not need a
  full hashtable scan to determine the amount of empty buckets.
- to keep it simpler, I just filled the HashHeader struct with a
  `char reserved[1024 - 32];`
  1024 being the desired overall header size and 32 being the currently used size.
  this alignment might be useful in case we mmap() the hashindex file one day.
2022-10-02 14:35:21 +02:00
Thomas Waldmann e32d733612 add test for recreate with "fixed" chunker 2022-10-02 14:02:06 +02:00
Thomas Waldmann 7b3cdb1aea add benchmark for item attribute / dict access
Author: @RonnyPfannschmidt in PR #5763
2022-09-29 00:47:48 +02:00
Thomas Waldmann 9455c1e278 rcompress: do a repo-wide (re)compression
reads all chunks in on-disk order and recompresses them if they are not already using
the desired compression type and level (and obfuscation level).

supports SIGINT/ctrl-c and --checkpoint-interval (default: 1800s).

this is a borg command that compacts when committing (without this, it would have
a huge space usage). it commits/compacts every checkpoint interval or when
pressing ctrl-c / receiving SIGINT.
2022-09-27 16:50:19 +02:00
TW 78b1301b98
Merge pull request #7028 from ThomasWaldmann/match-archives
implement pattern support for --match-archives, fixes #6504
2022-09-27 11:38:27 +02:00
Thomas Waldmann acc5d9870a repoobj.format: mutate meta
we should modify the meta dict given by the caller, so the caller can know
about e.g. the compression/obfuscation that was done (this is useful for rcompress).
2022-09-21 11:19:40 +02:00
Thomas Waldmann c4e54ca44e repository.scan: use same end_segment within same scan
achieved by putting it into the state that is now used instead of the marker.
2022-09-19 21:14:25 +02:00
Thomas Waldmann 49a4884cfe repository.scan: do not use chunkid as marker, but (segment, offset)
when using .scan(limit, marker), we used to use the last chunkid from
the previously returned scan result to remember how far we got and
from where we need to continue.

as this approach used the repo index to look up the respective segment/offset,
it was problematic if the code using scan was re-writing the chunk to
a new segment/offset, updating the repo index (e.g. when recompressing a chunk)
and basically destroying the memory about from where we need to continue
scanning.

thus, directly returning (segment, offset) as marker is easier and solves this issue.
2022-09-19 12:03:13 +02:00
Thomas Waldmann ce08f92090 repository.scan: only iterate over committed chunks
otherwise, if we scan+get+put (e.g. if we read/modify/write chunks to
recompress them), it would scan past the last commit and run into the
newly written chunks (and potentially never terminate).
2022-09-19 11:05:07 +02:00
Thomas Waldmann f348c86f08 mount cmd tests: remove absolute "borg" import 2022-09-16 19:09:46 +02:00
Thomas Waldmann 4493d396e6 implement pattern support for --match-archives, fixes #6504
also:
- rename --glob-archives option to --match-archives (short: -a, unchanged)
- globbing patterns now need sh: prefix
- regex patterns need re: prefix
- "identical" match "patterns" use an id: prefix
- new default style is id: pattern (--glob-archives used sh: glob pattern)
- source code: glob -> match, GLOB -> PATTERN
2022-09-16 15:10:13 +02:00
Thomas Waldmann 5d7b48ced8 add remote repo / borg binary testing 2022-09-14 09:11:45 +02:00
Thomas Waldmann f410de690d remove log output checks
the intention of this test is testing whether borg check
returns an error when checking a corrupted repository.

the removed assertions were rather testing the test logging
configuration, which seems flaky:

- when running all tests, assertions failed
- when running only this one test, assertions succeeded
- assertions also succeeded when running all the tests before
  they were refactored to separate test modules, although the
  test code was not changed, just moved.
2022-09-13 16:22:16 +02:00
Thomas Waldmann f94eec199f move patterns tests to own module 2022-09-13 14:18:17 +02:00
Thomas Waldmann 87c3f11796 remove unneeded code 2022-09-13 14:14:56 +02:00
Thomas Waldmann db0d15c182 move another test to argparsing 2022-09-13 14:12:15 +02:00
Thomas Waldmann 6ec6fc2496 move corruption tests to own module 2022-09-13 14:08:03 +02:00
Thomas Waldmann acca64b057 move some checks to own module 2022-09-13 13:59:33 +02:00
Thomas Waldmann c7146ffb47 move rcreate cmd tests to own module 2022-09-13 02:21:04 +02:00
Thomas Waldmann 8cee607652 move create cmd tests to own module 2022-09-13 02:00:18 +02:00
Thomas Waldmann 14f9d7d3cb move extract cmd tests to own module 2022-09-13 01:22:37 +02:00
Thomas Waldmann 4a720e9abd move item related test to item testing module 2022-09-13 00:29:20 +02:00
Thomas Waldmann 589ed91f4a move more help related stuff to help testing module 2022-09-13 00:29:20 +02:00
Thomas Waldmann 2e17ceb258 move argparsing tests to own module 2022-09-13 00:29:20 +02:00
Thomas Waldmann 32f81eff27 move config cmd tests to own module 2022-09-13 00:03:07 +02:00
Thomas Waldmann 8aaad71439 move disk full tests to own module 2022-09-12 23:55:13 +02:00
Thomas Waldmann 3c247b8109 move return codes tests to own module 2022-09-12 23:49:51 +02:00
Thomas Waldmann 245bdef4eb move benchmark cmd tests to own module 2022-09-12 23:45:11 +02:00
Thomas Waldmann cc79c98b98 move help cmd tests to own module 2022-09-12 23:42:48 +02:00
Thomas Waldmann e27bb0c1d0 move transfer cmd tests to own module 2022-09-12 23:37:26 +02:00
Thomas Waldmann 35d2710769 move lock cmd tests to own module 2022-09-12 23:35:21 +02:00
Thomas Waldmann ec731bfaa0 remove unused imports from test init 2022-09-12 23:27:20 +02:00
Thomas Waldmann 4e932241b2 blacken init 2022-09-12 23:25:38 +02:00
Thomas Waldmann e329152f01 move recreate cmd tests to own module 2022-09-12 23:25:38 +02:00
Thomas Waldmann 5fa1b7ea88 move (r)info cmd tests to own module 2022-09-12 23:25:38 +02:00
Thomas Waldmann 620d51d6bc move rename cmd tests to own module 2022-09-12 23:25:38 +02:00
Thomas Waldmann a07311101a move (r)list cmds tests to own module 2022-09-12 23:25:38 +02:00
Thomas Waldmann fcf7ca5e10 move fuse / mount cmds tests to own module 2022-09-12 23:25:38 +02:00
Thomas Waldmann 2288ee04fe move prune cmd tests to own module 2022-09-12 02:53:02 +02:00
Thomas Waldmann 4171e38d44 move key cmd tests to own module 2022-09-12 02:33:37 +02:00
Thomas Waldmann c09ce2cb55 move delete/rdelete cmd tests to own modules 2022-09-12 02:05:25 +02:00
Thomas Waldmann 185951fb57 move diff cmd tests to own module 2022-09-12 01:42:36 +02:00
Thomas Waldmann dadbe0ddf3 move check cmd tests to own module 2022-09-12 01:03:16 +02:00
Thomas Waldmann c4a1cc5bb0 remove unused imports 2022-09-12 00:51:25 +02:00
Thomas Waldmann d762833cd6 move debug cmd tests to own module 2022-09-12 00:50:12 +02:00
Thomas Waldmann 5beb3857f8 move tar and --bypass-lock tests to own modules 2022-09-12 00:03:26 +02:00
Thomas Waldmann bef65e5722 make borg.testsuite.archiver a package
git mv archiver.py archiver/__init__.py

+ adapt import levels + adapt filenames
2022-09-12 00:03:26 +02:00
Thomas Waldmann 208475f707 xattrs: adapt tests to new error msgs 2022-09-10 22:06:34 +02:00
TW c258eb45f4
Merge pull request #7008 from KN4CK3R/forwardport-6990
xattrs / extended stat: improve exception handling (master)
2022-09-10 00:52:38 +02:00
Thomas Waldmann 65a0d7fbca cosmetic: concat strings 2022-09-10 00:27:26 +02:00
Thomas Waldmann d3a2d831b7 refactor replace_placeholders, fixes #6966
fix replacing placeholders in archive name, --comment and --glob-archives values (even if overridden by other options like
--timestamp).

add test.
2022-09-09 23:28:34 +02:00
Thomas Waldmann 06eab6a228 RepositoryCache: cache complete and meta-only chunks separately 2022-09-08 19:38:18 +02:00
Thomas Waldmann 106abbe4d9 new read_data param for repository.get() and .get_many()
True (default): return full chunk (client can decrypt meta and data)

False: return enough so client can decrypt only the meta
2022-09-08 18:31:56 +02:00
Thomas Waldmann b64427c480 simplify: iter_objects always returns (..., size, data)
data might be None (if read_data is False).

also removed the include_data argument, not needed any more.
2022-09-08 12:48:39 +02:00
Thomas Waldmann e827f98c45 transfer: add test
bit hard to test the 1.2 -> 2.0 transfer, but we can at least
test the 2.0 -> 2.0 "NoOp" transfer.
2022-09-07 21:10:54 +02:00
Thomas Waldmann 4c9ed2a6c6 refactor compressors to new api
legacy: add/remove ctype/clevel bytes prefix of compressed data

new: use a separate metadata dict

compressors: use an int as ID, not a len 1 bytestring
2022-09-07 19:23:47 +02:00
Thomas Waldmann 1e156ca02b fix upgrader 2022-09-07 19:23:11 +02:00
TW 68e43911f5 Merge pull request #6990 from ThomasWaldmann/more-fine-grained-extended-stat-1.2
xattrs / extended stat: improve exception handling (1.2-maint)
2022-09-07 09:34:52 +02:00
Thomas Waldmann b6cbf045ff add a test for borg 1 -> 2 repo objects transformation 2022-09-05 22:17:51 +02:00
Thomas Waldmann fa986a9f19 repoobj: add a layer to format/parse repo objects
borg < 2:

obj = encrypted(compressed(data))

borg 2:

obj = enc_meta_len32 + encrypted(msgpacked(meta)) + encrypted(compressed(data))

handle compr / decompr in repoobj

move the assert_id call from decrypt to RepoObj.parse

also:
- for AEADKeyBase, add a dummy assert_id (not needed here)
- only test assert_id for other if not AEADKeyBase instance
- remove test_getting_wrong_chunk. assert_id is called elsewhere
  and is not needed any more anyway with the new AEAD crypto.
- only give manifest (includes key, repo, repo_objs)
- only return manifest from Manifest.load (includes key, repo, repo_objs)
2022-09-04 00:49:38 +02:00
Thomas Waldmann 90ca04f535 repository api: flags support, fixes #6982
- .list: only return IDs for objects where flags & mask == value.
- .flags(_many) (new) to set/query flags
2022-08-22 18:16:59 +02:00
Thomas Waldmann 29ae701ec9 fix test_recreate_timestamp
it did not work in timezone utc-0800.
2022-08-17 08:07:14 +02:00
Thomas Waldmann 66e74e0471 archiver modules: rename to *_cmd[s]
this was already required for list_cmd (due to "list"
being a builtin), now renamed all else also.
2022-08-13 22:59:48 +02:00
Thomas Waldmann 403ff07dde move nanorst module to borg.helpers 2022-08-13 22:10:13 +02:00
Thomas Waldmann ecd7bce5b8 move shellpattern module to borg.helpers 2022-08-13 22:03:44 +02:00
Thomas Waldmann 578639b35e move lrucache module to borg.helpers 2022-08-13 22:02:04 +02:00
Thomas Waldmann 9beaced33c move manifest module from helpers to borg.manifest 2022-08-13 21:55:12 +02:00
Thomas Waldmann 22804f05f9 move prune related code to borg.archiver.prune 2022-08-13 20:59:18 +02:00
Thomas Waldmann 4ab07b6acb create/recreate/import-tar --timestamp: default to local timezone
if you want to give UTC, just append: +00:00
2022-08-13 19:17:10 +02:00
Thomas Waldmann b4933eb337 get rid of dateutil 2022-08-13 18:31:22 +02:00
Thomas Waldmann ade08ce842 use timezones
- timezone aware timestamps
- str representation with +HHMM or +HH:MM
- get rid of to_locatime
- fix with_timestamp
- have archive start/end time always in local time with tz or as given
- idea: do not lose tz information

then we know when a backup was made and even from
which timezone it was made. if we want to compute
utc, we can do that using these infos.

this makes a quite nice archives list, with timestamps
as expected (in local time with timezone info).

at some places we just enforce utc, like for the
repo manifest timestamp or for the transaction log,
these are usually not looked at by the user.
2022-08-13 18:31:22 +02:00
Thomas Waldmann bab68a8d25 use py37+ datetime.isoformat / .fromisoformat
since python 3.7, .isoformat() is usable IF timespec != "auto"
is given ("auto" [default] would be as evil as before, sometimes
formatting with, sometimes without microseconds).

also since python 3.7, there is now .fromisoformat().
2022-08-11 21:18:56 +02:00
Thomas Waldmann fb74fdb710 massively increase per archive metadata stream size limit, fixes #1473
implemented by introducing one level of indirection, the limit is now
very high, so it is not practically relevant any more.

we always use the indirection (storing the metadata stream chunk ids list not
directly into the archive item, but into some repo objects referenced by the new
ArchiveItem.item_ptrs list).

thus, the code behaves the same for all archive sizes.
2022-08-06 19:01:41 +02:00
Thomas Waldmann 3ee69bc7ba Key: crypt_key instead of enc_key + enc_hmac_key, fixes #6611 2022-08-03 12:04:23 +02:00
Thomas Waldmann f82f123b56 new crypto does not need to call ._assert_id()
https://github.com/borgbackup/borg/pull/6463#discussion_r925436156
2022-07-20 14:13:25 +02:00
Thomas Waldmann 47c2672a64 ssh:// URLs: remove support for /~otheruser/, see #6855
If you used this, just replace it by:

ssh://user@host:port/home/otheruser/
2022-07-15 16:02:45 +02:00
Thomas Waldmann b8e48c5036 mypy: fixes / annotations 2022-07-15 14:54:48 +02:00
Thomas Waldmann 7bc7f01342 remove remainders of attic legacy
we expect that everybody has upgraded to borg
using borg 1.2.x or older, thus we do not need
to care about attic repos any more in borg2.
2022-07-13 16:55:29 +02:00
Thomas Waldmann e05f7971da move build_filter/build_matcher to archiver.common 2022-07-09 15:13:13 +02:00
Thomas Waldmann 94aec46a01 move rcreate command to archiver.rcreate 2022-07-09 15:13:12 +02:00
Thomas Waldmann 890d5950e7 move debug commands to archiver.debug 2022-07-09 15:13:12 +02:00
Thomas Waldmann 7957af562d blacken all the code
https://black.readthedocs.io/
2022-07-06 16:34:38 +02:00
TW 80289215d6
Merge pull request #6837 from ThomasWaldmann/recreate-recompress-considering-level
recreate: consider level for recompression, fixes #6698, fixes #3622
2022-07-06 14:11:06 +02:00
TW dbb9f62afd
Merge pull request #6836 from ThomasWaldmann/cleanups
Cleanups
2022-07-05 02:46:43 +02:00
Thomas Waldmann 0dc25000a9 recreate: consider level for recompression, fixes #6698, fixes #3622 2022-07-05 02:38:09 +02:00
Thomas Waldmann 350393c9fd remove unused imports 2022-07-05 00:05:07 +02:00
Thomas Waldmann 5c8a5f111f stop using libdeflate
borg2's new repo format does not need computing crc32 over big amounts of
(content) data any more (we now use xxh64 for that).

thus, having a quick crc32 implementation via libdeflate is not important
enough any more to rectify having libdeflate as a requirement.
2022-07-04 20:33:59 +02:00
Thomas Waldmann 0264f8dc92 fix benchmark tests 2022-07-04 14:53:31 +02:00
Thomas Waldmann 6888d5dcb2 remove -P (aka --prefix) option, fixes #6806
-a (aka --glob-archives) can be used for same purpose and is more powerful.
2022-07-02 20:52:41 +02:00
Thomas Waldmann eabad3e3b7 rcreate: always use argon2 kdf for new repos, fixes #6820
this way, we can remove the legacy pbkdf2 key code in next release.
2022-06-30 20:52:48 +02:00
Thomas Waldmann ef24dafb15 tests: use less RepoKey/KeyfileKey 2022-06-30 20:52:48 +02:00
Thomas Waldmann dc2f2f47a8 rcreate: remove legacy encryption modes for new repos, fixes #6490
These are legacy crypto modes based on AES-CTR mode:
(repokey|keyfile)[-blake2]

New crypto modes with session keys and AEAD ciphers:

(repokey|keyfile)[-blake2]-(aes-ocb|chacha20-poly1305)

Tests needed some changes:
- most used repokey/keyfile, changed to new modes
- some nonce tests removed, the new crypto code does not generate
  the repo side nonces any more (were only used for AES-CTR)
2022-06-30 20:52:48 +02:00
Thomas Waldmann f749d0dccf macOS does not support hardlinking symlinks, fixes #6802 2022-06-28 13:35:36 +02:00
Thomas Waldmann dbae8e60eb remove borg upgrade 2022-06-26 00:25:44 +02:00
Thomas Waldmann 31a081f695 simplify stats output
also:
- move stats related stuff to Statistics class
- repo ops give repo / overall stats
- archive ops give archive stats
- adapt tests
2022-06-23 16:00:12 +02:00
Thomas Waldmann e0c64629d1 Merge branch 'master' into borg2
strange conflicts, automated patches seemed to not have applied correctly.
also had to fix some stuff manually, tests were failing.
2022-06-23 11:25:01 +02:00
Thomas Waldmann f578c20b22 fix benchmark tests 2022-06-23 09:50:48 +02:00
Thomas Waldmann d00d650d88 borg init -> borg rcreate
this is to complement borg rdelete, see also borg create / delete.
2022-06-23 09:16:29 +02:00
Thomas Waldmann 34b6248d75 borg delete -a ARCH_GLOB, borg rdelete 2022-06-21 23:05:44 +02:00
Thomas Waldmann 9e5a8a352f borg info -a ARCH_GLOB, borg rinfo 2022-06-21 23:05:44 +02:00
Thomas Waldmann 1bf8f71e69 borg list ARCHIVE, borg rlist 2022-06-21 23:05:44 +02:00
Thomas Waldmann 6addafd784 borg mount -a ARCHIVE_GLOB mountpoint ... 2022-06-21 23:05:44 +02:00
Thomas Waldmann e6a8984c99 borg (import|export)-tar NAME ... 2022-06-20 20:17:29 +02:00
Thomas Waldmann 1ed7e5b292 borg dump-archive NAME / dump-archive-items NAME 2022-06-20 20:17:29 +02:00
Thomas Waldmann 75b53de37e borg diff ARCH1 ARCH2 2022-06-20 20:17:29 +02:00
Thomas Waldmann b8c7c53dde borg extract NAME ... 2022-06-20 20:17:29 +02:00
Thomas Waldmann f8d2024578 borg recreate -a ARCHIVE_GLOB ... 2022-06-20 20:17:29 +02:00
Thomas Waldmann 3fd5b73e1e borg create NAME ... 2022-06-20 20:17:28 +02:00
Thomas Waldmann c085c2744b borg rename NAME NEWNAME 2022-06-20 15:18:24 +02:00
Thomas Waldmann 7dbf125083 Location: remove archive name 2022-06-16 14:18:47 +02:00
Thomas Waldmann 281bbbc16b fix tests and benchmarks 2022-06-16 14:18:39 +02:00
Thomas Waldmann 0f0cd24354 if --(other-)repo option is not given, use default from environment
remove tests composing a repo+archive location with repo from env
and location from cli.
2022-06-16 14:14:54 +02:00
Thomas Waldmann 1c707b7da2 cli: use --repo option instead of positional repo parameter
currently still with ::archive appended.
2022-06-15 16:36:56 +02:00
Ricardo M. Correia 18f70be0e3 fix test_obfuscate byte accounting 2022-06-14 14:55:02 +02:00
Thomas Waldmann e5ea016115 repository: set/query flags, iteration over flagged items (NSIndex)
use this to query or set/clear flags in the "extra" word.

also: remove direct access to the "extra" word, adapt tests.
2022-06-14 14:48:56 +02:00
Thomas Waldmann 3ce3fbcdff repository index: add payload size (==csize) and flags to NSIndex entries
This saves some segment file random IO that was previously necessary
just to determine the size of to be deleted data.

Keep old one as NSIndex1 for old borg compatibility.
Choose NSIndex or NSIndex1 based on repo index layout from HashHeader.

for an old repo index repo.get(key) returns segment, offset, None, None
2022-06-14 14:48:56 +02:00
Thomas Waldmann 19dfbe5c5c compute the deduplicated size before compression
so we do not need csize for it.
2022-06-12 17:15:13 +02:00
Thomas Waldmann 2c1f7951c4 remove csize from ChunkIndexEntry 2022-06-12 17:15:13 +02:00
Thomas Waldmann 0211948cac remove csize from summarize return tuple 2022-06-12 15:48:33 +02:00
Thomas Waldmann ace5957524 remove csize from item.chunks elements 2022-06-12 15:48:33 +02:00
Thomas Waldmann b9f9623a6d prepare to remove csize (set it to 0 for now) 2022-06-12 15:48:33 +02:00
Thomas Waldmann f2b085787b Item: disallow None value for .user/group/chunks/chunks_healthy
If we do not know the value, just do not have that key/value pair in the item.
2022-06-09 17:57:28 +02:00
Thomas Waldmann 7b138cc710 Item: convert timestamps once, get rid of bigint code 2022-06-09 17:57:28 +02:00
Thomas Waldmann 8e87f1111b cleanup msgpack related str/bytes mess, fixes #968
see ticket and borg.helpers.msgpack docstring.

this changeset implements the full migration to
msgpack 2.0 spec (use_bin_type=True, raw=False).

still needed compat to the past is done via want_bytes decoder in borg.item.
2022-06-09 17:57:28 +02:00
Thomas Waldmann f8dbe5b542 cleanup msgpack related str/bytes mess, see #968
see ticket and borg.helpers.msgpack docstring.
2022-06-09 17:57:28 +02:00
Thomas Waldmann 6584a92c81 compression: use the 2 bytes for type and level, fixes #6698
adapt borg transfer, transferred chunks are set to compression level "unknown".
2022-06-09 17:49:16 +02:00
Thomas Waldmann d3dfa3be30 use version 2 for new archives
but still be able to read v1 archives
for borg transfer.
2022-06-09 17:49:16 +02:00
Elmar Hoffmann fd34fa2d02 use relative imports
Use relative imports where trivially possible for more consistency and to
avoid using the borg module name explicitly.
2022-05-29 09:36:52 +02:00
Thomas Waldmann 61299d23db Revert "Remove scp syntax for locations (#6697)"
This reverts commit 1b4b84dfd8.
2022-05-18 17:31:10 +02:00
Thomas Waldmann 6bfdb3f630 refactor hardlink_master processing globally
borg now has the chunks list in every item with content.
due to the symmetric way how borg now deals with hardlinks using
item.hlid, processing gets much simpler.

but some places where borg deals with other "sources" of hardlinks
still need to do some hardlink management:
borg uses the HardLinkManager there now (which is not much more
than a dict, but keeps documentation at one place and avoids some
code duplication we had before).

item.hlid is computed via hardlink_id function.

support hardlinked symlinks, fixes #2379
as we use item.hlid now to group hardlinks together,
there is no conflict with the item.source usage for
symlink targets any more.

2nd+ hardlinks now add to the files count as did the 1st one.
for borg, now all hardlinks are created equal.
so any hardlink item with chunks now adds to the "file" count.

ItemFormatter: support {hlid} instead of {source} for hardlinks
2022-05-18 14:20:01 +02:00
Thomas Waldmann 7903dad183 transfer: convert timestamps int/bigint -> msgpack.Timestamp, see #2323
Timestamp scales to 64 or 96bit serialization formats, that should be enough for everybody.

We use this in archived items and also in the files cache.
2022-05-18 14:20:01 +02:00
Thomas Waldmann 01f72d15b4 transfer: remove the zlib type bytes hack
hack: see the docstring of ZLIB_legacy class.

New clean ZLIB class that works as every other compressor.

ZLIB ID 0x0500, ZLIB_legacy ID 0x.8..
2022-05-18 14:20:01 +02:00
Thomas Waldmann 98b7dc0bf5 transfer: clean item of attic 0.13 'acl' bug remnants
also: remove attic bug support code from borg check.

borg transfer removes the acl key. we do not run borg check on old repos.
2022-05-18 14:20:00 +02:00
Emil M George 1b4b84dfd8
Remove scp syntax for locations (#6697)
remove scp syntax support from cli and from Location parser, add note about converting scp-style URLs to ssh-style, fixes #6691
2022-05-15 21:55:19 +02:00
Andrea Gelmini c79fd61b5c
Fix typos (#6688)
fix typos

Co-authored-by: Thomas Waldmann <tw@waldmann-edv.de>
2022-05-15 21:23:48 +02:00
TW 0e3ff0ab70
Merge pull request #6682 from ThomasWaldmann/fix-archive-progress-json-master
show_progress: add finished=true/false to archive_progress json
2022-05-08 19:45:39 +02:00
Thomas Waldmann 1c0937958d show_progress: add finished=true/false to archive_progress json, fixes #6570
also:
- remove empty values from final json
- add test
2022-05-08 18:32:07 +02:00
Thomas Waldmann 2c25123284 check that borg does not require pytest for normal usage, fixes #6563
also: move the note about this to the very top of the affected modules.
2022-05-07 02:24:18 +02:00
Thomas Waldmann cc0e33da65 fix key.decrypt calls
the id must now always be given correctly because
the AEAD crypto modes authenticate the chunk id.

the special case when id == MANIFEST_ID is now handled
inside assert_id, so we never need to give a None id.
2022-05-02 20:56:50 +02:00
Thomas Waldmann 4b070040d6 init --other-location=OTHER_REPO: reuse key material from OTHER_REPO, fixes #6554
it potentially will ask for the passphrase for the key of OTHERREPO.
for the newly created repo, it will use the same passphrase.

it will copy: enc_key, enc_hmac_key, id_key, chunker_seed.

keeping the id_key (and id algorithm) and the chunker seed (and chunker
algorithm and parameters) is desirable for deduplication.
the id algorithm is usually either HMAC-SHA256 or BLAKE2b.

keeping the enc_key / enc_hmac_key must be implemented carefully:
A) AES-CTR -> AES-CTR is INSECURE due to nonce reuse, thus not allowed.
B) AES-CTR -> AEAD with session keys is secure.
C) AEAD with session keys -> AEAD with session keys is secure.

AEAD modes with session keys: AES-OCB and CHACHA20-POLY1305.
2022-05-02 18:50:27 +02:00
Thomas Waldmann ed59159649 argon2 key: use chacha20-poly1305 instead of aes256-ctr + hmac-sha256, fixes #6601
so we can completely get rid of aes-ctr some day.
2022-04-16 11:52:33 +02:00
Thomas Waldmann be9e7d37c2 remove libressl support
currently it does not have what we need, so we can simplify our code.
2022-04-14 19:31:55 +02:00
Andrey Bienkowski 8e8e14c374 Fix selftest
selftest imports testsuite.crypto
I did not realise this and imported pytest from testsuite.crypto
This broke the selftest.

Solution: move the tests that depend on pytest to testsuite.key.
All three affected tests are tests for the Key classes, so
this is probably a better plase for them anyway.
2022-04-11 07:00:29 +03:00
Andrey Bienkowski 0c29faddec Simplify tests 2022-04-10 15:44:51 +03:00
Andrey Bienkowski fc6d423052 Passphrase.argon2 -> FlexiKey.argon2 2022-04-10 15:06:26 +03:00
Andrey Bienkowski 0850a7c295 Passphrase.kdf -> FlexiKey.pbkdf2 2022-04-10 05:33:10 +03:00
TW 28fa9e0f0b
Merge pull request #6523 from ThomasWaldmann/pax-borg-item-master
import/export-tar: --tar-format=BORG: roundtrip ALL item metadata
2022-04-09 20:22:36 +02:00
Thomas Waldmann 52f75d7722 repository: implement PUT2: header crc32, overall xxh64, fixes #1704
note: this required a slight increase of MAX_OBJECT_SIZE so that MAX_DATA_SIZE
      could stay the same as before.

For PUT2, compute the hash over the whole entry (header and content, excluding
hash and crc32 fields, because the crc32 computation includes the hash).

Also: refactor crc32 checks into function, use f-strings, structure _read in
a more logical sequential order.

write_put: avoid creating a large temporary bytes object

why use xxh64?
- fast even without hw acceleration
- borg depends on it already anyway
- stronger than crc32 and strong enough for this purpose
2022-04-09 18:58:47 +02:00
Andrey Andreyevich Bienkowski d386b0346d
Argon2 the third part: `borg key change-algorithm` (#6549)
add `borg key change-algorithm` to change the kdf / key processing
2022-04-09 12:42:05 +02:00
Andrey Andreyevich Bienkowski 56c27a99d0
Argon2 the second part: implement key encryption / decryption (#6469)
Argon2 the second part: implement encryption/decryption of argon2 keys

borg init --key-algorithm=argon2 (new default, older pbkdf2 also still available)

borg key change-passphrase: keep key algorithm the same
borg key change-location: keep key algorithm the same

use env var BORG_TESTONLY_WEAKEN_KDF=1 to resource limit (cpu, memory, ...) the kdf when running the automated tests.
2022-04-07 16:22:34 +02:00
Thomas Waldmann f24979bc09 fix scp repo url parsing for ip v6 addrs, fixes #6526
added a negative lookahead/lookbehind to make sure an ipv6 addr
(enclosed in square brackets) does not get badly matched by the
regex part intended for hostnames and ipv4 addrs only.

the other part of that regex which is actually intended to match
ipv6 addrs only matches if they are enclosed in square brackets.

also added tests for ssh and scp style repo URLs with ipv6 addrs
in brackets.

also: made regex more readable, putting these 2 cases on separate lines.
2022-04-03 20:42:48 +02:00
Thomas Waldmann e8069a8f80 import/export-tar: --tar-format=BORG: roundtrip ALL item metadata, fixes #5830
export-tar: just msgpack and b64encode all item metadata and
            put that into a BORG specific PAX header.
            this is *additional* to the standard tar metadata.

import-tar: when detecting the BORG specific PAX header, just get
            all metadata from there (and ignore the standard tar
            metadata).
2022-04-02 22:25:44 +02:00