| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 | .. IMPORTANT: this file is auto-generated from borg's built-in help, do not edit!.. _borg_check:borg check----------.. code-block:: none    borg [common options] check [options].. only:: html    .. class:: borg-options-table    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    | **optional arguments**                                                                                                                                                                                                                 |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--repository-only``                        | only perform repository checks                                                                            |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--archives-only``                          | only perform archives checks                                                                              |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--verify-data``                            | perform cryptographic archive data integrity verification (conflicts with ``--repository-only``)          |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--repair``                                 | attempt to repair any inconsistencies found                                                               |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--undelete-archives``                      | attempt to undelete archives (use with --repair)                                                          |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--max-duration SECONDS``                   | do only a partial repo check for max. SECONDS seconds (Default: unlimited)                                |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    | .. class:: borg-common-opt-ref                                                                                                                                                                                                         |    |                                                                                                                                                                                                                                        |    | :ref:`common_options`                                                                                                                                                                                                                  |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    | **Archive filters** — Archive filters can be applied to repository targets.                                                                                                                                                            |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``-a PATTERN``, ``--match-archives PATTERN`` | only consider archive names matching the pattern. see "borg help match-archives".                         |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--sort-by KEYS``                           | Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id; default is: timestamp |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--first N``                                | consider first N archives after other filters were applied                                                |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    |                                                                             | ``--last N``                                 | consider last N archives after other filters were 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.                                            |    +-----------------------------------------------------------------------------+----------------------------------------------+-----------------------------------------------------------------------------------------------------------+    .. raw:: html        <script type='text/javascript'>        $(document).ready(function () {            $('.borg-options-table colgroup').remove();        })        </script>.. only:: latex    optional arguments        --repository-only    only perform repository checks        --archives-only    only perform archives checks        --verify-data     perform cryptographic archive data integrity verification (conflicts with ``--repository-only``)        --repair          attempt to repair any inconsistencies found        --undelete-archives    attempt to undelete archives (use with --repair)        --max-duration SECONDS    do only a partial repo check for max. SECONDS seconds (Default: unlimited)    :ref:`common_options`        |    Archive filters        -a PATTERN, --match-archives PATTERN     only consider archive names matching the pattern. see "borg help match-archives".        --sort-by KEYS                           Comma-separated list of sorting keys; valid keys are: timestamp, archive, name, id; default is: timestamp        --first N                                consider first N archives after other filters were applied        --last N                                 consider last N archives after other filters were 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.Description~~~~~~~~~~~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   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   types of accidental damage can be detected this way. Running the repository   check can be split into multiple partial checks using ``--max-duration``.   When checking a remote repository, please note that the checks run on the   server and do not cause significant network traffic.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   reading archive and file metadata, but not data. To cryptographically verify   the file (content) data integrity pass ``--verify-data``, but keep in mind   that this requires reading all data and is hence very time consuming. When   checking archives of a remote repository, archive checks run on the client   machine because they require decrypting data and therefore the encryption   key.Both steps can also be run independently. Pass ``--repository-only`` to run therepository checks only, or pass ``--archives-only`` to run the archive checksonly.The ``--max-duration`` option can be used to split a long-running repositorycheck into multiple partial checks. After the given number of seconds the checkis interrupted. The next partial check will continue where the previous onestopped, until the full repository has been checked. Assuming a complete checkwould 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 fullrepository check aborts any previous partial check; the next partial check willrestart from the beginning. With partial repository checks you can run neitherarchive 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``.**Warning:** Please note that partial repository checks (i.e. running it with``--max-duration``) can only perform non-cryptographic checksum checks on therepository files. Enabling partial repository checks excepts archive checksfor the same reason. Therefore partial checks may be useful with very largerepositories only where a full check would take too long.The ``--verify-data`` option will perform a full integrity verification (asopposed to checking just the xxh64) of data, which means reading thedata from the repository, decrypting and decompressing it. It is a completecryptographic verification and hence very time consuming, but will detect anyaccidental and malicious corruption. Tamper-resistance is only guaranteed forencrypted repositories against attackers without access to the keys. You cannot use ``--verify-data`` with ``--repository-only``.About repair mode+++++++++++++++++The check command is a readonly task by default. If any corruption is found,Borg will report the issue and proceed with checking. To actually repair theissues 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!**Pursuant to the previous warning it is also highly recommended to test thereliability of the hardware running Borg with stress testing software. Thisespecially includes storage and memory testers. Unreliable hardware might leadto additional data loss.It is highly recommended to create a backup of your repository before runningin repair mode (i.e. running it with ``--repair``).Repair mode will attempt to fix any corruptions found. Fixing corruptions doesnot mean recovering lost data: Borg can not magically restore data lost due toe.g. a hardware failure. Repairing a repository means sacrificing some datafor 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: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.2. When checking the consistency and correctness of archives, repair mode might   remove whole archives from the manifest if their archive metadata chunk is   corrupt or lost. On a chunk level (i.e. the contents of files), repair mode   will replace corrupt or lost chunks with a same-size replacement chunk of   zeroes. If a previously zeroed chunk reappears, repair mode will restore   this lost chunk using the new chunk.Most steps taken by repair mode have a one-time effect on the repository, likeremoving a lost archive from the repository. However, replacing a corrupt orlost chunk with an all-zero replacement will have an ongoing effect on therepository: When attempting to extract a file referencing an all-zero chunk,the ``extract`` command will distinctly warn about it. The FUSE filesystemcreated by the ``mount`` command will reject reading such a "zero-patched"file unless a special mount option is given.As mentioned earlier, Borg might be able to "heal" a "zero-patched" file inrepair mode, if all its previously lost chunks reappear (e.g. via a laterbackup). This is achieved by Borg not only keeping track of the all-zeroreplacement chunks, but also by keeping metadata about the lost chunks. Inrepair mode Borg will check whether a previously lost chunk reappeared and willreplace the all-zero replacement chunk by the reappeared chunk. If all lostchunks of a "zero-patched" file reappear, this effectively "heals" the file.Consequently, if lost chunks were repaired earlier, it is advised to run``--repair`` a second time after creating some new backups.If ``--repair --undelete-archives`` is given, Borg will scan the repositoryfor archive metadata and if it finds some where no corresponding archivesdirectory entry exists, it will create the entries. This is basically undoing``borg delete archive`` or ``borg prune ...`` commands and only possible before``borg compact`` would remove the archives' data completely.
 |