Commit graph

325 commits

Author SHA1 Message Date
Thomas Waldmann
d2bc45f56d
key: unify keyfile/repokey classes, locate key independent of type byte (#9743)
Borg used to read the manifest's key-type byte and then look for the key in
exactly one place (keyfile or repokey) depending on the key class that byte
selected. As a result every crypto suite was duplicated into a keyfile class
and a repokey class that differed only in TYPE, NAME, ARG_NAME and STORAGE.

Now key *location* is independent of the type byte: detection tries keyfiles
first and repokeys afterwards until a passphrase unlocks a key. The type byte
still selects the crypto suite (id hash, MAC, cipher) to instantiate. Where a
key is stored (keyfile vs repokey) is therefore a per-key property
(self.storage), not a separate class, so a repository may even hold a mix of
keyfile- and repo-stored borg keys.

With storage decoupled from class identity, the keyfile/repokey class pairs
collapse into one class per crypto suite:
- modern AEAD: AESOCBKey, CHPOKey, Blake3AESOCBKey, Blake3CHPOKey
- legacy borg 1.x (read-only): AESCTRKey, Blake2AESCTRKey
There is now exactly one type byte per modern crypto suite (the old separate
repokey type bytes 0x11/0x21/0x31/0x41 were removed; borg2 is beta and only
needs to read repos it created). identify_key() matches on TYPES_ACCEPTABLE.

CLI: --encryption selects only the crypto suite (aes-ocb, chacha20-poly1305,
blake3-aes-ocb, blake3-chacha20-poly1305, authenticated*, none); the storage
location is chosen with the new --key-location=repokey|keyfile (default
repokey). The old combined modes (repokey-aes-ocb etc.) were removed.
borg key import also gained --key-location. borg key change-location no longer
swaps key classes or rewrites the manifest; it just re-saves the unlocked key
at the new location.

Keyfile removal (key remove, change-location) now overwrites the keyfile with
random data via secure_erase() before unlinking, consistent with save().

borg 1.x legacy read compatibility is preserved (the legacy class merge is a
behavior-preserving rename; the legacy type bytes incl. PASSPHRASE stay in
TYPES_ACCEPTABLE).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 23:48:45 +02:00
TW
c710edf0df
Merge pull request #9754 from ThomasWaldmann/simplify-location-parsing
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 (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.8) (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
Simplify location parsing, remove socket: remainders
2026-06-11 10:48:23 +02:00
Thomas Waldmann
5eab183183
remove leftover socket: protocol code
The unix-socket transport (socket:// repositories, the --socket option and
"borg serve" over a socket) was never part of a stable borg 2 release and the
old RPC protocol it relied on is gone, so the remaining code was dead:

- legacy remote: drop the unreachable proto == "socket" connection branch and
  the now-unused self.sock handling, "import socket" and get_socket_filename
  import (LegacyRemoteRepository is only built for proto == "ssh")
- helpers: remove get_socket_filename() and its export
- parseformat: drop "socket" from local_path_re - socket:// is now treated like
  any other unknown scheme (a local path) rather than being special-cased
- tests: drop test_socket and the self.sock check in the legacy reopen helper
- docs: drop the stale --socket entry from the manually maintained
  common-options.rst.inc (the auto-generated usage/man docs are left untouched
  here and will be rebuilt in a separate commit)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 18:51:55 +02:00
Thomas Waldmann
aa9f810453
parseformat: simplify Location parsing/validation, #9678
For sftp/http(s)/s3/b2/rclone repositories, borg only detects the scheme now
and hands the raw URL to borgstore, which parses and validates it - removing
the duplicate parsing borg used to do. Precise field extraction (user/host/
port/path) is kept only for the protocols borg itself reads: file, rest and
legacy ssh.

- drop http_re, s3_re, rclone_re and the sftp arm of the old ssh_or_sftp_re
- add a single scheme-detection pass-through against BORGSTORE_SCHEMES; reject
  unknown schemes (e.g. socket://) as before
- canonical_path() returns the processed URL for the delegated protocols, with
  embedded credentials stripped so secrets never reach the security state file
  or logs
- source local_path_re's scheme exclusions from BORGSTORE_SCHEMES
- create: use proto == "file" instead of "not location.host" for the local
  repo-dir inode skip

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 18:17:40 +02:00
Thomas Waldmann
0b103291b8
compact: invalidate cached chunk indexes before deleting objects, #9748
If `borg compact` was interrupted after deleting repository objects but
before writing the updated chunk index, the still-existing cache/chunks.*
kept claiming the deleted objects were present. A later `borg create` would
trust that stale index, skip re-uploading the affected chunks and silently
create an archive with dangling object references that extracts to zero bytes.

Invalidate all cached chunk indexes via delete_chunkindex_cache() before the
first object is deleted, so an interruption is conservative: the next client
rebuilds the index from actual repository contents and re-uploads any deleted
data. The post-deletion save_chunk_index() still writes a fresh, valid index.

Add a regression test covering both compact paths (default and --stats) that
interrupts compaction right before save_chunk_index() and verifies no cached
chunk index survives and a later create+extract reproduces the original bytes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 15:45:57 +02:00
Thomas Waldmann
c08c2ca461
files cache: don't empty cache on a no-change backup, #9749
FilesCacheMixin initialized _newest_cmtime to 0, but _write_files_cache()
only treats None as "no file was chunked this run" (falling back to a
max_time_ns cutoff that keeps all current entries).

When a backup reuses all files from the cache without chunking anything,
_newest_cmtime stayed at 0, so the race-protection cutoff became the unix
epoch and every current (age == 0) entry was discarded. The next backup
then had to re-read, chunk and hash all files again.

Initialize _newest_cmtime to None to match the documented contract in
_write_files_cache(), and make the comparisons in _build_files_cache()
None-safe.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 12:39:36 +02:00
Thomas Waldmann
83b0dd66c7
improve docs / comments 2026-06-09 00:49:50 +02:00
Thomas Waldmann
5415062564 borg serve --rest: serve rest:// repositories with borg
Make `borg serve` able to be the server-side component of a rest:// repository,
selected with a new --rest option. Plain `borg serve` (no option) keeps serving
legacy borg-1.x repos and stays command-line compatible with borg 1.x.

- serve_cmd.py: add --rest and --backend. With --rest, serve the given
  --backend FILE:<path> on stdio via borgstore.server.rest.serve(); honor
  --restrict-to-path/--restrict-to-repository (validated against the FILE path)
  and --permissions (mapped via borg_permissions). Without --rest, run the legacy
  RepositoryServer as before.
- repository.py: for rest:// locations, build the borgstore REST backend with a
  command that runs `borg serve --rest --backend FILE:<path>` (locally via
  sys.executable, or over ssh reusing borgstore's ssh_cmd / BORG_REMOTE_PATH),
  instead of borgstore's hardcoded `borgstore-server-rest`. So a remote only needs
  borg installed. Extracted the permissions string->dict mapping into the reusable
  borg_permissions().
- tests: unit tests for the rest serve command builder. The existing
  remote_archiver (rest:///) suite now runs against `borg serve --rest`.
- docs: changelog + quickstart updated.

Legacy serve and the legacy ssh client are unchanged (client still spawns plain
`borg serve`).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 14:52:41 +02:00
Thomas Waldmann
cac7237d3f remove ssh:// and socket:// remote repository for current repos
The modern client/server transport (RemoteRepository served by `borg serve`
over an msgpack RPC protocol) is now redundant for current (borg 2) repos:
its functionality is replaced by rest:// (which can tunnel over ssh to a
remote borgstore REST server).

Remove the modern RemoteRepository (both ssh:// and socket://) entirely.
Legacy v1 (borg 1.x) repos remain reachable over ssh:// via the separate
LegacyRemoteRepository client, and `borg serve` / RepositoryServer is kept,
trimmed to the legacy-only path, so a remote borg2 can still serve a v1 repo
for `borg transfer --from-borg1`.

Details:
- remote.py: delete RemoteRepository, SleepingBandwidthLimiter and the `api`
  decorator; trim RepositoryServer to legacy-only (drop modern _rpc_methods,
  socket serving, non-legacy open() branch); keep cache_if_remote /
  RepositoryCache / RepositoryNoCache (used by all repos).
- get_repository(): non-legacy ssh:// now raises a clear "use rest://" error;
  socket:// route and the global --socket option removed.
- parseformat: drop the socket:// scheme (now an invalid location).
- borg serve: keep the command (serves legacy v1 ssh only); update epilog.
- borg version: drop modern remote query; keep legacy ssh path.
- update isinstance/import sites (cache, archive, fuse/hlfuse, analyze/compact,
  archiver __init__ -> LegacyRemoteRepository.RPCError).
- tests/docs updated; obsolete socket serve test removed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 08:04:59 +02:00
Thomas Waldmann
d6eb910c21
update CHANGES 2026-06-02 11:34:42 +02:00
Hugo Wallenburg
c8f8defc0f
Fixes tests/docs assuming XDG_* vars not used on macOS
The move to platformdirs and its current usage _does_ honor XDG_*
variables on macOS if they are set. Tests were set up to assume this to
be untrue and the docs matched that.

This commit adds tests asserting that XDG_* variables are used when they
are present on macOS, with default locations still in ~/Library.
2026-04-03 11:34:10 +02:00
Thomas Waldmann
2d6d900231
update CHANGES 2026-03-15 17:03:12 +01:00
Thomas Waldmann
d0c5a04a2a
update CHANGES 2026-03-13 15:29:33 +01:00
Thomas Waldmann
cb6a7b6fcf
update CHANGES 2026-03-03 14:03:54 +01:00
Mrityunjay Raj
02f447536c docs: document platformdirs change and platform-specific directory paths, fixes #7332 2026-02-27 11:50:35 +05:30
Mrityunjay Raj
1c0bf36275
remove handwritten bash/zsh shell completions, fixes #9178
Remove the handwritten bash and zsh shell completion scripts now that
auto-generated completions via borg completion bash/zsh (powered by
shtab, #9172) are tested and working. Fish completions are kept as
shtab does not yet support fish.

Replace string-matching tests with focused behavior tests: script size
sanity, shell syntax validation (bash -n / zsh -n), and tests that
invoke the custom preamble functions in bash (sortby key dedup,
filescachemode mutual exclusivity, archive name and aid: prefix
completion against a real repository).
2026-02-17 19:33:54 +01:00
Mrityunjay Raj
f1ed09965f docs: fix broken :ref: references in man pages, fixes #7239 2026-02-16 22:36:07 +05:30
Thomas Waldmann
d75604b293
update CHANGES 2026-01-28 15:05:25 +01:00
Thomas Waldmann
461f78b2b0
update release date 2025-12-23 18:01:59 +01:00
Thomas Waldmann
f4a2ff13d2
update CHANGES 2025-12-23 16:47:31 +01:00
Thomas Waldmann
28de075535
update CHANGES 2025-12-16 13:51:27 +01:00
Thomas Waldmann
4eb19d9e14
update CHANGES 2025-11-19 17:42:11 +01:00
Thomas Waldmann
7548f523e6
update CHANGES 2025-11-17 20:28:50 +01:00
Thomas Waldmann
352cf7bdcc
update CHANGES 2025-11-03 17:33:19 +01:00
Thomas Waldmann
7e6dea9408
BORG_MSGPACK_VERSION_CHECK=no to disable the version check, fixes #9109
(cherry picked from commit 2d63dc9a4f)
2025-11-01 16:48:00 +01:00
Thomas Waldmann
73e2543b53
update CHANGES 2025-10-16 13:34:27 +02:00
Thomas Waldmann
3120f9cd1c
fixed typos and grammar (AI)
this was done by Junie AI.
2025-09-23 14:56:23 +02:00
Thomas Waldmann
4905fd8bea
update CHANGES 2025-08-02 11:21:28 +02:00
Thomas Waldmann
1f75c40d34
update CHANGES 2025-08-01 20:19:04 +02:00
Thomas Waldmann
840c0c4788
update CHANGES 2025-06-18 17:31:57 +02:00
Thomas Waldmann
1e40d74f88
update CHANGES 2025-06-14 17:20:53 +02:00
Thomas Waldmann
b116971217
update CHANGES 2025-06-10 01:09:25 +02:00
Thomas Waldmann
5ca22e9c10
update CHANGES 2025-06-03 20:26:10 +02:00
Thomas Waldmann
456e319bb6
docs: fix mistyped CVE number 2025-05-23 09:26:26 +02:00
Thomas Waldmann
6b87fec1f7
update CHANGES 2025-05-22 14:22:10 +02:00
Thomas Waldmann
5b24e774b7
update CHANGES 2025-05-22 12:46:05 +02:00
Thomas Waldmann
6e0a11cb96
update CHANGES 2025-05-18 09:57:29 +02:00
Thomas Waldmann
3bca22a0a3
update CHANGES 2025-05-06 01:35:29 +02:00
Thomas Waldmann
18dbfd3985
update CHANGES 2025-04-21 21:08:45 +02:00
Thomas Waldmann
a69fd81098
update CHANGES 2025-04-21 18:36:23 +02:00
Thomas Waldmann
992b5f18c8
update CHANGES 2025-04-06 18:25:11 +02:00
Thomas Waldmann
863a1efdc0
update CHANGES 2025-03-23 14:48:01 +01:00
Thomas Waldmann
7b0eed99ae
update CHANGES 2025-02-16 19:31:32 +01:00
Thomas Waldmann
e8a6421ebf
b14 release date 2024-11-16 20:08:19 +01:00
Thomas Waldmann
5f605d6642
upgrade notes about files cache settings when NOT using archive series 2024-11-16 18:47:16 +01:00
Thomas Waldmann
b007b99394
update CHANGES 2024-11-16 15:20:51 +01:00
Daniel Rudolf
38ba3d8c4d Update docs to better incorporate new undelete command
Follow-up to #8515

Refer to https://github.com/borgbackup/borg/pull/8515#pullrequestreview-2417746853 for details.
2024-11-08 01:50:45 +01:00
Thomas Waldmann
63c74ca313
update CHANGES 2024-10-31 20:45:33 +01:00
Thomas Waldmann
b6eb5b239f
update CHANGES 2024-10-19 03:49:28 +02:00
Thomas Waldmann
cb691417ac
update CHANGES 2024-10-03 12:30:56 +02:00