Commit graph

9496 commits

Author SHA1 Message Date
Thomas Waldmann
2af8de5800
borg --cockpit: show TUI based on Textual 2025-12-15 16:10:21 +01:00
TW
2152e1e3a9
Merge pull request #9209 from ThomasWaldmann/fix-9208
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 (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
Fix misc. borg transfer issues
2025-12-08 01:33:38 +01:00
Thomas Waldmann
b43c3adabb
transfer: create a chunks list entry for missing chunks, see #9208 2025-12-06 17:21:41 +01:00
Thomas Waldmann
3bda2f10d9
HardLinkManager: allow NoneType for contentless hardlinks, see #9208
Some hardlinks have content and thus a chunks list,
but e.g. block or char device hardlinks do not have a chunks list.
2025-12-06 17:21:38 +01:00
Thomas Waldmann
352f982393
old archives might not have a comment in metadata, see #9208
guess the default is only needed when transferring
very old archives from borg1 repos.
2025-12-06 16:04:46 +01:00
TW
425fa1c77a
fix pynacl/libsodium build on freebsd (#9214)
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 (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
2025-12-06 15:30:26 +01:00
TW
70f6c0122a
Merge pull request #9212 from ThomasWaldmann/filter-xattrs-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 (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
no_selinux -> filter_xattrs
2025-12-05 19:18:47 +01:00
Thomas Waldmann
fefb27e732
no_selinux -> filter_xattrs
Originally, we only wanted to get rid of selinux xattrs,
but macOS also uses some xattr keys that disturb our test results,
so we filter them also.
2025-12-05 18:37:11 +01:00
TW
231bf26552
Merge pull request #9200 from ThomasWaldmann/fix-9199-legacyremote-raise-missing
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 (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
transfer and legacyremote fixes
2025-12-04 01:59:31 +01:00
Thomas Waldmann
7d4c05d2a3
transfer: fix AttributeError with --dry-run, see #9199 2025-12-02 03:00:32 +01:00
Thomas Waldmann
017dfec4ff
transfer: add --dry-run test 2025-12-02 03:00:30 +01:00
Thomas Waldmann
11ad58d3ca
legacyremote: accept raise_missing in get/get_many to avoid TypeError with callers that pass it; no behavior change on legacy protocol (fixes #9199) 2025-12-02 02:33:01 +01:00
TW
a38d87b21f
Merge pull request #9205 from ThomasWaldmann/fix-compact-master
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 (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
compact: fix dealing with mismatching hints (master)
2025-12-02 02:31:14 +01:00
Thomas Waldmann
d676ef7b3f
compact: also fix segments hints data for lost segment files
The code used to remove the missing segment only from "compact" hints,
but we need to also remove it from "segments" hints.
2025-12-02 01:37:35 +01:00
Thomas Waldmann
b1bb3830fb
compact_segments: replace AssertionError by warning, fixes #8535
emit only a warning, but let compaction complete.
after that, borg check --repair can fix the hints successfully.

likely this code won't be used in master branch as we only read from
legacy repos, but I ported this fix from 1.4-maint nevertheless.

This is the result of a longer discussion with Antigravity AI and me:

Detailed Explanation: Why Converting AssertionError to Warning is Correct
=========================================================================

PROBLEM OVERVIEW
----------------
The assertion `assert segments[segment] == 0` in compact_segments() was causing
borg compact to crash when segment reference counts in the hints file didn't
match the actual repository state. This typically occurred after index corruption
or repository recovery scenarios.

ROOT CAUSE ANALYSIS
-------------------
The crash happens due to a fundamental mismatch between two data structures:

1. self.segments (loaded from hints file)
   - Contains reference counts for each segment
   - Persisted to disk in the hints file
   - Represents the "last known state"

2. self.index (loaded from index file)
   - Contains mappings of object IDs to (segment, offset) pairs
   - Can be corrupted or lost
   - When corrupted, triggers auto-recovery

The Problem Scenario:
1. Repository has valid data with consistent hints.N and index.N
2. Index file gets corrupted (crash, disk error, etc.)
3. Borg detects corruption and auto-recovers:
   - Loads hints.N (with old reference counts)
   - Rebuilds index by replaying segments
   - Commits the rebuilt index
4. State is now inconsistent IF segments were deleted/lost:
   - self.segments[X] = 10 (from old hints, assumes segment X exists)
   - Segment X was actually deleted/lost
   - self.index has 0 entries for segment X (rebuilt from remaining segments)
5. During compact_segments():
   - Tries to iterate objects in segment X
   - Segment X doesn't exist (was deleted/lost)
   - OR: segment X exists but objects aren't in index (superseded)
   - segments[X] is never decremented
   - segments[X] remains 10 instead of becoming 0
   - Assertion fails!

WHY THE FIX IS CORRECT
----------------------

1. Hints are Advisory, Not Authoritative
   The hints file is an optimization to avoid scanning all segments. It's
   explicitly designed to be rebuildable from scratch by scanning segments.
   Therefore, incorrect hints should not cause a fatal error.

2. Self-Healing Behavior
   By converting the assertion to a warning and allowing compaction to proceed:
   - Compaction completes successfully
   - New hints are written with correct reference counts
   - Repository is automatically healed
   - No manual intervention required

3. Data Safety is Preserved
   The fix does NOT compromise data integrity because:
   - Compaction first copies all live data from segments to new segments
   - Only after all live data is safely copied are segments marked for deletion
   - The index determines what's "live" (authoritative source of truth)
   - Segments are deleted only when they contain no live data (per index)
   - The refcount warning indicates stale hints, not actual data loss risk
   - After compaction, new hints are written with correct counts

4. Consistent with Design Philosophy
   Borg already handles many corruption scenarios gracefully:
   - Missing hints → regenerated from segments
   - Corrupted index → rebuilt from segments
   - Missing segments → detected and handled
   This fix extends that philosophy to hint/index mismatches.

5. Alternative Solutions are Worse
   Other approaches considered:
   a) Crash and require manual intervention
      - Current behavior, user-hostile
      - Requires expert knowledge to fix
   b) Automatically run check --repair
      - Too aggressive, may hide real problems
      - User should decide when to repair
   c) Refuse to compact
      - Leaves repository in degraded state
      - Prevents normal operations

VERIFICATION
------------
The fix has been verified with test cases that reproduce both scenarios:

1. test_missing_segment_in_hints
   - Simulates missing segment files
   - Verifies compact succeeds and updates hints correctly

2. test_index_corruption_with_old_hints
   - Simulates the root cause: corrupted index with old hints
   - Verifies compact succeeds despite reference count mismatch

3. test_subtly_corrupted_hints_without_integrity
   - Existing test updated to expect warning instead of crash
   - Verifies repository remains consistent after compaction

OPERATIONAL IMPACT
------------------
After this fix:
1. Users experiencing this crash can now run `borg compact` successfully
2. The warning message alerts them to the inconsistency
3. They can optionally run `borg check --repair` for peace of mind
4. Repository continues to function normally

The warning message provides enough information for debugging while not
blocking normal operations.

CONCLUSION
----------
Converting the assertion to a warning is the correct fix because:
- It aligns with Borg's design philosophy of graceful degradation
- It enables self-healing behavior
- It preserves data safety
- It improves user experience
- It's consistent with how other corruption scenarios are handled

The assertion was overly strict for a data structure (hints) that is
explicitly designed to be advisory and rebuildable.
2025-12-02 01:35:38 +01:00
TW
f6ac5c4715
Merge pull request #9188 from ThomasWaldmann/update-faq-master
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 (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
docs: some fixes/update to the FAQ
2025-11-21 17:29:06 +01:00
Thomas Waldmann
3642c7903b
docs: some fixes/update to the FAQ 2025-11-21 17:16:35 +01:00
TW
1ede79bdec
Merge pull request #9143 from ThomasWaldmann/feature/8753-linux-acl-any-text
linux ACL: use acl_to_any_text to avoid libacl name lookups, fixes #8753
2025-11-21 17:05:19 +01:00
Thomas Waldmann
3419d93a17
how to speed up the freebsd ACL code 2025-11-21 13:42:30 +01:00
Thomas Waldmann
e385103a1b
cosmetic: move new acl helper functions closer to other acl code 2025-11-21 13:42:29 +01:00
Thomas Waldmann
964aa8998d
better names 2025-11-21 13:42:27 +01:00
Thomas Waldmann
7e7ea5b289
remove unused acl code (linux) 2025-11-21 13:42:25 +01:00
Thomas Waldmann
798bd9ed0d
refactor id <-> name lookup for monkeypatching
we can't monkeypatch stuff in Cython/C code, so we
go over python module attribute lookup.

that way, we can more easily test some functions that
internally do id<->name lookups.
2025-11-21 13:42:11 +01:00
Thomas Waldmann
6808809818
linux ACL: use acl_to_any_text to avoid libacl name lookups, fixes #8753
Use LRU caches in borg to avoid gazillions of id -> name lookups
(they can be slow, especially for network filesystems).
2025-11-21 13:38:31 +01:00
TW
753ac7088b
Merge pull request #9169 from ThomasWaldmann/netbsd-xattr-support
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 (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
netbsd: xattr support
2025-11-21 13:35:38 +01:00
Thomas Waldmann
bcf3316308
NetBSD: xattr.get_all: catch also errno.EOPNOTSUPP 2025-11-21 12:42:06 +01:00
Thomas Waldmann
0286fb6dc4
NetBSD: copy xattr implementation of FreeBSD, fixes #1332 2025-11-21 12:42:05 +01:00
Thomas Waldmann
9a0122995c
CI: netbsd: enable xattrs on TMPDIR 2025-11-21 12:41:59 +01:00
TW
2c2b0343b2
Merge pull request #9185 from ThomasWaldmann/tests-fs-cleanup-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 (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
Tests fs cleanup (master)
2025-11-21 03:17:59 +01:00
TW
ce9a4826b0
Merge pull request #9186 from ThomasWaldmann/fixes-master
misc small fixes (master)
2025-11-21 03:02:46 +01:00
Thomas Waldmann
1244e0d23a
conftest.py: clean up directly after tests 2025-11-21 02:54:08 +01:00
Thomas Waldmann
4aa63a7866
tests: add some ctx managers for better cleanup 2025-11-21 02:54:06 +01:00
TW
d6c334c4ec
Merge pull request #9184 from ThomasWaldmann/shtab2-master
more shell completion work
2025-11-21 02:52:29 +01:00
Thomas Waldmann
311a5c7e6b
fix rst syntax in changelog 2025-11-21 02:40:29 +01:00
Thomas Waldmann
211bb3225c
lrucache: remove unneeded move_to_end call, already at end 2025-11-21 02:01:46 +01:00
Thomas Waldmann
9b89f3ebd4
crypto: add low_level.pyi stub file 2025-11-21 02:01:43 +01:00
Thomas Waldmann
870f414690
buzhash/buzhash64: initialise all-zero memory more efficiently 2025-11-20 01:35:03 +01:00
Thomas Waldmann
631ef99e3f
chunkers.failing: fix docstring 2025-11-20 01:29:21 +01:00
Thomas Waldmann
bb38a63596
reader.pyi: fix types 2025-11-20 01:26:49 +01:00
Thomas Waldmann
4eb19d9e14
update CHANGES 2025-11-19 17:42:11 +01:00
Thomas Waldmann
895feaa71a
completion: blacken 2025-11-19 17:26:29 +01:00
Thomas Waldmann
5968382c9b
completion: support parse_file_size 2025-11-19 17:21:48 +01:00
Thomas Waldmann
12395967ea
completion: support timestamp 2025-11-19 17:21:47 +01:00
Thomas Waldmann
813585b428
completion: support relative_time_marker_validator 2025-11-19 17:21:46 +01:00
Thomas Waldmann
f787f4bfa5
completion: complete tags with already present ones in repo 2025-11-19 17:21:44 +01:00
Thomas Waldmann
91d0153f90
completion: module docstring 2025-11-19 17:21:43 +01:00
Thomas Waldmann
2b86db8343
completion: archive id descriptions for zsh 2025-11-19 17:21:41 +01:00
Thomas Waldmann
5b5c06b80f
completion: support archive name and id completion 2025-11-19 17:21:40 +01:00
Thomas Waldmann
271a3f2466
completion: support ChunkerParams 2025-11-19 03:07:24 +01:00
Thomas Waldmann
0a0e4e18fd
completion: support PathSpec 2025-11-19 02:59:34 +01:00