Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ The recommended order of operations is:

At the repository level, it salvages each corrupt pack: the pack is replaced by one
holding only the objects whose header, metadata and data still authenticate with
the key. It rebuilds the chunk index and removes the index entries of the chunks
the key (or deleted if none do and other objects in the repository authenticated).
It rebuilds the chunk index and removes the index entries of the chunks
stored in missing packs.

At the archive level, it might remove archives whose archive metadata chunk is
Expand Down
5 changes: 3 additions & 2 deletions docs/internals/packs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ content, so a pack damaged in the store keeps failing the store-level check that
``borg check`` runs over ``packs/`` until it is rewritten. ``borg check --repair``
rewrites it before any index rebuild: it replaces the pack by one holding only the
blobs the walk finds and whose metadata and data slots both authenticate, which
drops the damaged bytes (see ``Repository.salvage_pack``). A pack in which no blob
authenticates is left as it is.
drops the damaged bytes (see ``Repository.salvage_pack``). If no blob
authenticates, the pack is deleted provided other blobs in the repository
authenticated in the same run; otherwise it is left as it is.

``OBJ_MAGIC`` occurs inside the payloads as well, so the scan accepts a candidate
only when it validates like any walked header. Validating needs the key, which
Expand Down
6 changes: 4 additions & 2 deletions src/borg/archiver/check_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ def build_parser_check(self, subparsers, common_parser, mid_common_parser):
salvages each pack that fails its store hash (a pack is named by the hash of its
content): the pack is replaced by one holding only its objects whose header,
metadata and data authenticate with the key, the rest is dropped and the index
entries of the dropped objects are removed. A pack in which no object
authenticates is left in place and reported. If the index is corrupt, a full
entries of the dropped objects are removed. If no object in the pack authenticates,
the pack is deleted and its index entries are removed, provided other objects in the
repository authenticated in the same run; otherwise it is left in place and reported.
If the index is corrupt, a full
``borg check --repair`` then rebuilds it from the packs in the archive check
(which does so on every ``--repair`` run). With ``--repository-only``, the
repository check rebuilds it, provided no pack is left corrupt. Either rebuild
Expand Down
7 changes: 4 additions & 3 deletions src/borg/archiver/compact_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,10 @@ def build_parser_compact(self, subparsers, common_parser, mid_common_parser):

``borg compact`` does not rewrite or merge packs that ``borg check`` recorded as corrupt
and warns about them. ``borg check --repair`` salvages such a pack: it replaces it by a pack
holding only the objects that authenticate with the key, which drops the corrupt chunks and
any damage outside a chunk (e.g. bytes appended to the pack). A pack in which no object
authenticates stays recorded corrupt and ``borg compact`` warns about it on every run.
holding only the objects that authenticate with the key (or deletes it if none do and other
objects in the repository authenticated), which drops the corrupt chunks and any damage
outside a chunk (e.g. bytes appended to the pack). A pack that could not be salvaged stays
recorded corrupt and ``borg compact`` warns about it on every run.

You usually do not want to run ``borg compact`` after every write operation, but
either regularly (e.g., once a month, possibly together with ``borg check``) or
Expand Down
7 changes: 4 additions & 3 deletions src/borg/archiver/repo_compress_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ def build_parser_repo_compress(self, subparsers, common_parser, mid_common_parse

``borg repo-compress`` does not rewrite packs that ``borg check`` recorded as corrupt
and warns about them. ``borg check --repair`` salvages such a pack: it replaces it by a pack
holding only the objects that authenticate with the key, which drops the corrupt chunks and any
damage outside a chunk (e.g. bytes appended to the pack). A pack in which no object authenticates
stays recorded corrupt and is not rewritten.
holding only the objects that authenticate with the key (or deletes it if none do and other
objects in the repository authenticated), which drops the corrupt chunks and any damage
outside a chunk (e.g. bytes appended to the pack). A pack that could not be salvaged stays
recorded corrupt and is not rewritten.

Rewriting a pack invalidates every client's cached chunk index, so the next borg
operation of each client will re-fetch the chunk index from the repository.
Expand Down
Loading