Commit Graph

2770 Commits

Author SHA1 Message Date
Thomas Waldmann 3051473168
BORG_WORKAROUNDS=authenticated_no_key to extract from authenticated repos without key, fixes #7700 2023-07-20 17:17:28 +02:00
bigtedde 0fa103460b removed 'prefix' 2023-07-19 17:24:15 -07:00
bigtedde 975a094e6e generate_archiver_tests added: generate tests by specifying kinds of archivers 2023-07-19 16:23:42 -07:00
bigtedde 8a5664dcfd remote archiver prefix check 2023-07-16 14:01:06 -07:00
bigtedde fcddbc6356 Fixed: camelcase, generate test dupe, init vars declerations, general cleanup 2023-07-16 13:33:54 -07:00
bigtedde 0c899a7985 extract_cmd cleanup 2023-07-13 20:14:04 -04:00
bigtedde bbb5340e8c diff_cmd cleanup 2023-07-13 19:52:59 -04:00
bigtedde 535b336b14 delete_cmd cleanup 2023-07-13 19:37:32 -04:00
bigtedde 3a7ee07cf3 debug_cmds cleanup 2023-07-13 19:33:56 -04:00
bigtedde 225fdb0b72 increased readability in delete_cmd 2023-07-13 17:29:11 -04:00
bigtedde eb37f4b9aa corrupted_archiver changed from fixture to function call 2023-07-13 17:26:12 -04:00
bigtedde 7fea384fa7 removed print statement from transfer_cmd 2023-07-13 17:16:30 -04:00
bigtedde 9a8d5da822 ValueError added in 'open_repository' 2023-07-13 15:51:58 -04:00
bigtedde 73c178d628 cleanup create_cmd 2023-07-13 15:42:50 -04:00
bigtedde b2d8210e5d testsuite/benchmark.py - 'cmd' -> 'cmd_fixture' 2023-07-13 11:45:59 -04:00
bigtedde f502941137 check_cmd cleaned up 2023-07-13 11:27:18 -04:00
bigtedde fdb21af6e6 cleanup bypass_lock_option tests 2023-07-13 11:09:12 -04:00
Ted Lawson 33645ad38a
Repo tests - conversion to pytest (#7626) 2023-07-11 01:40:51 +02:00
Ted Lawson 7df34fc4a6
Archive pytest conversion (#7661)
parameterized stats_progress and timestamp_parsing tests
2023-07-11 01:14:51 +02:00
TW 52db16b3eb
Merge pull request #7714 from PhrozenByte/docs-check-rewrite
Docs: Rewrite `borg check` docs
2023-07-11 00:00:07 +02:00
Daniel Rudolf 2647673dc8
Docs: Improve `borg check` docs 2023-07-10 22:41:24 +02:00
bigtedde 1e5c62f1a1 test_unix_socket fix 2023-07-09 22:12:03 -04:00
bigtedde 912df41c4a test_unix_socket fix 2023-07-09 21:42:37 -04:00
bigtedde 62bfd5e13a create_cmd changes 2023-07-09 18:32:02 -04:00
bigtedde 2c5f6645b4 changed socket path to secure temp file 2023-07-09 17:46:50 -04:00
bigtedde ed02164b68 fixed fuse_mount CM 2023-07-09 17:32:31 -04:00
bigtedde f1af13e544 removed unittest skips 2023-07-09 17:06:30 -04:00
bigtedde efc4481996 removed erroneous test from init 2023-07-09 16:40:53 -04:00
bigtedde 6cb87e5ff7 transfer_cmd converted 2023-07-09 16:31:44 -04:00
bigtedde 751bac0fb7 tar_cmds converted 2023-07-09 15:57:01 -04:00
bigtedde 6ca4e15c4b fixed issue in test_unix_socket 2023-07-09 15:27:41 -04:00
bigtedde 9a8fb00c10 serve_cmd converted 2023-07-09 15:05:27 -04:00
bigtedde 5cdbf03110 rlist_cmd converted 2023-07-09 14:57:13 -04:00
bigtedde a9cf42f6e3 rlist_cmd 2023-07-09 14:56:12 -04:00
bigtedde 116428cd4f rinfo_cmd converted 2023-07-09 14:41:12 -04:00
bigtedde 0f160cda29 return_codes converted 2023-07-09 14:34:06 -04:00
bigtedde 227f43958f rename_cmd converted 2023-07-09 11:57:57 -04:00
bigtedde c68e0b9936 recreate_cmd converted 2023-07-09 11:50:24 -04:00
bigtedde 673cd4718e rcreate_cmd converted 2023-07-09 11:13:15 -04:00
bigtedde a3bfc4d390 rdelete_cmd converted 2023-07-09 10:43:51 -04:00
bigtedde 216f13831e rcompress_cmd converted 2023-07-08 17:43:30 -04:00
bigtedde a4fc546c8a prune_cmd converted 2023-07-08 17:28:32 -04:00
TW 4dfce1cca4
Merge pull request #7719 from bket/fix_test
Fix failing test on OpenBSD
2023-07-08 02:20:07 +02:00
bigtedde 7e14361700 patterns converted 2023-07-07 17:50:44 -04:00
bigtedde 0a104a3435 mount_cmds converted 2023-07-07 17:48:29 -04:00
bigtedde 91dd71e3b1 lock_cmds converted 2023-07-07 16:49:01 -04:00
bigtedde 08ab71669a list_cmd converted 2023-07-07 16:40:39 -04:00
bigtedde 3cccf19671 key_cmds converted 2023-07-07 15:53:49 -04:00
bigtedde 725149cb8b info_cmd converted, edited generate tests comment 2023-07-07 15:26:50 -04:00
bigtedde b5901eb0a6 merge upstream changes 2023-07-07 15:16:11 -04:00
bigtedde a438176b85 help_cmd converted 2023-07-07 10:08:25 -05:00
Björn Ketelaars 1074089d37 Fix failing test on OpenBSD
A borgbackup-2.0.0b6 test fails on OpenBSD with the message below.

```
=================================== FAILURES ===================================
_____________________________ test_get_runtime_dir _____________________________

path = '/run/user/55/borg', mode = 511, pretty_deadly = True

    def ensure_dir(path, mode=stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO, pretty_deadly=True):
        """
        Ensures that the dir exists with the right permissions.
        1) Make sure the directory exists in a race-free operation
        2) If mode is not None and the directory has been created, give the right
        permissions to the leaf directory. The current umask value is masked out first.
        3) If pretty_deadly is True, catch exceptions, reraise them with a pretty
        message.
        Returns if the directory has been created and has the right permissions,
        An exception otherwise. If a deadly exception happened it is reraised.
        """
        try:
>           os.makedirs(path, mode=mode, exist_ok=True)

build/lib.openbsd-7.3-amd64-cpython-310/borg/helpers/fs.py:37:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
```

If `$XDG_RUNTIME_DIR` is not set `platformdirs.user_runtime_dir()`
returns one of 3 different paths
(https://github.com/platformdirs/platformdirs/pull/201). Proposed fix is
to check if `get_runtime_dir()` returns one of these paths.
2023-07-07 15:38:13 +02:00
TW 7914e38160
Merge pull request #7712 from ThomasWaldmann/manifest-item_keys
manifest: move item_keys into config dict, fixes #7710
2023-07-07 00:58:27 +02:00
TW cfbfe2423f
Merge pull request #7676 from RayyanAnsari/paths-win
Properly normalise paths on Windows
2023-07-07 00:42:03 +02:00
TW e63775a316
Merge pull request #7711 from ThomasWaldmann/doc-updates-master
doc updates (master)
2023-07-07 00:30:16 +02:00
Felix Schwarz ae0b3d2fff replace "datetime.utcfromtimestamp" with custom helper to avoid deprecation warnings when using Python 3.12 2023-07-06 21:46:19 +02:00
Daniel Rudolf a661da13ee
Docs: Improve explanation of `borg check --max-duration`'s side effects 2023-07-06 00:42:57 +02:00
Daniel Rudolf 9d59146de4
Docs: Remove technical description from `borg check` docs 2023-07-06 00:19:48 +02:00
Daniel Rudolf 9edbf4e931
Docs: Rewrite `borg check` docs
Fixes #7578
2023-07-06 00:17:55 +02:00
bigtedde 5bc1bbd3a3 extract_cmd converted 2023-07-04 19:35:48 -05:00
bigtedde 95d48c054a disk_full converted 2023-07-04 18:38:10 -05:00
Thomas Waldmann 51e68c24e4
manifest: move item_keys into config dict, fixes #7710
also: manifest.version == 2 now
2023-07-05 01:11:24 +02:00
bigtedde dfaea063a5 diff_cmd converted 2023-07-04 17:15:15 -05:00
Thomas Waldmann 8db8fd601b
docs: OS X -> macOS 2023-07-04 23:59:44 +02:00
bigtedde 99bf56cfcd delete_cmd converted 2023-07-04 16:53:06 -05:00
bigtedde d18525ae49 debug_cmds added 2023-07-04 16:35:09 -05:00
bigtedde 2cf784d5c6 combined all tests into one single Archiver folder PR 2023-07-04 15:35:51 -05:00
Rayyan Ansari 7e0cdd7c5e testsuite: Enable test_archived_paths on Windows 2023-07-04 19:44:22 +01:00
Rayyan Ansari 54b654e3b1 fs: Properly normalise paths on Windows
Use forward slashes and integrate the drive letter into the path.
2023-07-04 19:44:22 +01:00
TW cd678a032d
Merge pull request #7696 from ThomasWaldmann/macfuse-volname-master
mount: make up volname if not given (macOS), fixes #7690
2023-07-01 16:02:28 +02:00
Thomas Waldmann bd9af62c07
mount: make up volname if not given (macOS), fixes #7690
macFUSE supports a volname mount option to give what
finder displays on desktop / in directory list.

if the user did not specify it, we make something up,
because otherwise it would be "macFUSE Volume 0 (Python)".
2023-07-01 15:35:03 +02:00
Thomas Waldmann 2aecdb91d4
extract: fix false warning about pattern never matching, fixes #4110 2023-07-01 15:31:00 +02:00
Thomas Waldmann 58d3dbcec0
keyfile: improve key sanity check, fixes #7561
check key file structure, make sure the binary key
is not way too short (or zero) length.

if key file looks strange, emit warnings.
2023-06-29 23:13:29 +02:00
Thomas Waldmann ec1f2dfbf1
--files-cache=size: fix crash, fixes #7658 2023-06-29 23:09:24 +02:00
Thomas Waldmann 45cda981f9
test_sparse_file: skip test on win32
about 10-50% of the github windows CI runs fail due to
this - root cause unknown.

Example failure:

        # we first check if we could create a sparse input file:
        sparse_support = is_sparse(filename, total_size, hole_size)
        if sparse_support:
            # we could create a sparse input file, so creating a backup of it and
            # extracting it again (as sparse) should also work:
            self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
            self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
            with changedir(self.output_path):
                self.cmd(f"--repo={self.repository_location}", "extract", "test", "--sparse")
            self.assert_dirs_equal("input", "output/input")
            filename = os.path.join(self.output_path, "input", "sparse")
            with open(filename, "rb") as fd:
                # check if file contents are as expected
>               self.assert_equal(fd.read(hole_size), b"\0" * hole_size)
E               AssertionError: b'\x0[8388602 chars]x00\xf0Y\xb5\xe3\xee\xf3\x1f\xe3L\xcf\xae\x92\[159253621 chars]\x00' != b'\x0[8388602 chars]x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0[159383505 chars]\x00'

src/borg/testsuite/archiver/extract_cmd.py:212: AssertionError
2023-06-22 23:10:31 +02:00
TW c89eb98c18
Merge pull request #7665 from ThomasWaldmann/fix-benchmark
benchmark cpu: use sanitized path, fixes #7653
2023-06-22 21:56:31 +02:00
TW 67a32ee603
Merge pull request #7664 from ThomasWaldmann/test-for-backslashes
no backslashes
2023-06-22 21:41:37 +02:00
Thomas Waldmann 420eae6138
benchmark cpu: use sanitized path, fixes #7654 2023-06-22 21:22:18 +02:00
TW 44147fe5b3
Merge pull request #7663 from ThomasWaldmann/send-log-cb
remote logging/progress: add callback to send queued records, fixes #7662
2023-06-22 21:19:18 +02:00
Thomas Waldmann 4f49f9bae6
make_path_safe: remove test for backslashes, fixes #7651
looks like some tools use backslashes in linux/macOS paths.
2023-06-22 20:49:14 +02:00
Thomas Waldmann 3aec98ada9
remote logging/progress: use callback to send queued records, fixes #7662 2023-06-22 20:09:29 +02:00
Ted Lawson a5c4d0d310
Xattr.py unittest to pytest conversion (#7657) 2023-06-20 16:08:44 +02:00
Tarrailt 616d5e7330
Add --format option to `borg diff`, resolve issue #4634 (#7534)
diff: add --format option

also: refactoring/improvements of BaseFormatter
2023-06-11 22:41:36 +02:00
TW 8506c05ab6
Merge pull request #7642 from Deric-W/typehints
replace `LRUCache` internals with `OrderedDict`
2023-06-11 17:11:41 +02:00
Eric Wolf ad3c890167
rephrase docstring and remove unused sentinel 2023-06-11 13:56:58 +02:00
Eric Wolf e683c80c75
replace `LRUCache` internals with `OrderedDict`
Replacing the internals should make the implementation faster
and simpler since the order tracking is done by the `OrderedDict`.

Furthermore, this commit adds type hints to `LRUCache` and
renames the `upd` method to `replace` to make its use more clear.
2023-06-10 20:57:32 +02:00
TW 4f76f595a9
Merge pull request #7635 from eoli3n/master
Improve patterns help
2023-06-10 14:39:31 +02:00
Thomas Waldmann 518c4fbca8
skip test_import_tar_with_dotdot for binary testing 2023-06-10 14:17:07 +02:00
eoli3n 095d5f463b improve patterns help: added declarative includes sample 2023-06-10 14:00:06 +02:00
eoli3n ba922d2e0a improve patterns help: define a pattern style 2023-06-10 14:00:06 +02:00
eoli3n 9bbb38d9ab improve patterns help 2023-06-10 14:00:06 +02:00
Thomas Waldmann b7ce3b1156
make sure we do not get backslashes into item paths
on windows, we also want slashes, not backslashes.
2023-06-10 12:52:00 +02:00
Thomas Waldmann db96c0c487
subclass MakePathSafeAction from Highlander 2023-06-10 11:41:31 +02:00
Peter Gerber 438cf2e7ef
Sanitize paths during archive creation/extraction/...
Paths are not always sanitized when creating an archive and,
more importantly, never when extracting one. The following example
shows how this can be used to attempt to write a file outside the
extraction directory:

$ echo abcdef | borg create -r ~/borg/a --stdin-name x/../../../../../etc/shadow archive-1 -
$ borg list -r ~/borg/a archive-1
-rw-rw---- root   root          7 Sun, 2022-10-23 19:14:27  x/../../../../../etc/shadow
$ mkdir borg/target
$ cd borg/target
$ borg extract -r ~/borg/a archive-1
x/../../../../../etc/shadow: makedirs: [Errno 13] Permission denied: '/home/user/borg/target/x/../../../../../etc'

Note that Borg tries to extract the file to /etc/shadow and the
permission error is a result of the user not having access.

This patch ensures file names are sanitized before archiving.
As for files extracted from the archive, paths are sanitized
by making all paths relative, removing '.' elements, and removing
superfluous slashes (as in '//'). '..' elements, however, are
rejected outright. The reasoning here is that it is easy to start
a path with './' or insert a '//' by accident (e.g. via --stdin-name
or import-tar). '..', however, seem unlikely to be the result
of an accident and could indicate a tampered repository.

With paths being sanitized as they are being read, this "errors"
will be corrected during the `borg transfer` required when upgrading
to Borg 2. Hence, the sanitation, when reading the archive,
can be removed once support for reading v1 repositories is dropped.
V2 repository will not contain non-sanitized paths. Of course,
a check for absolute paths and '..' elements needs to kept in
place to detect tempered archives.

I recommend treating this as a security issue. I see the following
cases where extracting a file outside the extraction path could
constitute a security risk:

a) When extraction is done as a different user than archive
creation. The user that created the archive may be able to
get a file overwritten as a different user.
b) When the archive is created on one host and extracted on
another. The user that created the archive may be able to
get a file overwritten on another host.
c) When an archive is created and extracted after a OS reinstall.
When a host is suspected compromised, it is common to reinstall
(or set up a new machine), extract the backups and then evaluate
their integrity. A user that manipulates the archive before such
a reinstall may be able to get a file overwritten outside the
extraction path and may evade integrity checks.

Notably absent is the creation and extraction on the same host as
the same user. In such case, an adversary must be assumed to be able
to replace any file directly.

This also (partially) fixes #7099.
2023-06-07 23:23:53 +02:00
Thomas Waldmann ae97584218
fix logging, add some comments
shutting down logging is problematic as it is global
and we do multi-threaded execution, e.g. in tests.

thus, rather just flush the important loggers and keep
them alive.
2023-06-06 21:13:31 +02:00
Thomas Waldmann ffc59dd071
implement unix domain (ipc) socket support
server (listening) side:
borg serve --socket  # default location
borg serve --socket=/path/to/socket

client side:
borg -r socket:///path/to/repo create ...
borg --socket=/path/to/socket -r socket:///path/to/repo ...

served connections:
- for ssh: proto: one connection
- for socket: proto: many connections (one after the other)

The socket has user and group permissions (770).

skip socket tests on win32, they hang infinitely, until
github CI terminates them after 60 minutes.

socket tests: use unique socket name

don't use the standard / default socket name, otherwise tests
running in parallel would interfere with each other by using
the same socket / the same borg serve process.

write a .pid file, clean up .pid and .sock file at exit

add stderr print for accepted/finished socket connection
2023-06-06 21:12:54 +02:00
Thomas Waldmann 7878a34fd4
add get_runtime_dir / BORG_RUNTIME_DIR, tests, docs 2023-06-06 11:58:48 +02:00
TW 9f51600f20
Merge pull request #7627 from ThomasWaldmann/fix-chunksize-distrib-test-master
fix test_buzhash_chunksize_distribution
2023-06-06 10:43:53 +02:00
Thomas Waldmann 6625fb52ac
fix test_buzhash_chunksize_distribution
the last chunk can be smaller than 2**min_exp.
2023-06-06 10:09:53 +02:00
bigtedde 83d821171e Parameterize 'version' and 'item' tests 2023-06-04 14:38:22 -07:00
TW e70b5b1e94
Merge pull request #7620 from bigtedde/parameterize_test_compress
Parametrize compression tests
2023-06-02 23:03:24 +02:00
bigtedde e0f6685498 parameterized compression tests 2023-06-02 12:55:35 -07:00
David Rambo ee0ca13ab5 Update help docs to reflect support for alternative grouping in shell-style patterns 2023-05-31 16:57:31 -07:00
David Rambo 4efc7cd0bd Add support and tests for shell-style alternatives
Code review fixes

Remove empty line
2023-05-31 15:38:05 -07:00
Thomas Waldmann e2ea5cf164
tests: fix usage of .reopen()
also:
add missing param to RemoteRepositoryTestCase.open method, but ignore it.
2023-05-29 23:02:42 +02:00
Thomas Waldmann 48c7879887
RemoteRepository: add .close method
- tears down logging (so no new log output is generated afterwards)
- sends all queued log output
- then returns

also: make stdin_fd / stdout_fd instance variables
2023-05-29 22:40:55 +02:00
Thomas Waldmann f84951b53c
add logging debugging functionality 2023-05-29 22:40:53 +02:00
Thomas Waldmann ac4b5c35da
borg serve: shutdown server after sending all queued log records 2023-05-29 22:40:52 +02:00
Thomas Waldmann 746cef1cba
teardown logging in exec_cmd
for normal borg command invocation:
- logging is set up in Archiver.run
- the atexit handler calls logging.shutdown when process terminates

for tests:
- Archiver.run called by exec_cmd
- no atexit handler executed as process lives on
- borg.logger.teardown (calls shutdown and configured=False) now
  called in exec_cmd
2023-05-29 22:40:50 +02:00
Thomas Waldmann dac4609468
remove_handlers 2023-05-29 22:40:49 +02:00
Thomas Waldmann c3a4568870
channel progress output via logging system
- simplify progress output (no \r, no terminal size related tweaks)
- emit progress output via the logging system (so it does not use stderr
  of borg serve)
- progress code always logs a json string, the json has all needed
  to either do json log output or plain text log output.
- use formatters to generate plain or json output from that.
- clean up setup_logging
- use a StderrHandler that always uses the **current** sys.stderr
- tweak TestPassphrase to not accidentally trigger just because of seeing 12 in output
2023-05-29 22:40:47 +02:00
Thomas Waldmann 0be545dc45
remove ProgressIndicatorEndless (not used) 2023-05-29 22:40:45 +02:00
Thomas Waldmann e351e67aee
RepositoryServer: do not use stderr for logging, see #7604
Instead, install a handler that sends the LogRecord dicts to a queue.
That queue is then emptied in the borg serve main loop and
the LogRecords are sent msgpacked via stdout to the client,
similar to the RPC results.

On the client side, the LogRecords are recreated from the
received dicts and fed into the clientside logging system.

As we use msgpacked LogRecord dicts, we don't need JSON for
this purpose on the borg serve side any more.
On the client side, the LogRecords will then be either formatted
as normal text or as JSON log output (by the clientside log
formatter).
2023-05-29 22:40:42 +02:00
Thomas Waldmann 6ae23bc0d7
fix typo 2023-05-29 15:04:30 +02:00
nain 4a7a5b2253 Add function to clear empty directories at end of compact process.
Compact moves data to new segments, and then removes the old segments.
When enough segments are moved, directories holding the now cleared segments
may thus become empty.

With this commit any empty directories are cleared after segments compacting.
Fixes #6823
2023-05-28 01:48:32 -04:00
nain ffe237ce0c unify scanning and listing of segment dirs / segment files and apply good practices
+ os.scandir instead of os.listdir
  Improved speed and added flexibility with attributes (name, path, is_dir(), is_file())
+ use is_dir / is_file to make sure  we're reading only dirs / files respectively
+ Filtering to particular start, end index range built in
+ Move value bounds of segment (index) into constants module and use them instead

Resolves #7597

(forward patch from commits c9f35a16e9bf9e7073c486553177cef79ff1cb06^..edb5e749f512b7737b6933e13b7e61fefcd17bcb)
2023-05-27 07:54:32 -04:00
Thomas Waldmann 89297398c4
fix borg.remote._resolve_path
this used to call get_base_dir (and would have needed
legacy=True now to work like expected).

rather implemented the desired behaviour locally and
got rid of the legacy call (which was a bit strange
anyway as it also considered BORG_BASE_DIR, which is
unexpected when resolving ~).
2023-05-24 17:01:45 +02:00
Thomas Waldmann 90c6b7f794
remote exceptions: simplify sysinfo processing
in the sysinfo function, there is a way to suppress
all sysinfo output via an env var and just return an
empty string.

so we can expect it is always in unpacked, but it
might be the empty string.
2023-05-24 15:30:20 +02:00
Thomas Waldmann 2331341b74
simplify handle_error 2023-05-24 14:38:30 +02:00
Thomas Waldmann 4b796a7337
remote repos: remove support for borg < 1.1.0 ($LOG, logging setup)
log output:

always expect json, remove $LOG format support.

we keep limited support for unstructured format also,
just not to lose anything from remote stderr.
2023-05-24 14:38:24 +02:00
Thomas Waldmann 51177b9f06
remote repos: remove support for borg < 1.1.0 (exceptions)
exception infos:
ancient borg gave only limited infos about exceptions,
but recent ones give more.
2023-05-24 02:13:30 +02:00
Thomas Waldmann 591d8efac4
remote repos: remove support for borg < 1.1.0 (rpc data format, version)
rpc format:
ancient borg used tuples in the rpc protocol,
but recent ones use easier-to-work-with dicts.

version info:
we expect dicts with server/client version now.
2023-05-24 02:13:01 +02:00
Thomas Waldmann 1fb1cc3ea3
tests: check buzhash chunksize distribution, see #7586 2023-05-23 00:20:28 +02:00
jetchirag eeefa55428
do not crash for empty archives list in borg rlist date based matching (#7544)
fix ValueError for empty archives list, add a test

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@gmail.com>
2023-05-20 12:30:03 +02:00
Thomas Waldmann b9d0f00099
RepositoryTestCaseBase: remove need for "with" after reopen()
setUp enters the context manager, so let's .reopen() leave it.
then create a fresh Repository instance in self.repository and
enter the context manager again. tearDown then will leave that.
2023-05-20 01:31:07 +02:00
Thomas Waldmann f0e4be76b1
RepositoryTestCaseBase: call __exit__
As we call __enter__ in setUp,
let's call __exit__ in tearDown.
2023-05-20 01:31:05 +02:00
Thomas Waldmann 3d82be0b58
fix RepositoryTestCaseBase.reopen method
"if self.repository" did not work as expected:
- Repository has a __len__ method, so the boolean evaluation was calling that.
- self.repository is also not set to None anywhere.
2023-05-20 01:30:14 +02:00
Thomas Waldmann 989b0a2847
use correct path for security dir when accessing legacy repos (v1)
while on macOS the new and old security dir location is the same path,
this is not the case on e.g. Linux, it could move from .config/borg/security to
.local/share/borg/security .

See #5760.
2023-05-19 21:12:59 +02:00
Thomas Waldmann b8d49a0274
put security infos into data dir, fixes #5760 2023-05-18 12:48:45 +02:00
Thomas Waldmann b0b32e35f5
tests: avoid long ids in pytest output
sometimes the automatically computed IDs are just too long,
so rather give IDs directly or avoid them otherwise.
2023-05-18 05:46:33 +02:00
Thomas Waldmann 0744b7a241
fix test_extract_continue for hfs timestamp granularity 2023-05-17 00:19:42 +02:00
Thomas Waldmann 82ccf0c08c
fix test_extract_continue
make a hardlink to keep the inode allocated,
so it can not re-use the same inode when it
(deletes and re)creates the file.
2023-05-16 19:12:46 +02:00
elandorr bfe6e0da5d
Update create_cmd.py 2023-05-15 11:49:22 +00:00
elandorr c83507eb0c
mention paths-from-stdin's exclusiveness 2023-05-14 19:24:55 +00:00
elandorr 4fb2f2151e
include/exclude options 2023-05-14 19:23:15 +00:00
elandorr e086d2a8f6
markup fix + note about MAX_DATA_SIZE 2023-05-14 07:14:48 +00:00
elandorr 8e2f5a621b
escape 2023-05-14 07:09:45 +00:00
TW b70cefa474
Merge pull request #7556 from ThomasWaldmann/kill-nonce-manager
remove nonce management, related repo methods
2023-05-12 00:00:29 +02:00
Thomas Waldmann f970679b62
low_level crypto: fix borg version in comments 2023-05-11 20:10:55 +02:00
Thomas Waldmann 44f58b0870
low_level crypto: minor cleanup
HMAC is not used, we use hmac from py stdlib.
2023-05-11 20:09:47 +02:00
Thomas Waldmann e02d9edc34
remove nonce management, related repo methods
not needed for borg2 repos (we derive a new session key for each borg
invocation and start counting from 0).

also not needed for borg 1.x repos because we only read them (borg transfer)
and won't write new encrypted data to them.
2023-05-11 17:51:49 +02:00
Thomas Waldmann 0b62338d4a
borg transfer --compression=C --recompress=M, fixes #7529 2023-04-24 23:46:38 +02:00
TW ee9bf28df9
Merge pull request #7524 from ThomasWaldmann/test-no-backslashes
tests: check for posix-like paths in archives, see #7120
2023-04-18 18:21:48 +02:00
Thomas Waldmann 573275e678
extract --continue: continue a previously interrupted extraction, fixes #1356
This skips over all previously fully extracted regular files,
but will delete and fully re-extract incomplete files.
2023-04-16 21:09:48 +02:00
Thomas Waldmann 7786cc7cb4
extract: support extraction of atime/mtime on win32 2023-04-16 20:40:35 +02:00
Thomas Waldmann 9e534c1929
Archive.extract_item: remove unused params, make most params kwargs
stripped_components: this is done already in do_extract, it modifies item.path accordingly.

original_path: not used any more.

also: run black.
2023-04-16 15:40:36 +02:00
Thomas Waldmann 0dee28bd9f
tests: check for posix-like paths in archives, see #7120 2023-04-15 20:29:26 +02:00
TW 0679cbd410
Merge pull request #7523 from ThomasWaldmann/optimize-src-dir-master
tests: use a smaller dir for src_dir, fixes #7518
2023-04-15 17:19:32 +02:00
Thomas Waldmann 4505c90920
tests: use a smaller dir for src_dir, fixes #7518
also: introduce src_file, which is a file in src_dir.
2023-04-15 16:46:23 +02:00
TW b52a8af6f0
Merge pull request #7517 from snsmac/feat/highlander
Ensure that cli options specified with action=Highlander can only be set once.
2023-04-15 16:45:28 +02:00
snsmac 53b4cf05fb Ensure that cli options specified with action=Highlander can only be set once, even if the set value is a default value. Add tests for action=Highlander. See #7500 #6269 2023-04-15 16:12:36 +02:00
TW 9263705de7
Merge pull request #7521 from ThomasWaldmann/fix-argparse-errors-master
Fix argparse error messages
2023-04-15 15:08:07 +02:00
TW 81e618ba28
Merge pull request #7513 from ThomasWaldmann/friendlier-exceptions-master
refactor toplevel exception handling, see #6018
2023-04-15 15:03:27 +02:00
Thomas Waldmann 0b40e038ad
fix CompressionSpec validator and tests 2023-04-12 01:45:46 +02:00
Thomas Waldmann 05bf29f504
fix SortBySpec validator 2023-04-12 01:21:43 +02:00
Thomas Waldmann 0f923c8c4a
fix FilesCacheMode validator 2023-04-12 01:18:05 +02:00
Thomas Waldmann 6d38530ff1
fix ChunkerParams validator and tests 2023-04-12 01:15:46 +02:00
TW 1e1c922298
Merge pull request #7512 from ThomasWaldmann/prune-list-pruned-master
prune --list-kept/--list-pruned, fixes #7511
2023-04-08 17:37:33 +02:00
TW 33599b9115
Merge pull request #7509 from ThomasWaldmann/build-filter-microopt
build_filter: micro opt / easier code, fixes #3390
2023-04-08 17:11:40 +02:00
Thomas Waldmann 02b28882b3
prune --list-kept/--list-pruned, fixes #7511
use this to only list the kept (or pruned) archives.
--list-pruned and --list-kept also work in a additive way.

implied logging: support multiple prune options activating same logger

if any of --list / --list-kept / --list-pruned is used,
it should put the borg.output.list logger to INFO level,
otherwise to WARN level.
2023-04-08 15:40:07 +02:00
Thomas Waldmann 9f4f2b42e3
implement BORG_<CMD>_FORMAT env vars, fixes #5166
for now for: prune, list, rlist.
2023-04-08 00:53:53 +02:00
Thomas Waldmann b0b3d9e08c
refactor toplevel exception handling, see #6018
as a first step, i moved all the traceback formatting
to format_tb.

also, it **first** prints the error and then the traceback
as additional information for a bug report, as suggested
by @jimparis in that ticket.
2023-04-08 00:12:06 +02:00
TW 48f3161248
Merge pull request #7510 from ThomasWaldmann/prune-format-master
prune --short/--format: enable users to format the list output, fixes #3238
2023-04-07 20:24:40 +02:00
TW b8337b6f77
Merge pull request #7507 from ThomasWaldmann/ignore-empty-path-master
create: ignore empty paths, print warning, fixes #5637
2023-04-07 19:39:27 +02:00
TW cfbaa3feae
Merge pull request #7506 from ThomasWaldmann/archive-size-nfiles
rlist: size and nfiles format keys
2023-04-07 19:38:54 +02:00
Thomas Waldmann 7686a721af
strip_components: remove bad test 2023-04-07 19:34:32 +02:00
Thomas Waldmann a0e1110c16
prune --short/--format: enable users to format the list output, fixes #3238 2023-04-07 19:30:22 +02:00
Thomas Waldmann 8060d4100a
build_filter: micro opt / easier code, fixes #3390 2023-04-07 18:21:17 +02:00
Thomas Waldmann 08a2db9410
benchmark crud: use TemporaryDirectory below given path, fixes #4706 2023-04-07 18:05:19 +02:00
Thomas Waldmann 7df6301144
create: ignore empty paths, print warning, fixes #5637 2023-04-07 17:04:00 +02:00
Thomas Waldmann 7a2c757c69
rlist: add size and nfiles to format keys, fixes #6086 2023-04-07 16:37:17 +02:00
Thomas Waldmann 355a50225f
ArchiveFormatter.get_meta: add default value argument 2023-04-07 14:23:43 +02:00
TW 6662b8dadb
Merge pull request #7498 from ThomasWaldmann/mount-dir-check-master
mount: improve mountpoint error msgs, see #7496
2023-04-06 20:26:43 +02:00
Thomas Waldmann 12f9a26fad
common options: more Highlander options, fixes #6269 2023-04-06 19:11:58 +02:00
Thomas Waldmann 971438dfa0
import/export-tar: more Highlander options, fixes #6269 2023-04-06 17:53:27 +02:00
Thomas Waldmann d0d8cd1edf
serve: more Highlander options, fixes #6269 2023-04-06 17:49:40 +02:00
Thomas Waldmann 1a6d1d0c7c
rlist: more Highlander options, fixes #6269 2023-04-06 17:47:56 +02:00
Thomas Waldmann 6ca2256f26
rcompress: more Highlander options, fixes #6269 2023-04-06 17:46:17 +02:00
Thomas Waldmann 644796ad6b
list: more Highlander options, fixes #6269 2023-04-06 17:44:07 +02:00
Thomas Waldmann 6074ca44d9
debug: more Highlander options, fixes #6269 2023-04-06 17:40:47 +02:00
Thomas Waldmann ffdd156fd4
compact: more Highlander options, fixes #6269 2023-04-06 17:36:49 +02:00
Thomas Waldmann 5d8986c440
check: more Highlander options, fixes #6269 2023-04-06 17:35:54 +02:00
Thomas Waldmann afccb1dee5
transfer: more Highlander options, fixes #6269 2023-04-06 17:33:41 +02:00
Thomas Waldmann 79b39c4652
recreate: more Highlander options, fixes #6269 2023-04-06 17:31:48 +02:00
Thomas Waldmann 21a3a95cc8
rcreate: more Highlander options, fixes #6269 2023-04-06 17:26:31 +02:00
Thomas Waldmann 13e99033cb
delete: more Highlander options, fixes #6269 2023-04-06 17:15:09 +02:00
Thomas Waldmann 1aae04e66e
prune: more Highlander options, fixes #6269 2023-04-06 17:10:16 +02:00
Thomas Waldmann 645b0088c5
create: more Highlander options, fixes #6269 2023-04-06 17:03:08 +02:00
Thomas Waldmann 7eb04b86ed
mount: improve mountpoint error msgs, see #7496
saying "must be a writable directory" can distract
from the real root cause as seen in #7496.

so we better first check if the mountpoint is an
existing directory and if not, just tell that.

after that, we check permissions and if they are not
like required, tell that.
2023-04-04 23:25:29 +02:00
TW ffea8a0f25
Merge pull request #7487 from ThomasWaldmann/pyupgrade-py39-plus
pyupgrade --py39-plus ./**/*.py
2023-04-02 23:02:07 +02:00
TW 4faf375339
Merge pull request #7492 from ThomasWaldmann/fix-progress-msg-width-master
ProgressIndicatorPercent: fix space computation for wide chars, fixes #3027
2023-04-02 22:59:43 +02:00
TW 6b02c05f2b
Merge pull request #7489 from ThomasWaldmann/option-x-help-master
improve --one-file-system help /docs
2023-04-02 21:58:18 +02:00
Thomas Waldmann 3dd14f4855
ProgressIndicatorPercent: fix space computation for wide chars, fixes #3027
needs to use swidth() in case there are wide chars (like CJK)
in the left part of the msg (e.g. an archive name).
2023-04-02 21:57:02 +02:00
Thomas Waldmann b7adee65bd
--one-file-system: add macOS apfs notes, fixes #4876 2023-04-02 17:28:20 +02:00
Thomas Waldmann 63e17d6da2
borgfs.statfs: add comments 2023-04-02 16:56:28 +02:00
Thomas Waldmann 6ca1ed9716
improve --one-file-system help string, fixes #5618 2023-04-02 14:30:53 +02:00
Thomas Waldmann 52793be923
pyupgrade --py39-plus ./**/*.py 2023-04-02 02:14:54 +02:00
nain-F49FF806 dfef2b9092
fix config/cache dir compatibility issues, fixes #7445 (#7448)
fix config dir compatibility issue, fixes #7445

- add tests
- make sure the result of get_cache_dir matches pre and post #7300 where desired
- harmonize implementation of config_dir_compat and cache_dir_compat tests

Co-authored-by: nain <126972030+F49FF806@users.noreply.github.com>
2023-03-30 00:24:42 +02:00
Soumik Dutta 1428ffeae9
Add parse-obj and format-obj debug commands (#7443)
add parse-obj and format-obj debug commands, fixes #7406

Signed-off-by: Soumik Dutta <shalearkane@gmail.com>
2023-03-28 21:45:48 +02:00
Thomas Waldmann 2692fa1146
skip "do not retry when permissions denied" test if running as root
we can not take away read permissions for root,
so the test would fail.
2023-03-28 15:55:10 +02:00