[Question] Does borgmatic check repeat the repo check if I have multiple config files? #558

Closed
opened 2022-07-02 08:33:13 +00:00 by kaysond · 10 comments

I have a fairly large repo size (~2TB), so my previous consistency check strategy was to disable it in the archive creation runs, then do a separate manual borgmatic check via a weekly crontab.

I have a number of config files in /etc/borgmatic.d, all of which point to the same repository, but different archives. These config files all disable consistency checking. I then have a separate /etc/borgmatic_check.yml that gets used as the config for the check cron job.

I'm trying to simplify my config setup and noticed that at some point borgmatic updated to running the checks no more than once a month, with that interval being customizable.

My question is - if I leave consistency checking on for the config files in /etc/borgmatic.d, is it going to repeat the repo consistency check for every file? Or is it smart enough to only check the repo once?

I'd try it myself to check but doing the repo check once followed by all the archives takes ~8hrs

I have a fairly large repo size (~2TB), so my previous consistency check strategy was to disable it in the archive creation runs, then do a separate manual borgmatic check via a weekly crontab. I have a number of config files in /etc/borgmatic.d, all of which point to the same repository, but different archives. These config files all disable consistency checking. I then have a separate /etc/borgmatic_check.yml that gets used as the config for the check cron job. I'm trying to simplify my config setup and noticed that at some point borgmatic updated to running the checks no more than once a month, with that interval being customizable. My question is - if I leave consistency checking on for the config files in /etc/borgmatic.d, is it going to repeat the repo consistency check for every file? Or is it smart enough to only check the repo once? I'd try it myself to check but doing the repo check once followed by all the archives takes ~8hrs
Owner

It's smart enough to only check the repo once, since repository check frequency is performed on a per-repository basis! I just confirmed this by creating two configuration files pointing to the same repo and using the default check frequency of monthly in each. When I ran borgmatic check, passing in both configuration files, the check ran for the first configuration file but was skipped for the second.

The only caveat is that there's nothing enforcing that every configuration file for a repo has the same check configuration or the same check frequency. So if you set the frequency in one configuration file to monthly and another configuration file to every two weeks, borgmatic will blindly try to make that happen. (The every two weeks one will win, being more frequent.)

It's smart enough to only check the repo once, since repository check frequency is performed on a per-repository basis! I just confirmed this by creating two configuration files pointing to the same repo and using the default check frequency of monthly in each. When I ran `borgmatic check`, passing in both configuration files, the check ran for the first configuration file but was skipped for the second. The only caveat is that there's nothing enforcing that every configuration file for a repo has the same check configuration or the same check frequency. So if you set the frequency in one configuration file to monthly and another configuration file to every two weeks, borgmatic will blindly try to make that happen. (The every two weeks one will win, being more frequent.)
witten added the
question / support
label 2022-07-02 17:24:36 +00:00
Author

I just confirmed this by creating two configuration files

Don't know why I didn't think of testing it that way... probably because it was 1:30am :D
Thanks for the quick response!

> I just confirmed this by creating two configuration files Don't know why I didn't think of testing it that way... probably because it was 1:30am :D Thanks for the quick response!
kaysond reopened this issue 2022-07-03 23:31:41 +00:00
Author

@witten - Re-opening because I think I broke its "smartness"!

So in my setup, I have a base config file at /etc/borgmatic.d/common/borgmatic.yml like:

location:
    source_directories: ['.']
    one_file_system: true
    numeric_owner: true
    repositories:
        - repo1
        - repo2

storage:
    compression: zstd,8
    encryption_passphrase: 'blah'
    ssh_command: ssh -i /path/to/key
retention:
    keep_daily: 7
    keep_weekly: 4
    keep_monthly: 1

# Run manually every two weeks
consistency:
    checks:
        - disabled
        
hooks:
    healthchecks: https://healthchecks/ping

My actual config files in /etc/borgmatic.d/ all start with
<<: !include common/borgmatic.yml
and then overwrite the relevant keys like source_directories and healthchecks

When I run a regular borgmatic, it works as expected, executing all operations besides checking. If I run borgmatic --verbosity 2 check --override consistency.checks="[{name: 'repository'}, {name: 'archives'}]", though, it runs the repo checks multiple times!

I think I can get around this like I did before by specifying --config /etc/borgmatic.d/common/borgmatic.yml, but figured I'd mention this here.

All of this just to get a separate healthchecks ping for repo checks :)

@witten - Re-opening because I think I broke its "smartness"! So in my setup, I have a base config file at `/etc/borgmatic.d/common/borgmatic.yml` like: ``` location: source_directories: ['.'] one_file_system: true numeric_owner: true repositories: - repo1 - repo2 storage: compression: zstd,8 encryption_passphrase: 'blah' ssh_command: ssh -i /path/to/key retention: keep_daily: 7 keep_weekly: 4 keep_monthly: 1 # Run manually every two weeks consistency: checks: - disabled hooks: healthchecks: https://healthchecks/ping ``` My actual config files in `/etc/borgmatic.d/` all start with `<<: !include common/borgmatic.yml` and then overwrite the relevant keys like `source_directories` and `healthchecks` When I run a regular `borgmatic`, it works as expected, executing all operations besides checking. If I run `borgmatic --verbosity 2 check --override consistency.checks="[{name: 'repository'}, {name: 'archives'}]"`, though, it runs the repo checks multiple times! I think I can get around this like I did before by specifying `--config /etc/borgmatic.d/common/borgmatic.yml`, but figured I'd mention this here. All of this just to get a separate healthchecks ping for repo checks :)
Owner

When I run a regular borgmatic, it works as expected, executing all operations besides checking. If I run borgmatic --verbosity 2 check --override consistency.checks="[{name: 'repository'}, {name: 'archives'}]", though, it runs the repo checks multiple times!

I'm pretty sure that's because this override doesn't include a frequency for those two checks, and so therefore they're both defaulting to always. You can fix that by including a desired frequency in your override. For instance:

borgmatic --verbosity 2 check --override consistency.checks="[{name: 'repository', frequency: '2 weeks'}, {name: 'archives', frequency: '1 month'}]"

Let me know if something like that works for you.

All of this just to get a separate healthchecks ping for repo checks :)

This ticket may be of interest to you: #366.

> When I run a regular borgmatic, it works as expected, executing all operations besides checking. If I run borgmatic --verbosity 2 check --override consistency.checks="[{name: 'repository'}, {name: 'archives'}]", though, it runs the repo checks multiple times! I'm pretty sure that's because this override doesn't include a frequency for those two checks, and so therefore they're both defaulting to `always`. You can fix that by including a desired frequency in your override. For instance: ```bash borgmatic --verbosity 2 check --override consistency.checks="[{name: 'repository', frequency: '2 weeks'}, {name: 'archives', frequency: '1 month'}]" ``` Let me know if something like that works for you. > All of this just to get a separate healthchecks ping for repo checks :) This ticket may be of interest to you: #366.
Author

I'm pretty sure that's because this override doesn't include a frequency for those two checks, and so therefore they're both defaulting to always.

I want it to always run, though. When I run borgmatic via cron job #1, it does not run checks, as desired. When I run borgmatic check with the overrides via cron job #2, it does always run the checks like I want, but it runs the repo checks repeatedly, once for each file in /etc/borgmatic.d. That's what I don't want, since its unnecessary.

I worked around it by explicitly specifying a single config file in the command, but I think the default behavior should always be to run repo checks only once regardless of config setup!

> I'm pretty sure that's because this override doesn't include a frequency for those two checks, and so therefore they're both defaulting to always. I want it to always run, though. When I run `borgmatic` via cron job #1, it does not run checks, as desired. When I run `borgmatic check` with the overrides via cron job #2, it does always run the checks like I want, but it runs the repo checks repeatedly, once for each file in /etc/borgmatic.d. That's what I don't want, since its unnecessary. I worked around it by explicitly specifying a single config file in the command, but I think the default behavior should always be to run repo checks only once regardless of config setup!
Owner

Would a short frequency do it? For instance, including a frequency of 2 hours or so in your override?

Would a short frequency do it? For instance, including a frequency of `2 hours` or so in your override?
Owner

Closing this for now, but feel free to follow up. We can always reopen it. Thanks!

Closing this for now, but feel free to follow up. We can always reopen it. Thanks!
kaysond reopened this issue 2023-04-29 04:42:38 +00:00
Owner

It looks like you may have deleted your most recent comment. Perhaps you figured out the issue? If not, please feel free to let me know. Thanks!

It looks like you may have deleted your most recent comment. Perhaps you figured out the issue? If not, please feel free to let me know. Thanks!
Author

I misread the log files and thought this was still not working as expected. Turns out its something else! So I made a separate issue. Thanks for checking in though. Where do I send my nominations for best FOSS dev? :)

I misread the log files and thought this was still not working as expected. Turns out its something else! So I made a separate issue. Thanks for checking in though. Where do I send my nominations for best FOSS dev? :)
Owner

Hah, you're too kind. I'll check out the other ticket!

Hah, you're too kind. I'll check out the other ticket!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#558
No description provided.