borg/docs/usage/repo-compress.rst.inc
Thomas Waldmann 637972f363
re-add repo-compress, fixes #9663
reimplemented for the pack-based repository format: the repository is
processed pack after pack - each pack is read as a whole and, if it has
objects not stored with the desired compression, those get recompressed
and the pack is rewritten (objects already fine are copied into the new
pack unchanged), the chunk index is updated and the old pack is deleted.
a pack whose objects all already match is not touched at all.

- new Repository.transform_pack: rewrite one pack, passing each indexed
  object's bytes through a transform callback. gap bytes are handled
  like in compact_pack: superseded duplicates are dropped, other
  unindexed bytes are carried forward for "borg check --repair".
- factored the check_pack_objects / superseded_gap_ranges helpers out
  of compact_pack, now shared with merge_packs and transform_pack.
- crash safety like compact (#9748): stored chunk indexes are
  invalidated before the first store change, a full updated index is
  written back at the end. SIGINT stops cleanly at a pack boundary,
  saving a valid index; a later run recompresses the remaining packs.
- --stats reports rewritten packs, per-object outcomes (recompressed /
  already had the desired compression / kept as-is because
  recompression brings no gain) and the repository size change.
- re-adding the fish completions also restores the compression_methods
  definition that the create/transfer/recreate/import-tar completions
  kept referencing after it was removed together with the old
  repo-compress.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-02 10:12:06 +02:00

76 lines
No EOL
4.4 KiB
PHP

.. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
.. _borg_repo-compress:
borg repo-compress
------------------
.. code-block:: none
borg [common options] repo-compress [options]
.. only:: html
.. class:: borg-options-table
+-------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------------------------------+
| **options** |
+-------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------------------------------+
| | ``-C COMPRESSION``, ``--compression COMPRESSION`` | select compression algorithm, see the output of the "borg help compression" command for details. |
+-------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------------------------------+
| | ``-s``, ``--stats`` | print statistics |
+-------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------------------------------+
| .. class:: borg-common-opt-ref |
| |
| :ref:`common_options` |
+-------------------------------------------------------+---------------------------------------------------+--------------------------------------------------------------------------------------------------+
.. raw:: html
<script type='text/javascript'>
$(document).ready(function () {
$('.borg-options-table colgroup').remove();
})
</script>
.. only:: latex
options
-C COMPRESSION, --compression COMPRESSION select compression algorithm, see the output of the "borg help compression" command for details.
-s, --stats print statistics
:ref:`common_options`
|
Description
~~~~~~~~~~~
Repository (re-)compression (and/or re-obfuscation).
Reads all repository objects and recompresses the ones that are not already using
the compression type/level and obfuscation level given via ``--compression``.
The repository is processed one pack file at a time: a pack is read as a whole and,
if it holds objects that need recompression, rewritten as a whole - objects already
using the desired compression are copied into the rewritten pack unchanged. A pack
whose objects all already use the desired compression is not touched at all.
Please note that the outcome of recompressing a chunk might not always be the
desired compression type/level - if no compression gives a shorter output, that
might be chosen; such chunks are kept as they are.
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.
This command needs free space in the repository for the rewritten pack files
(roughly one pack file size while running).
If the ``borg repo-compress`` process receives a SIGINT signal (Ctrl-C), it stops
at the next pack boundary, leaving the repository and its chunk index in a
consistent state; running it again later processes the remaining packs.
Both ``--progress`` and ``--stats`` are recommended when ``borg repo-compress``
is used interactively.
You do **not** need to run ``borg compact`` after ``borg repo-compress``.