Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add optional check for existence of source directories #53

Conversation

diivi
Copy link
Collaborator

@diivi diivi commented Mar 17, 2023

Resolves #501.
Will add tests once I know if this is correct.

@diivi
Copy link
Collaborator Author

diivi commented Mar 17, 2023

@witten
This was the error when I tried to add a missing directory before:
image

Now:
image
Not sure if this was what was expected so I marked the PR as draft.

@witten
Copy link
Collaborator

witten commented Mar 18, 2023

So I think you found a legitimate bug in the current code! It looks like when database hooks are enabled and a non-existent directory is given in source_directories, then borgmatic gives the weird error message above (in your first screenshot) and exits. That's not intentional; non-existent source directories aren't supposed to cause errors (without your new option being set). When database hooks are not enabled and a non-existent directory is given in source_directories, Borg issues a warning but then continues on without any error, like this:

Processing files ...
/root/noexist: [Errno 2] No such file or directory: 'noexist'

Anyway, I think the bug you've uncovered occurs in collect_special_file_paths() in borgmatic/borg/create.py, which is triggered when a database hook is configured (or read_special is set to true). Specifically, the call to execute_command_and_capture_output() there blows up when one of the directories doesn't exist. At least, I think that's what's going on. If you want to try to fix the bug as part of this ticket it, you are welcome to do so. Otherwise, feel free to file it or just let me know and I'd be happy to have a look.

Copy link
Collaborator

@witten witten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes you have so far look good!

borgmatic/borg/create.py Outdated Show resolved Hide resolved
@diivi
Copy link
Collaborator Author

diivi commented Mar 18, 2023

Interesting, I'll work on that bug next, just to do one thing per PR.

@diivi diivi marked this pull request as ready for review March 18, 2023 12:00
@diivi diivi requested a review from witten March 18, 2023 20:27
@witten
Copy link
Collaborator

witten commented Mar 18, 2023

This is great. Thank you!

@witten witten merged commit 31d04d9 into borgmatic-collective:master Mar 18, 2023
@diivi
Copy link
Collaborator Author

diivi commented Mar 21, 2023

Specifically, the call to execute_command_and_capture_output() there blows up

Yes, I just checked, and this is what's happening. I don't understand why Borg raises an error when I have database hooks configured and pass a non-existent directory in this command though:

borg create --one-file-system --read-special --list --filter AMEx- /home/divyansh/Desktop/bkt2::{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f} /home/divyansh/Desktop/os12 /root/.borgmatic --dry-run --list

As you said, even when the source directory does not exist, it should just give a warning and continue.

Also, this (similar) command works (when I don't have database hooks configured):

borg create --list --filter AMEx- /home/divyansh/Desktop/bkt2::{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f} /home/divyansh/Desktop/os12 /root/.borgmatic --stats --debug --show-rc

@witten
Copy link
Collaborator

witten commented Mar 21, 2023

I'm gonna move this discuss over to https://projects.torsion.org/borgmatic-collective/borgmatic/issues/655! I'll respond there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants