How do I test the exclusions in the Borgmatic config? #680
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#680
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I want to test the exclusion filters in my Borgmatic config without having to create a real backup.
Here is how I test a single exclusion using plain Borg.
In the output
"-"
means "include" and"x"
means "exclude".My Borgmatic config looks like this:
I invoke Borgmatic like this:
The output is completely different. No list of files. The only maybe useful thing I see is an invocation of Borg (
borg create --dry-run ssh://...@....repo.borgbase.com/./repo::{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f} /home/isme --json
).What am I missing?
And why am I see so many hook outputs? I haven't configured any.
Environment
borgmatic version: 1.7.10
borgmatic installation method: pipx
Borg version: 1.2.4
Python version: 3.8.10
operating system and version: Ubuntu 20.04.5 LTS
I think what's going on is that in borgmatic, if
--json
and--list
are used together, the--list
flag gets ignored so as not to interfere with the JSON. That's because--list
output is not valid JSON and any tools consuming the output will choke on it. Maybe though borgmatic should error when both flags are used together?In terms of solving your particular need though, you could drop the
--json
flag and just use--list
, and then borgmatic should output all the added and excluded files. Or, if you really do need JSON output, maybe we need to add borgmatic support for--log-json
?At a high verbosity level (2), borgmatic is showing you absolutely everything it's doing, including the fact that it's removing stale database dumps—which it does regardless of hook configuration to prevent Borg hangs.
That would be great. The
--log-json
option was what I was trying to activate.The problem with the basic list format is that file names can contain newlines.
This command generates the basic list using plain Borg.
I use the next command to count the number of inclusions
-
and exclusionsx
. It reads the first character on each output line and counts the unique characters. But because of a rogue filename my data contains an extraC
character! (TheC
follows the newline in the filename.)To avoid that this command generates a JSON list using plain Borg.
The output is JSON lines. Each newline terminates a JSON-formatted record. Any newlines in the file names are now encoded in a JSON string. So I can count the number of inclusions and exclusions like this.
And I can count how many file names contain a newline.
Thanks. This does produce something useful when I add
--no-color
.I use the same command to count the inclusions and exclusions.
Borgmatic doesn't print any exclusions. So even with this output, it's still hard to see exactly what is being excluded.
Do I need to set something else to print the exlusions?
--log-json
is implemented now in main and will be part of the next release!As of borgmatic 1.7.8, excluded files are only shown with
--list
when at verbosity level 2 (e.g.--verbosity 2
).This was just released in borgmatic 1.7.13!
Got it. That's a bit surprising because
--verbosity=2
also adds a lot of output I don't need. Nonetheless, it does give me a solution.Now with Borgmatic 1.7.13 I can count the number of inclusions and exclusions like this:
The
sed
command prints only the JSON lines, dropping all the other stuff generated by the verbosity setting.Thanks a lot for addressing this. Now I have a robust way to test the configured Borgmatic exclusions.
I'm glad to hear it's working for you!