borgbackup/docs/usage/compact.rst.inc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
3.8 KiB
PHP
Raw Normal View History

2018-07-12 16:00:19 -04:00
.. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
.. _borg_compact:
borg compact
------------
.. code-block:: none
2022-06-23 19:19:19 -04:00
borg [common options] compact [options]
2018-07-12 16:00:19 -04:00
.. only:: html
.. class:: borg-options-table
2025-04-21 15:07:46 -04:00
+-------------------------------------------------------+-----------------------+-----------------------------------------+
| **options** |
+-------------------------------------------------------+-----------------------+-----------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``-n``, ``--dry-run`` | do not change the repository |
2025-04-21 15:07:46 -04:00
+-------------------------------------------------------+-----------------------+-----------------------------------------+
| | ``-s``, ``--stats`` | print statistics (might be much slower) |
+-------------------------------------------------------+-----------------------+-----------------------------------------+
| .. class:: borg-common-opt-ref |
| |
| :ref:`common_options` |
+-------------------------------------------------------+-----------------------+-----------------------------------------+
2018-07-12 16:00:19 -04:00
.. raw:: html
<script type='text/javascript'>
$(document).ready(function () {
$('.borg-options-table colgroup').remove();
})
</script>
.. only:: latex
2025-04-21 15:07:46 -04:00
options
2025-12-23 12:00:09 -05:00
-n, --dry-run do not change the repository
2025-04-21 15:07:46 -04:00
-s, --stats print statistics (might be much slower)
2018-07-12 16:00:19 -04:00
:ref:`common_options`
|
Description
~~~~~~~~~~~
2024-09-07 16:31:48 -04:00
Free repository space by deleting unused chunks.
2019-09-06 18:27:17 -04:00
2025-12-23 12:00:09 -05:00
``borg compact`` analyzes all existing archives to determine which repository
2024-11-16 14:14:16 -05:00
objects are actually used (referenced). It then deletes all unused objects
from the repository to free space.
Unused objects may result from:
2025-12-23 12:00:09 -05:00
- use of ``borg delete`` or ``borg prune``
- interrupted backups (consider retrying the backup before running compact)
- backups of source files that encountered an I/O error mid-transfer and were skipped
- corruption of the repository (e.g., the archives directory lost entries; see notes below)
2024-11-16 14:14:16 -05:00
2025-12-23 12:00:09 -05:00
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
2024-11-16 14:14:16 -05:00
when disk space needs to be freed.
**Important:**
2025-12-23 12:00:09 -05:00
After compacting, it is no longer possible to use ``borg undelete`` to recover
2024-11-16 14:14:16 -05:00
previously soft-deleted archives.
``borg compact`` might also delete data from archives that were "lost" due to
archives directory corruption. Such archives could potentially be restored with
``borg check --find-lost-archives [--repair]``, which is slow. You therefore
2025-12-23 12:00:09 -05:00
might not want to do that unless there are signs of lost archives (e.g., when
2024-11-16 14:14:16 -05:00
seeing fatal errors when creating backups or when archives are missing in
2025-04-21 15:07:46 -04:00
``borg repo-list``).
2025-12-23 12:00:09 -05:00
When using the ``--stats`` option, borg will internally list all repository
objects to determine their existence and stored size. It will build a fresh
2025-04-21 15:07:46 -04:00
chunks index from that information and cache it in the repository. For some
types of repositories, this might be very slow. It will tell you the sum of
stored object sizes, before and after compaction.
Without ``--stats``, borg will rely on the cached chunks index to determine
existing object IDs (but there is no stored size information in the index,
2025-12-23 12:00:09 -05:00
thus it cannot compute before/after compaction size statistics).