Commit graph

3486 commits

Author SHA1 Message Date
John C. McCabe-Dansted
5ba8acfe61 cli error help now exactly matches test-ux.sh.blessed_stderr 2026-03-25 04:09:38 +08:00
gmatht
dddbaf02fc tests: CLI UX regression coverage and test-ux.sh
Add cli_guidance and argparsing hint tests; adjust repository remote tests; manual UX smoke script.
2026-03-25 04:09:38 +08:00
gmatht
ed85f0004f cli: print borg1 option migration under Common fixes
preprocess_args: glob-archives and related hints with example; omit Rust version branding.
2026-03-25 04:09:38 +08:00
gmatht
d1e80cfab5 cli: ArgumentParser hints for commands, locations, and argv
Invalid subcommand synonyms/fuzzy hints, argv-based examples, Common fixes for repo::archive and flags before subcommand, repo-create encryption reminder.
2026-03-25 04:09:38 +08:00
gmatht
ffbfb80a30 cli: repository DoesNotExist and InvalidRepository common fixes
Replace useless repo-info bullet with path reasons; add InvalidRepository guidance; get_message returns full text.
2026-03-25 04:09:38 +08:00
gmatht
d6d0cd6de3 cli: expand repo::archive parse errors with corrected command lines
When --repo uses legacy repo::archive syntax, show list and repo-info style examples.
2026-03-25 04:09:29 +08:00
Ebuzer Celil Durmaz
6bc41465a4
Add --json flag to borg prune for structured output (#9512)
Some checks failed
Lint / lint (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / security (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
CI / asan_ubsan (push) Has been cancelled
CI / native_tests (push) Has been cancelled
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Has been cancelled
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Has been cancelled
CI / vm_tests (OmniOS, false, omnios, r151056) (push) Has been cancelled
CI / vm_tests (OpenBSD, false, openbsd, 7.8) (push) Has been cancelled
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Has been cancelled
CI / windows_tests (push) Has been cancelled
prune: add --json option, fixes #9222

Enable programmatic extraction of prune/keep decisions via
structured JSON output, instead of parsing log message text.

Follows the repo-list --json pattern: outputs a single JSON object
with repository, encryption, and archives array. Each archive
includes pruned (bool), rule, and rule_number fields.
2026-03-20 21:03:01 +01:00
Thomas Waldmann
2ac51d71cf
patterns: allow backslashes in paths, fixes #9518
On all POSIX systems, a backslash is a normal character in filenames and not a path separator.
2026-03-19 17:41:51 +01:00
ebuzerdrmz44
6b51f36569 passing black lint 2026-03-18 16:15:30 +03:00
ebuzerdrmz44
440b7039af addressing review 2026-03-18 16:02:34 +03:00
ebuzerdrmz44
6a3158729f about issue 2026-03-18 02:00:21 +03:00
trxvorr
d7bbcfb98b archiver: warn about MSYS2 path translation, fixes #9339
This adds a runtime warning when running under MSYS2/Git Bash without the necessary environment variables to disable automatic path translation. The documentation is also updated to explain this behavior and how to mitigate it.
2026-03-15 20:54:59 +05:30
Thomas Waldmann
a2ea1e9883
add rest store support 2026-03-15 13:19:39 +01:00
Thomas Waldmann
65de69943e
enhance tag_validator, fixes #9466 2026-03-11 23:11:38 +01:00
Thomas Waldmann
5f4e921b9a
create: add --tags, fixes #9401
- add `--tags TAG [TAG ...]` option to `borg create` to tag newly created archives.
- validate the tags exactly like `borg tag` does, including checking that any special tags starting with `@` are known `SPECIAL_TAGS`.
- add `test_create_tags` and `test_create_invalid_tags` to ensure proper behavior.
2026-03-11 19:28:56 +01:00
Thomas Waldmann
90f84e7219
create: add --hostname/--username, fixes #9402
- Added `--hostname` and `--username` command-line options to `borg create`
- Updated Archive to capture and store these explicit values, falling back to system defaults
- Added `test_explicit_hostname_and_username` to verify the functionality
2026-03-11 18:21:38 +01:00
TW
a03d1780a5
Merge pull request #9462 from ThomasWaldmann/trailing-sparse-windows-master
Some checks are pending
Lint / lint (push) Waiting to run
CI / lint (push) Waiting to run
CI / security (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OmniOS, false, omnios, r151056) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CI / windows_tests (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
fix spurious sparse test fail on win32, fixes #7616
2026-03-11 13:57:56 +01:00
Thomas Waldmann
871c89bea0
Fix intermittent test_with_lock failure (race condition), fixes #8810.
test_with_lock previously relied on a hardcoded timeout
(`time.sleep(4)`) to ensure the first background command acquired
the repository lock before the second command tried to get it. On
extremely slow CI runners, this was sometimes too short, allowing
the second command to falsely acquire the lock.

This commit replaces the arbitrary sleep with true synchronization:
- The first command now blocks indefinitely using `sys.stdin.read()`.
- The test deterministically waits for lock acquisition by reading
  `p1.stdout.readline()` which guarantees the lock is held.
- After the second command correctly fails, the first command is
  smoothly unblocked and terminated by passing `input=""` to
  `p1.communicate()`.
2026-03-11 11:40:42 +01:00
Thomas Waldmann
6d85812e12
fix spurious sparse test fail on win32, fixes #7616
Python's `os.truncate()` on Windows relies on `SetEndOfFile()`, which does
not initialize the extended disk space with zeroes. This means that
trailing sparse holes simply leave uninitialized garbage data at the end
of the file.

During sparse file extraction, when the very last chunk is a sparse hole,
the VDL (Valid Data Length) is not properly advanced by `os.truncate()`.
As a result, reading from the end of the file fetches random disk garbage
instead of zeroes, causing spurious test failures at boundaries (like
2MB or 8MB) depending on what was in the uninitialized disk sectors.

Fix this by tracking trailing holes and manually writing a single `b"\0"`
byte at the end of the file before truncating on Windows. Writing explicit
data forces NTFS to officially advance the VDL and securely zero-fill the
preceding hole space.

Re-enable `test_sparse_file` on Windows.
2026-03-11 10:58:54 +01:00
Thomas Waldmann
c98e93bc0b
fix race condition in test_with_lock, fixes #8810 2026-03-11 00:13:53 +01:00
Thomas Waldmann
4f2f2255c3
create --paths-from-shell-command, fixes #5968
This adds the `--paths-from-shell-command` option to the `create` command, enabling the use of shell-specific features like pipes and redirection when specifying input paths. Includes related test coverage.
2026-03-10 20:16:26 +01:00
Thomas Waldmann
e15547a685
import ActionSubCommands from jsonargparse 2026-03-10 20:15:59 +01:00
Thomas Waldmann
4a6b4130ef
completion: use new get_completion_script method 2026-03-10 18:36:35 +01:00
Thomas Waldmann
cf6fd0769d
use jsonargparse's PositiveInt 2026-03-10 18:36:32 +01:00
Thomas Waldmann
678df16bad
add support for auto-generated environment variables (jsonargparse) 2026-03-10 18:36:31 +01:00
Thomas Waldmann
63a45c6c21
add support for yaml config files, default config 2026-03-10 18:36:30 +01:00
Thomas Waldmann
2f778b974b
argparsing: add ArgumentParser subclass with borg's usual defaults
Borg's ArgumentParser (in borg.helpers.argparsing) now subclasses
jsonargparse's ArgumentParser and pre-sets two defaults that every
borg parser uses:

  formatter_class = RawDescriptionHelpFormatter
  add_help        = False
2026-03-10 18:36:28 +01:00
Thomas Waldmann
975212bbec
simplify flatten_namespace, add docstring for argparsing 2026-03-10 18:36:27 +01:00
Thomas Waldmann
fac47c6785
archiver: replace CommonOptions suffix hack with jsonargparse-native approach
The old code worked around argparse's flat namespace by appending
_maincommand / _midcommand / _subcommand suffixes to every common
option's dest (e.g. log_level_subcommand), then resolving them with
CommonOptions.resolve() after parsing.  This polluted config key names
and env var names (BORG_LOG_LEVEL_SUBCOMMAND instead of BORG_LOG_LEVEL).

jsonargparse nests subcommand arguments automatically, so the workaround
is no longer needed.  Each parser level now registers common options with
their clean dest name.  flatten_namespace() is updated to a two-pass
depth-first walk so the most-specific (innermost) value wins naturally:

  borg --info create --debug  →  log_level = "debug"  (subcommand wins)
  borg --info create          →  log_level = "info"   (top-level fills gap)

For append-action options (--debug-topic) values from all levels are
merged (outer + inner) to preserve the accumulation behaviour.
2026-03-10 18:36:26 +01:00
Thomas Waldmann
71212d2d7f
add octal_int validator 2026-03-10 18:36:24 +01:00
Thomas Waldmann
ee58cb4e44
reorg imports 2026-03-10 18:36:23 +01:00
Thomas Waldmann
83b8935abf
move compress.CompressionSpec to helpers.parseformat.CompressionSpec
other validators / specs are also there and it is easier to maintain
as Python code. the compress module is Cython code.
2026-03-10 18:36:20 +01:00
Thomas Waldmann
7250fd947e
helpers.jap_helper -> helpers.argparsing 2026-03-10 18:36:19 +01:00
Thomas Waldmann
be2b3363e2
reorg imports 2026-03-10 18:36:18 +01:00
Thomas Waldmann
a708397612
fix argparsing test 2026-03-10 18:36:16 +01:00
Thomas Waldmann
223a834a3d
adapt borg completion for jsonargparse 2026-03-10 18:36:12 +01:00
Thomas Waldmann
393b2cbc11
import from jsonargparse: SUPPRESS, REMAINDER, NameSpace 2026-03-10 18:36:11 +01:00
Thomas Waldmann
e39d06ee98
blacken src 2026-03-10 18:36:09 +01:00
Thomas Waldmann
27561bd9cc
SortBySpec: avoid triggering bandit security checker
Guess it was triggered due to naming the variable "token",
maybe "sort_key" is less problematic.
2026-03-10 18:36:08 +01:00
Thomas Waldmann
2cff41d894
migrate to jsonargparse 2026-03-10 18:36:04 +01:00
Thomas Waldmann
e3dcf98775
refactor: separate pattern roots from positional paths
Previously, ArgparsePatternAction and ArgparsePatternFileAction
appended recursion roots directly to args.paths. This mixed
CLI positional paths with paths derived from patterns
(e.g., using the `R` root path command in a pattern file),
complicating downstream argument parsing and future jsonargparse
integration.

This commit introduces `args.pattern_roots` as a dedicated list
for these accumulated root paths:
- All argparse definition sites now initialize `pattern_roots=[]` alongside `paths=[]`
- ArgparsePatternAction and ArgparsePatternFileAction write directly to `args.pattern_roots`
- The build_matcher utility accepts both `include_paths` and `pattern_roots` and concatenates them internally
- `create_cmd` iterations explicitly concatenate both lists before processing

This ensures `args.paths` strictly reflects exactly what the
user provided positionally, paving the way for a clean
jsonargparse implementation without regressions in pattern behavior.
2026-03-10 18:36:02 +01:00
Thomas Waldmann
4f1736d880
streamline function names for borg key subcommands 2026-03-10 18:36:01 +01:00
Thomas Waldmann
ef0eca0469
make validators idempotent 2026-03-10 18:35:59 +01:00
Suryansh Pal
ba6706395a
use xxhash from PyPI, fixes #6535
Some checks failed
Lint / lint (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / security (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
CI / asan_ubsan (push) Has been cancelled
CI / native_tests (push) Has been cancelled
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Has been cancelled
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Has been cancelled
CI / vm_tests (OmniOS, false, omnios, r151056) (push) Has been cancelled
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Has been cancelled
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Has been cancelled
CI / windows_tests (push) Has been cancelled
2026-03-08 13:06:01 +01:00
Thomas Waldmann
93cd407ff5
speed up prune/list/repo-list tests, see #9324
there are a lot of files in src_dir (due to the __pycache__ subdir).
for tests that do not need that, we can use a much smaller set of files,
now provided by the backup_files fixture.
2026-03-07 22:20:08 +01:00
Thomas Waldmann
6950a10ccd
tests: add test for cockpit feature 2026-03-07 20:08:41 +01:00
Thomas Waldmann
14c215396f
recreate_cmd_test: relax timestamp matching 2026-03-05 23:28:31 +01:00
TW
404c06d7bc
Merge pull request #9436 from ThomasWaldmann/three-timestamps
Some checks failed
CI / lint (push) Waiting to run
CI / security (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OmniOS, false, omnios, r151056) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CI / windows_tests (push) Blocked by required conditions
Lint / lint (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
archive: use 3 timestamps, fixes #9400
2026-03-04 17:45:08 +01:00
TW
1c05ab32db
Merge pull request #9430 from ThomasWaldmann/y2038
Y2038+
2026-03-04 14:16:49 +01:00
Thomas Waldmann
9b633cdb68
archive: use 3 timestamps, fixes #9400
time: the nominal ts, used for prune, list, sorting, ...
start: operation start time (informative)
end: operation end time (informative)

Often, "time" is the same as "start" (normal borg create).

But it can make sense to have a different "time":
- borg create --timestamp=...
- borg recreate --timestamp=...
- borg recreate (will keep "time" as in original archive)
- borg transfer (will keep "time" as in original archive)

recreate and transfer produce new archives, "start" and "end"
will reflect the recreate/transfer operation.

Also: remove start_monotonic. start and end are just what the
clock shows (including tz), so should be ok to compute duration
from that, even for dst switching times.
2026-03-04 13:55:58 +01:00