borgbackup/docs/usage/check.rst.inc

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

192 lines
17 KiB
PHP
Raw Normal View History

2016-07-05 17:30:08 -04:00
.. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!
.. _borg_check:
borg check
----------
.. code-block:: none
2022-06-23 19:19:19 -04:00
borg [common options] check [options]
2017-06-20 09:22:24 -04:00
.. only:: html
.. class:: borg-options-table
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-04-21 15:07:46 -04:00
| **options** |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
| | ``--repository-only`` | only perform repository checks |
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--archives-only`` | only perform archive checks |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
| | ``--verify-data`` | perform cryptographic archive data integrity verification (conflicts with ``--repository-only``) |
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
| | ``--repair`` | attempt to repair any inconsistencies found |
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2024-11-16 14:14:16 -05:00
| | ``--find-lost-archives`` | attempt to find lost archives |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--max-duration SECONDS`` | perform only a partial repository check for at most SECONDS seconds (default: unlimited) |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
| .. class:: borg-common-opt-ref |
| |
| :ref:`common_options` |
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
| **Archive filters** Archive filters can be applied to repository targets. |
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``-a PATTERN``, ``--match-archives PATTERN`` | only consider archives matching all patterns. See "borg help match-archives". |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
| | ``--sort-by KEYS`` | Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id, tags, host, user; default is: timestamp |
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--first N`` | consider the first N archives after other filters are applied |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--last N`` | consider the last N archives after other filters are applied |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--oldest TIMESPAN`` | consider archives between the oldest archive's timestamp and (oldest + TIMESPAN), e.g., 7d or 12m. |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--newest TIMESPAN`` | consider archives between the newest archive's timestamp and (newest - TIMESPAN), e.g., 7d or 12m. |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--older TIMESPAN`` | consider archives older than (now - TIMESPAN), e.g., 7d or 12m. |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2025-12-23 12:00:09 -05:00
| | ``--newer TIMESPAN`` | consider archives newer than (now - TIMESPAN), e.g., 7d or 12m. |
2024-10-03 06:23:03 -04:00
+-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
2017-06-20 09:22:24 -04:00
.. raw:: html
<script type='text/javascript'>
$(document).ready(function () {
2017-06-20 09:22:24 -04:00
$('.borg-options-table colgroup').remove();
})
</script>
.. only:: latex
2025-04-21 15:07:46 -04:00
options
2017-06-20 09:22:24 -04:00
--repository-only only perform repository checks
2025-12-23 12:00:09 -05:00
--archives-only only perform archive checks
2017-06-20 09:22:24 -04:00
--verify-data perform cryptographic archive data integrity verification (conflicts with ``--repository-only``)
--repair attempt to repair any inconsistencies found
2024-11-16 14:14:16 -05:00
--find-lost-archives attempt to find lost archives
2025-12-23 12:00:09 -05:00
--max-duration SECONDS perform only a partial repository check for at most SECONDS seconds (default: unlimited)
2017-06-20 09:22:24 -04:00
:ref:`common_options`
|
2017-07-23 11:12:01 -04:00
Archive filters
2025-12-23 12:00:09 -05:00
-a PATTERN, --match-archives PATTERN only consider archives matching all patterns. See "borg help match-archives".
2024-10-03 06:23:03 -04:00
--sort-by KEYS Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id, tags, host, user; default is: timestamp
2025-12-23 12:00:09 -05:00
--first N consider the first N archives after other filters are applied
--last N consider the last N archives after other filters are applied
--oldest TIMESPAN consider archives between the oldest archive's timestamp and (oldest + TIMESPAN), e.g., 7d or 12m.
--newest TIMESPAN consider archives between the newest archive's timestamp and (newest - TIMESPAN), e.g., 7d or 12m.
--older TIMESPAN consider archives older than (now - TIMESPAN), e.g., 7d or 12m.
--newer TIMESPAN consider archives newer than (now - TIMESPAN), e.g., 7d or 12m.
2017-06-20 05:49:26 -04:00
Description
~~~~~~~~~~~
2023-09-14 09:52:08 -04:00
The check command verifies the consistency of a repository and its archives.
It consists of two major steps:
1. Checking the consistency of the repository itself. This includes checking
2024-09-07 16:31:48 -04:00
the file magic headers, and both the metadata and data of all objects in
the repository. The read data is checked by size and hash. Bit rot and other
2023-09-14 09:52:08 -04:00
types of accidental damage can be detected this way. Running the repository
check can be split into multiple partial checks using ``--max-duration``.
2025-12-23 12:00:09 -05:00
When checking an ssh:// remote repository, please note that the checks run on
2024-10-31 15:50:06 -04:00
the server and do not cause significant network traffic.
2023-09-14 09:52:08 -04:00
2. Checking consistency and correctness of the archive metadata and optionally
archive data (requires ``--verify-data``). This includes ensuring that the
repository manifest exists, the archive metadata chunk is present, and that
all chunks referencing files (items) in the archive exist. This requires
2024-11-16 14:14:16 -05:00
reading archive and file metadata, but not data. To scan for archives whose
entries were lost from the archive directory, pass ``--find-lost-archives``.
2025-12-23 12:00:09 -05:00
It requires reading all data and is hence very time-consuming.
2024-11-16 14:14:16 -05:00
To additionally cryptographically verify the file (content) data integrity,
2025-12-23 12:00:09 -05:00
pass ``--verify-data``, which is even more time-consuming.
2024-11-16 14:14:16 -05:00
When checking archives of a remote repository, archive checks run on the client
machine because they require decrypting data and therefore the encryption key.
2023-09-14 09:52:08 -04:00
Both steps can also be run independently. Pass ``--repository-only`` to run the
repository checks only, or pass ``--archives-only`` to run the archive checks
only.
The ``--max-duration`` option can be used to split a long-running repository
2025-12-23 12:00:09 -05:00
check into multiple partial checks. After the given number of seconds, the check
2023-09-14 09:52:08 -04:00
is interrupted. The next partial check will continue where the previous one
stopped, until the full repository has been checked. Assuming a complete check
would take 7 hours, then running a daily check with ``--max-duration=3600``
(1 hour) would result in one full repository check per week. Doing a full
repository check aborts any previous partial check; the next partial check will
restart from the beginning. With partial repository checks you can run neither
archive checks, nor enable repair mode. Consequently, if you want to use
``--max-duration`` you must also pass ``--repository-only``, and must not pass
``--archives-only``, nor ``--repair``.
2025-12-23 12:00:09 -05:00
**Warning:** Please note that partial repository checks (i.e., running with
2023-09-14 09:52:08 -04:00
``--max-duration``) can only perform non-cryptographic checksum checks on the
2025-12-23 12:00:09 -05:00
repository files. Enabling partial repository checks excludes archive checks
for the same reason. Therefore, partial checks may be useful only with very large
repositories where a full check would take too long.
2023-09-14 09:52:08 -04:00
2026-06-16 08:17:43 -04:00
The ``--verify-data`` option will perform a full integrity verification of data,
which means reading the data from the repository, decrypting and decompressing it.
It is a complete cryptographic verification and hence very time-consuming, but
will detect any accidental and malicious corruption. Tamper-resistance is only
guaranteed for encrypted repositories against attackers without access to the keys.
You cannot use ``--verify-data`` with ``--repository-only``.
2023-09-14 09:52:08 -04:00
2024-11-16 14:14:16 -05:00
The ``--find-lost-archives`` option will also scan the whole repository, but
tells Borg to search for lost archive metadata. If Borg encounters any archive
2025-12-23 12:00:09 -05:00
metadata that does not match an archive directory entry (including
2024-11-16 14:14:16 -05:00
soft-deleted archives), it means that an entry was lost.
Unless ``borg compact`` is called, these archives can be fully restored with
``--repair``. Please note that ``--find-lost-archives`` must read a lot of
2025-12-23 12:00:09 -05:00
data from the repository and is thus very time-consuming. You cannot use
2024-11-16 14:14:16 -05:00
``--find-lost-archives`` with ``--repository-only``.
2023-09-14 09:52:08 -04:00
About repair mode
+++++++++++++++++
2025-12-23 12:00:09 -05:00
The check command is a read-only task by default. If any corruption is found,
2023-09-14 09:52:08 -04:00
Borg will report the issue and proceed with checking. To actually repair the
issues found, pass ``--repair``.
.. note::
``--repair`` is a **POTENTIALLY DANGEROUS FEATURE** and might lead to data
loss! This does not just include data that was previously lost anyway, but
might include more data for kinds of corruption it is not capable of
dealing with. **BE VERY CAREFUL!**
2020-10-04 14:32:38 -04:00
Pursuant to the previous warning it is also highly recommended to test the
2023-09-14 09:52:08 -04:00
reliability of the hardware running Borg with stress testing software. This
especially includes storage and memory testers. Unreliable hardware might lead
to additional data loss.
It is highly recommended to create a backup of your repository before running
in repair mode (i.e. running it with ``--repair``).
Repair mode will attempt to fix any corruptions found. Fixing corruptions does
2025-12-23 12:00:09 -05:00
not mean recovering lost data: Borg cannot magically restore data lost due to
2023-09-14 09:52:08 -04:00
e.g. a hardware failure. Repairing a repository means sacrificing some data
for the sake of the repository as a whole and the remaining data. Hence it is,
by definition, a potentially lossy task.
In practice, repair mode hooks into both the repository and archive checks:
2024-09-07 16:31:48 -04:00
1. When checking the repository's consistency, repair mode removes corrupted
objects from the repository after it did a 2nd try to read them correctly.
2023-09-14 09:52:08 -04:00
2. When checking the consistency and correctness of archives, repair mode might
remove whole archives from the manifest if their archive metadata chunk is
2025-04-21 15:07:46 -04:00
corrupt or lost. Borg will also report files that reference missing chunks.
2024-09-07 16:31:48 -04:00
2024-11-16 14:14:16 -05:00
If ``--repair --find-lost-archives`` is given, previously lost entries will
be recreated in the archive directory. This is only possible before
2024-09-07 16:31:48 -04:00
``borg compact`` would remove the archives' data completely.