2019-02-04 07:20:59 +01:00
|
|
|
---
|
|
|
|
title: How to deal with very large backups
|
2020-08-21 23:27:47 +02:00
|
|
|
eleventyNavigation:
|
2022-05-20 20:11:35 +02:00
|
|
|
key: 📏 Deal with very large backups
|
2020-08-21 23:27:47 +02:00
|
|
|
parent: How-to guides
|
2022-06-17 00:30:53 +02:00
|
|
|
order: 4
|
2019-02-04 07:20:59 +01:00
|
|
|
---
|
|
|
|
## Biggish data
|
|
|
|
|
|
|
|
Borg itself is great for efficiently de-duplicating data across successive
|
2019-02-05 05:58:27 +01:00
|
|
|
backup archives, even when dealing with very large repositories. But you may
|
2023-03-08 23:05:06 +01:00
|
|
|
find that while borgmatic's default actions of `create`, `prune`, `compact`,
|
|
|
|
and `check` works well on small repositories, it's not so great on larger
|
|
|
|
ones. That's because running the default pruning, compact, and consistency
|
|
|
|
checks take a long time on large repositories.
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.7.9</span> The
|
|
|
|
default action ordering was `prune`, `compact`, `create`, and `check`.
|
2019-02-04 07:20:59 +01:00
|
|
|
|
|
|
|
### A la carte actions
|
|
|
|
|
2023-03-08 23:05:06 +01:00
|
|
|
If you find yourself wanting to customize the actions, you have some options.
|
2024-06-05 20:21:51 +02:00
|
|
|
First, you can run borgmatic's `create`, `prune`, `compact`, or `check`
|
2023-03-08 23:05:06 +01:00
|
|
|
actions separately. For instance, the following optional actions are
|
|
|
|
available (among others):
|
2019-02-04 07:20:59 +01:00
|
|
|
|
|
|
|
```bash
|
2023-03-08 23:05:06 +01:00
|
|
|
borgmatic create
|
2019-06-23 07:09:50 +02:00
|
|
|
borgmatic prune
|
2022-02-09 23:33:12 +01:00
|
|
|
borgmatic compact
|
2019-06-23 07:09:50 +02:00
|
|
|
borgmatic check
|
2019-02-04 07:20:59 +01:00
|
|
|
```
|
|
|
|
|
2023-03-08 23:05:06 +01:00
|
|
|
You can run borgmatic with only one of these actions provided, or you can mix
|
|
|
|
and match any number of them in a single borgmatic run. This supports
|
|
|
|
approaches like skipping certain actions while running others. For instance,
|
|
|
|
this skips `prune` and `compact` and only runs `create` and `check`:
|
2020-03-09 19:20:18 +01:00
|
|
|
|
|
|
|
```bash
|
|
|
|
borgmatic create check
|
|
|
|
```
|
|
|
|
|
2023-03-08 22:19:41 +01:00
|
|
|
<span class="minilink minilink-addedin">New in version 1.7.9</span> borgmatic
|
|
|
|
now respects your specified command-line action order, running actions in the
|
|
|
|
order you specify. In previous versions, borgmatic ran your specified actions
|
|
|
|
in a fixed ordering regardless of the order they appeared on the command-line.
|
|
|
|
|
|
|
|
But instead of running actions together, another option is to run backups with
|
|
|
|
`create` on a frequent schedule (e.g. with `borgmatic create` called from one
|
|
|
|
cron job), while only running expensive consistency checks with `check` on a
|
|
|
|
much less frequent basis (e.g. with `borgmatic check` called from a separate
|
|
|
|
cron job).
|
2020-03-09 19:20:18 +01:00
|
|
|
|
2023-11-09 03:22:17 +01:00
|
|
|
<span class="minilink minilink-addedin">New in version 1.8.5</span> Instead of
|
|
|
|
(or in addition to) specifying actions on the command-line, you can configure
|
|
|
|
borgmatic to [skip particular
|
|
|
|
actions](https://torsion.org/borgmatic/docs/how-to/set-up-backups/#skipping-actions).
|
|
|
|
|
2019-02-04 07:20:59 +01:00
|
|
|
|
|
|
|
### Consistency check configuration
|
|
|
|
|
2022-11-14 23:58:42 +01:00
|
|
|
Another option is to customize your consistency checks. By default, if you
|
2022-11-15 00:13:47 +01:00
|
|
|
omit consistency checks from configuration, borgmatic runs full-repository
|
|
|
|
checks (`repository`) and per-archive checks (`archives`) within each
|
2023-03-17 18:09:36 +01:00
|
|
|
repository. (Although see below about check frequency.) This is equivalent to
|
|
|
|
what `borg check` does if run without options.
|
2019-02-04 07:20:59 +01:00
|
|
|
|
2019-02-05 05:58:27 +01:00
|
|
|
But if you find that archive checks are too slow, for example, you can
|
2019-02-04 07:20:59 +01:00
|
|
|
configure borgmatic to run repository checks only. Configure this in the
|
|
|
|
`consistency` section of borgmatic configuration:
|
|
|
|
|
|
|
|
```yaml
|
2023-07-12 07:10:57 +02:00
|
|
|
checks:
|
|
|
|
- name: repository
|
2019-02-04 07:20:59 +01:00
|
|
|
```
|
|
|
|
|
2023-07-12 07:10:57 +02:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.8.0</span> Put
|
|
|
|
this option in the `consistency:` section of your configuration.
|
|
|
|
|
2023-03-17 18:09:36 +01:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.6.2</span> The
|
|
|
|
`checks` option was a plain list of strings without the `name:` part, and
|
|
|
|
borgmatic ran each configured check every time checks were run. For example:
|
2023-02-13 06:42:43 +01:00
|
|
|
|
|
|
|
```yaml
|
2023-07-12 07:10:57 +02:00
|
|
|
checks:
|
|
|
|
- repository
|
2023-02-13 06:42:43 +01:00
|
|
|
```
|
|
|
|
|
2022-05-29 04:03:45 +02:00
|
|
|
|
2020-04-29 20:08:41 +02:00
|
|
|
Here are the available checks from fastest to slowest:
|
|
|
|
|
|
|
|
* `repository`: Checks the consistency of the repository itself.
|
|
|
|
* `archives`: Checks all of the archives in the repository.
|
2024-04-15 21:51:07 +02:00
|
|
|
* `extract`: Performs an extraction dry-run of the latest archive.
|
2022-12-13 01:03:05 +01:00
|
|
|
* `data`: Verifies the data integrity of all archives contents, decrypting and decompressing all data.
|
2024-04-15 21:51:07 +02:00
|
|
|
* `spot`: Compares file counts and contents between your source files and the latest archive.
|
2022-12-13 01:03:05 +01:00
|
|
|
|
|
|
|
Note that the `data` check is a more thorough version of the `archives` check,
|
|
|
|
so enabling the `data` check implicitly enables the `archives` check as well.
|
2020-04-29 20:08:41 +02:00
|
|
|
|
2022-08-12 23:53:20 +02:00
|
|
|
See [Borg's check
|
|
|
|
documentation](https://borgbackup.readthedocs.io/en/stable/usage/check.html)
|
|
|
|
for more information.
|
2020-04-29 20:08:41 +02:00
|
|
|
|
2023-05-16 08:17:45 +02:00
|
|
|
|
2024-04-15 21:51:07 +02:00
|
|
|
### Spot check
|
|
|
|
|
|
|
|
The various consistency checks all have trade-offs around speed and
|
|
|
|
thoroughness, but most of them don't even look at your original source
|
|
|
|
files—arguably one important way to ensure your backups contain the files
|
2024-04-15 23:18:42 +02:00
|
|
|
you'll want to restore in the case of catastrophe (or just an accidentally
|
|
|
|
deleted file). Because if something goes wrong with your source files, most
|
|
|
|
consistency checks will still pass with flying colors and you won't discover
|
|
|
|
there's a problem until you go to restore.
|
2024-04-15 21:51:07 +02:00
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">New in version 1.8.10</span> <span
|
|
|
|
class="minilink minilink-addedin">Beta feature</span> That's where the spot
|
2024-04-15 23:18:42 +02:00
|
|
|
check comes in. This check actually compares your source file counts and data
|
2024-04-15 21:51:07 +02:00
|
|
|
against those in the latest archive, potentially catching problems like
|
|
|
|
incorrect excludes, inadvertent deletes, files changed by malware, etc.
|
|
|
|
|
|
|
|
However, because an exhaustive comparison of all source files against the
|
2024-04-15 23:18:42 +02:00
|
|
|
latest archive might be too slow, the spot check supports *sampling* a
|
2024-04-16 19:50:37 +02:00
|
|
|
percentage of your source files for the comparison, ensuring they fall within
|
2024-04-15 21:51:07 +02:00
|
|
|
configured tolerances.
|
|
|
|
|
2024-04-15 23:18:42 +02:00
|
|
|
Here's how it works. Start by installing the `xxhash` OS package if you don't
|
2024-04-15 21:51:07 +02:00
|
|
|
already have it, so the spot check can run the `xxh64sum` command and
|
|
|
|
efficiently hash files for comparison. Then add something like the following
|
|
|
|
to your borgmatic configuration:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
checks:
|
|
|
|
- name: spot
|
|
|
|
count_tolerance_percentage: 10
|
|
|
|
data_sample_percentage: 1
|
|
|
|
data_tolerance_percentage: 0.5
|
|
|
|
```
|
|
|
|
|
|
|
|
The `count_tolerance_percentage` is the percentage delta between the source
|
|
|
|
directories file count and the latest backup archive file count that is
|
|
|
|
allowed before the entire consistency check fails. For instance, if the spot
|
2024-04-15 23:18:42 +02:00
|
|
|
check runs and finds 100 source files on disk and 105 files in the latest
|
|
|
|
archive, that would be within the configured 10% count tolerance and the check
|
|
|
|
would succeed. But if there were 100 source files and 200 archive files, the
|
|
|
|
check would fail. (100 source files and only 50 archive files would also
|
|
|
|
fail.)
|
2024-04-15 21:51:07 +02:00
|
|
|
|
|
|
|
The `data_sample_percentage` is the percentage of total files in the source
|
|
|
|
directories to randomly sample and compare to their corresponding files in the
|
2024-04-15 23:18:42 +02:00
|
|
|
latest backup archive. A higher value allows a more accurate check—and a
|
2024-04-16 19:52:56 +02:00
|
|
|
slower one. The comparison is performed by hashing the selected source files
|
|
|
|
and counting hashes that don't match the latest archive. For instance, if you
|
|
|
|
have 1,000 source files and your sample percentage is 1%, then only 10 source
|
|
|
|
files will be compared against the latest archive. These sampled files are
|
|
|
|
selected randomly each time, so in effect the spot check is probabilistic.
|
2024-04-15 21:51:07 +02:00
|
|
|
|
|
|
|
The `data_tolerance_percentage` is the percentage of total files in the source
|
|
|
|
directories that can fail a spot check data comparison without failing the
|
|
|
|
entire consistency check. The value must be lower than or equal to the
|
2024-06-10 00:28:28 +02:00
|
|
|
`data_sample_percentage`, because `data_tolerance_percentage` only looks at
|
|
|
|
at the sampled files as determined by `data_sample_percentage`.
|
2024-04-15 21:51:07 +02:00
|
|
|
|
2024-04-15 23:18:42 +02:00
|
|
|
All three options are required when using the spot check. And because the
|
2024-04-15 21:51:07 +02:00
|
|
|
check relies on these configured tolerances, it may not be a
|
|
|
|
set-it-and-forget-it type of consistency check, at least until you get the
|
2024-04-15 23:18:42 +02:00
|
|
|
tolerances dialed in so there are minimal false positives or negatives. It is
|
|
|
|
recommended you run `borgmatic check` several times after configuring the spot
|
|
|
|
check, tweaking your tolerances as needed. For certain workloads where your
|
|
|
|
source files experience wild swings of file contents or counts, the spot check
|
|
|
|
may not suitable at all.
|
2024-04-15 21:51:07 +02:00
|
|
|
|
2024-04-15 23:18:42 +02:00
|
|
|
What if you add, delete, or change a bunch of your source files and you don't
|
2024-04-15 21:51:07 +02:00
|
|
|
want the spot check to fail the next time it's run? Run `borgmatic create` to
|
2024-04-15 23:18:42 +02:00
|
|
|
create a new backup, thereby allowing the next spot check to run against an
|
|
|
|
archive that contains your recent changes.
|
2024-04-15 21:51:07 +02:00
|
|
|
|
2024-04-16 19:57:34 +02:00
|
|
|
Because the spot check only looks at the most recent archive, you may not want
|
|
|
|
to run it immediately after a `create` action (borgmatic's default behavior).
|
|
|
|
Instead, it may make more sense to run the spot check on a separate schedule
|
|
|
|
from `create`.
|
|
|
|
|
2024-04-15 23:18:42 +02:00
|
|
|
As long as the spot check feature is in beta, it may be subject to breaking
|
|
|
|
changes. But feel free to use it in production if you're okay with that
|
|
|
|
caveat, and please [provide any
|
2024-04-15 21:51:07 +02:00
|
|
|
feedback](https://torsion.org/borgmatic/#issues) you have on this feature.
|
|
|
|
|
|
|
|
|
2022-05-28 23:42:19 +02:00
|
|
|
### Check frequency
|
|
|
|
|
2022-06-17 05:49:15 +02:00
|
|
|
<span class="minilink minilink-addedin">New in version 1.6.2</span> You can
|
|
|
|
optionally configure checks to run on a periodic basis rather than every time
|
|
|
|
borgmatic runs checks. For instance:
|
2022-05-28 23:42:19 +02:00
|
|
|
|
|
|
|
```yaml
|
2023-07-12 07:10:57 +02:00
|
|
|
checks:
|
|
|
|
- name: repository
|
|
|
|
frequency: 2 weeks
|
|
|
|
- name: archives
|
|
|
|
frequency: 1 month
|
2022-05-28 23:42:19 +02:00
|
|
|
```
|
|
|
|
|
2023-07-12 07:10:57 +02:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.8.0</span> Put
|
|
|
|
this option in the `consistency:` section of your configuration.
|
|
|
|
|
2022-07-04 07:24:25 +02:00
|
|
|
This tells borgmatic to run the `repository` consistency check at most once
|
|
|
|
every two weeks for a given repository and the `archives` check at most once a
|
2023-11-09 02:57:31 +01:00
|
|
|
month. The `frequency` value is a number followed by a unit of time, e.g. `3
|
|
|
|
days`, `1 week`, `2 months`, etc. The set of possible time units is as
|
2023-11-09 02:53:59 +01:00
|
|
|
follows (singular or plural):
|
|
|
|
|
|
|
|
* `second`
|
|
|
|
* `minute`
|
|
|
|
* `hour`
|
|
|
|
* `day`
|
|
|
|
* `week` (7 days)
|
|
|
|
* `month` (30 days)
|
|
|
|
* `year` (365 days)
|
2023-03-17 18:09:36 +01:00
|
|
|
|
|
|
|
The `frequency` defaults to `always` for a check configured without a
|
|
|
|
`frequency`, which means run this check every time checks run. But if you omit
|
|
|
|
consistency checks from configuration entirely, borgmatic runs full-repository
|
|
|
|
checks (`repository`) and per-archive checks (`archives`) within each
|
|
|
|
repository, at most once a month.
|
2022-05-28 23:42:19 +02:00
|
|
|
|
|
|
|
Unlike a real scheduler like cron, borgmatic only makes a best effort to run
|
|
|
|
checks on the configured frequency. It compares that frequency with how long
|
|
|
|
it's been since the last check for a given repository (as recorded in a file
|
|
|
|
within `~/.borgmatic/checks`). If it hasn't been long enough, the check is
|
2022-08-22 06:48:37 +02:00
|
|
|
skipped. And you still have to run `borgmatic check` (or `borgmatic` without
|
|
|
|
actions) in order for checks to run, even when a `frequency` is configured!
|
2022-05-28 23:42:19 +02:00
|
|
|
|
2022-07-02 18:40:49 +02:00
|
|
|
This also applies *across* configuration files that have the same repository
|
2022-08-22 06:48:37 +02:00
|
|
|
configured. Make sure you have the same check frequency configured in each
|
|
|
|
though—or the most frequently configured check will apply.
|
2022-07-02 18:40:49 +02:00
|
|
|
|
2022-05-29 04:29:33 +02:00
|
|
|
If you want to temporarily ignore your configured frequencies, you can invoke
|
|
|
|
`borgmatic check --force` to run checks unconditionally.
|
|
|
|
|
2023-12-28 19:22:48 +01:00
|
|
|
<span class="minilink minilink-addedin">New in version 1.8.6</span> `borgmatic
|
|
|
|
check --force` runs `check` even if it's specified in the `skip_actions`
|
|
|
|
option.
|
|
|
|
|
2022-05-28 23:42:19 +02:00
|
|
|
|
2024-06-26 23:57:59 +02:00
|
|
|
### Check days
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">New in version 1.8.13</span> You can
|
|
|
|
optionally configure checks to only run on particular days of the week. For
|
|
|
|
instance:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
checks:
|
|
|
|
- name: repository
|
|
|
|
only_run_on:
|
|
|
|
- Saturday
|
|
|
|
- Sunday
|
|
|
|
- name: archives
|
|
|
|
only_run_on:
|
|
|
|
- weekday
|
|
|
|
- name: spot
|
|
|
|
only_run_on:
|
|
|
|
- Friday
|
|
|
|
- weekend
|
|
|
|
```
|
|
|
|
|
|
|
|
Each day of the week is specified in the current locale (system
|
|
|
|
language/country settings). `weekend` and `weekday` are also accepted.
|
|
|
|
|
|
|
|
Just like with `frequency`, borgmatic only makes a best effort to run checks
|
|
|
|
on the given day of the week. For instance, if you run `borgmatic check`
|
|
|
|
daily, then every day borgmatic will have an opportunity to determine whether
|
|
|
|
your checks are configured to run on that day. If they are, then the checks
|
|
|
|
run. If not, they are skipped.
|
|
|
|
|
|
|
|
For instance, with the above configuration, if borgmatic is run on a Saturday,
|
|
|
|
the `repository` check will run. But on a Monday? The repository check will
|
|
|
|
get skipped. And if borgmatic is never run on a Saturday or a Sunday, that
|
|
|
|
check will never get a chance to run.
|
|
|
|
|
|
|
|
Also, the day of the week configuration applies *after* any configured
|
|
|
|
`frequency` for a check. So for instance, imagine the following configuration:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
checks:
|
|
|
|
- name: repository
|
|
|
|
frequency: 2 weeks
|
|
|
|
only_run_on:
|
|
|
|
- Monday
|
|
|
|
```
|
|
|
|
|
|
|
|
If you run borgmatic daily with that configuration, then borgmatic will first
|
|
|
|
wait two weeks after the previous check before running the check again—on the
|
|
|
|
first Monday after the `frequency` duration elapses.
|
|
|
|
|
|
|
|
|
2023-06-26 07:49:36 +02:00
|
|
|
### Running only checks
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">New in version 1.7.1</span> If you
|
|
|
|
would like to only run consistency checks without creating backups (for
|
|
|
|
instance with the `check` action on the command-line), you can omit
|
|
|
|
the `source_directories` option entirely.
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.7.1</span> In older
|
|
|
|
versions of borgmatic, instead specify an empty `source_directories` value, as
|
|
|
|
it is a mandatory option there:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
location:
|
|
|
|
source_directories: []
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2022-05-28 23:42:19 +02:00
|
|
|
### Disabling checks
|
|
|
|
|
2019-02-04 07:20:59 +01:00
|
|
|
If that's still too slow, you can disable consistency checks entirely,
|
|
|
|
either for a single repository or for all repositories.
|
|
|
|
|
2023-11-01 05:54:41 +01:00
|
|
|
<span class="minilink minilink-addedin">New in version 1.8.5</span> Disabling
|
|
|
|
all consistency checks looks like this:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
skip_actions:
|
|
|
|
- check
|
|
|
|
```
|
|
|
|
|
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.8.5</span> Use this
|
|
|
|
configuration instead:
|
2019-02-04 07:20:59 +01:00
|
|
|
|
|
|
|
```yaml
|
2023-07-12 04:42:14 +02:00
|
|
|
checks:
|
|
|
|
- name: disabled
|
2019-02-04 07:20:59 +01:00
|
|
|
```
|
|
|
|
|
2023-07-12 04:42:14 +02:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.8.0</span> Put
|
2023-11-01 05:54:41 +01:00
|
|
|
`checks:` in the `consistency:` section of your configuration.
|
2023-07-12 04:42:14 +02:00
|
|
|
|
2023-11-01 05:54:41 +01:00
|
|
|
<span class="minilink minilink-addedin">Prior to version 1.6.2</span>
|
|
|
|
`checks:` was a plain list of strings without the `name:` part. For instance:
|
2023-02-13 06:42:43 +01:00
|
|
|
|
|
|
|
```yaml
|
2023-07-12 07:10:57 +02:00
|
|
|
checks:
|
|
|
|
- disabled
|
2023-02-13 06:42:43 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
If you have multiple repositories in your borgmatic configuration file,
|
2019-02-04 07:20:59 +01:00
|
|
|
you can keep running consistency checks, but only against a subset of the
|
|
|
|
repositories:
|
|
|
|
|
|
|
|
```yaml
|
2023-07-12 04:42:14 +02:00
|
|
|
check_repositories:
|
|
|
|
- path/of/repository_to_check.borg
|
2019-02-04 07:20:59 +01:00
|
|
|
```
|
|
|
|
|
2023-07-19 08:27:45 +02:00
|
|
|
Finally, you can override your configuration file's consistency checks and
|
2019-09-19 20:50:29 +02:00
|
|
|
run particular checks via the command-line. For instance:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
borgmatic check --only data --only extract
|
|
|
|
```
|
|
|
|
|
|
|
|
This is useful for running slow consistency checks on an infrequent basis,
|
2022-05-28 23:42:19 +02:00
|
|
|
separate from your regular checks. It is still subject to any configured
|
2022-05-29 04:29:33 +02:00
|
|
|
check frequencies unless the `--force` flag is used.
|
2019-09-19 20:50:29 +02:00
|
|
|
|
2019-02-05 05:53:47 +01:00
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
|
|
|
### Broken pipe with remote repository
|
|
|
|
|
|
|
|
When running borgmatic on a large remote repository, you may receive errors
|
|
|
|
like the following, particularly while "borg check" is validating backups for
|
|
|
|
consistency:
|
|
|
|
|
|
|
|
```text
|
|
|
|
Write failed: Broken pipe
|
|
|
|
borg: Error: Connection closed by remote host
|
|
|
|
```
|
|
|
|
|
|
|
|
This error can be caused by an ssh timeout, which you can rectify by adding
|
|
|
|
the following to the `~/.ssh/config` file on the client:
|
|
|
|
|
|
|
|
```text
|
|
|
|
Host *
|
|
|
|
ServerAliveInterval 120
|
|
|
|
```
|
|
|
|
|
|
|
|
This should make the client keep the connection alive while validating
|
|
|
|
backups.
|